Key Components and Architecture of Kubernetes

Kubernetes (k8s) is a container orchestration system that enables automated deployment, scaling, and management of applications. To define Kubernetes components, we use YAML files that describe how containers should be managed within the cluster.


This content originally appeared on DEV Community and was authored by Aleson França

Kubernetes (k8s) is a container orchestration system that enables automated deployment, scaling, and management of applications. To define Kubernetes components, we use YAML files that describe how containers should be managed within the cluster.

Pod

A Pod is the smallest unit in Kubernetes. It can contain one or more containers. Pods are created and destroyed as needed. They are not persistent by default (but can use volumes to persist data).

Networking: Containers in the same Pod share the same IP address and ports.
Storage: Volumes can be mounted and shared between containers within the Pod.
Life Cycle: All containers in the Pod start and stop together. If the Pod is deleted, all containers within it are terminated.

Example of how to create a YAML for pods.

apiVersion: v1
kind: Pod
metadata:
  name: my-pod
spec:
  containers:
    - name: app
      image: nginx

ReplicaSet

Ensures that a fixed number of Pod replicas are running.
If a Pod fails or is deleted, the ReplicaSet automatically creates a new Pod to replace it.
Selectors identify which Pods the ReplicaSet should manage.

Example of how to create a YAML for ReplicaSet.

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: my-replicaset
spec:
  replicas: 3
  selector:
    matchLabels:
      app: minha-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
        - name: app
          image: nginx

Deployment

Manages application updates and rollbacks (without downtime). Manages ReplicaSets to ensure the desired number of Pod replicas.

Each Deployment update creates a new ReplicaSet, allowing control over different application versions. It gradually replaces old Pods with new ones, ensuring the application remains available during updates.

Example of how to create a YAML for Deployment.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
        - name: app
          image: nginx

StatefulSet

Used for applications that need a fixed identity, such as databases. Each Pod in a StatefulSet receives a unique and stable identifier, ensuring predictable network names and storage.

Ensures each Pod has an exclusive persistent volume, even after failures or restarts.
Maintains static network addresses for each Pod even after restarts.

Example of how to create a YAML for StatefulSet.

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: my-statefulset
spec:
  serviceName: "my-service"
  replicas: 2
  selector:
    matchLabels:
      app: database
  template:
    metadata:
      labels:
        app: database
    spec:
      containers:
        - name: db
          image: mysql

Service

Defines how a set of Pods is accessed. Provides stable IP and DNS addresses to access Pods, even if they are recreated or moved.
Distributes network traffic among Pods that match the Service selector.

Example of how to create a YAML for Service.

apiVersion: v1
kind: Service
metadata:
  name: my-servico
spec:
  selector:
    app: my-app
  type: LoadBalancer
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080

ConfigMap

Stores configuration variables for Pods. Data in a ConfigMap is stored as key-value pairs, making it easy for Pods to access and use.

Using ConfigMaps separates application settings from code, making the application easier to manage. Settings can be changed without rebuilding the container image.

A ConfigMap has a maximum size of 1MB. For larger configurations, other solutions like persistent volumes may be needed.

Example of how to create a YAML for Service.

apiVersion: v1
kind: ConfigMap
metadata:
  name: my-config
data:
  APP_MODE: "production"
  TIMEOUT: "30"

Conclusion

Kubernetes has several components that help manage applications in a scalable and reliable way. Its ability to efficiently orchestrate containers automatically allows development and operations teams to focus on creating business value, rather than worrying about infrastructure complexity.


This content originally appeared on DEV Community and was authored by Aleson França


Print Share Comment Cite Upload Translate Updates
APA

Aleson França | Sciencx (2025-02-10T22:18:53+00:00) Key Components and Architecture of Kubernetes. Retrieved from https://www.scien.cx/2025/02/10/key-components-and-architecture-of-kubernetes/

MLA
" » Key Components and Architecture of Kubernetes." Aleson França | Sciencx - Monday February 10, 2025, https://www.scien.cx/2025/02/10/key-components-and-architecture-of-kubernetes/
HARVARD
Aleson França | Sciencx Monday February 10, 2025 » Key Components and Architecture of Kubernetes., viewed ,<https://www.scien.cx/2025/02/10/key-components-and-architecture-of-kubernetes/>
VANCOUVER
Aleson França | Sciencx - » Key Components and Architecture of Kubernetes. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/02/10/key-components-and-architecture-of-kubernetes/
CHICAGO
" » Key Components and Architecture of Kubernetes." Aleson França | Sciencx - Accessed . https://www.scien.cx/2025/02/10/key-components-and-architecture-of-kubernetes/
IEEE
" » Key Components and Architecture of Kubernetes." Aleson França | Sciencx [Online]. Available: https://www.scien.cx/2025/02/10/key-components-and-architecture-of-kubernetes/. [Accessed: ]
rf:citation
» Key Components and Architecture of Kubernetes | Aleson França | Sciencx | https://www.scien.cx/2025/02/10/key-components-and-architecture-of-kubernetes/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.