📄️ Kubernetes Architecture
k8s-architecture-dicoding-image
📄️ Kubernetes General Commands
Cluster Information
📄️ Kubernetes Manifest Breakdown
A Kubernetes manifest file is a configuration file written in YAML or JSON that describes the desired state of objects in a Kubernetes cluster. The file defines a wide variety of attributes for managing different resources, such as Pods, Deployments, Services, and more.
📄️ Namespace
Namespace in Kubernetes is basically an abstraction to divide cluster into sub-virtual cluster that isolate from each other. We can group resources based on department on team with namespace by creating namespace and then assign any kubernetes objects to it.
📄️ Pod
A Pod is the smallest deployable unit in Kubernetes, representing a single instance of a running process in the cluster. It typically contains one or more containers, shared storage volumes, a unique IP address, and configurations such as environment variables and resource limits.
📄️ Service
In Kubernetes, a Service is an abstraction that defines a logical set of Pods and provides a stable endpoint (IP and DNS) to access them. It enables reliable communication between different Pods or external systems, regardless of changes in the underlying Pods' IPs.
📄️ ReplicaSet
A ReplicaSet guarantees that a certain number of pod replicas are running at all times. However, a Deployment is a more advanced concept that oversees ReplicaSets and offers declarative updates to Pods, along with many other valuable features. As a result, it's generally recommended to use Deployments rather than directly working with ReplicaSets, unless you need specific update control or don't need updates at all.
📄️ Deployment
A Deployment in Kubernetes manages the lifecycle of a set of Pods, ensuring that the desired number of replicas are running and updated in a controlled manner. It supports rolling updates, rollbacks, and scaling, providing high availability and easy management of applications.
📄️ Horizontal Pod Autoscaler
Horizontal Pod Autoscaler (HPA) in Kubernetes is an API resource and controller that automatically adjusts the number of replicas in a Deployment based on observed metrics, such as average CPU usage. It scales up or down the replicas depending on whether the actual CPU usage exceeds the target percentage, which is based on the Pod's CPU resource request. If no CPU resource request is set, autoscaling will not occur.
📄️ Volume and Persistent Volume
Volume
📄️ Assign PV and PVC to Deployment
In this example I will use MySQL deployment as an example
📄️ ConfigMap
A ConfigMap in Kubernetes stores configuration data as key-value pairs, allowing applications to separate configuration from code. It can be used to inject environment variables, command-line arguments, or mount configuration files into Pods. This makes applications more portable and easier to manage across different environments.
📄️ Secret
Secret is an object used to store sensitive data, such as passwords, OAuth tokens, SSH keys, or any other type of sensitive information. Secrets allow you to keep this data secure and separate from your application code.
📄️ StatefulSet
A StatefulSet is a Kubernetes resource used to manage stateful applications that require stable, unique network identifiers, persistent storage, and ordered deployment and scaling. Unlike a regular Deployment, which manages stateless applications, a StatefulSet ensures that each pod in the set has a unique, persistent identity and storage that survives pod rescheduling or scaling.
📄️ Job
A Job in Kubernetes is a controller that creates one or more pods and ensures that they run until completion. The primary use case for a Job is to run a batch or parallelized task that is expected to run to completion, such as data processing or running a one-off script. It is typically used for tasks that are not long-lived or that need to run in the background to completion.
📄️ CronJob
- A CronJob adds the concept of schedule. Similar like CronJob in Linux
📄️ DaemonSet
- Runs a copy of the pod specified in the yaml file on all or specified numbers of worker nodes in the cluster
📄️ Ingress
- Enable routing traffic to many services via a single LoadBalancer
🗃️ 📂 Example k8s Projects
1 item