Overview of Kubernetes architecture with examples

Category : Kubernetes | Sub Category : Learn Kubernetes | By Prasad Bonam Last updated: 2023-11-22 07:09:52 Viewed : 214


Lets go through the key components of Kubernetes architecture with examples:

  1. Master Node:

    • API Server:

      • Example: kubectl is a command-line tool that interacts with the API server. For instance, kubectl get pods fetches information about running pods.
    • Controller Manager:

      • Example: The Replication Controller ensures a specified number of replicas of a pod are running at all times. If a pod fails, the Replication Controller creates a new one.
      yaml
      apiVersion: v1 kind: ReplicationController metadata: name: my-replication-controller spec: replicas: 3 selector: app: my-app template: metadata: labels: app: my-app spec: containers: - name: my-container image: my-image
    • Scheduler:

      • Example: When you create a new pod without specifying a node, the scheduler selects an appropriate node based on resource requirements and availability.
  2. Node (Minion) / Worker Node:

    • Kubelet:

      • Example: The Kubelet ensures that containers in a pod are running. If a pod definition specifies two containers, the Kubelet ensures both are running.
      yaml
      apiVersion: v1 kind: Pod metadata: name: my-pod spec: containers: - name: container-1 image: image-1 - name: container-2 image: image-2
    • Container Runtime:

      • Example: Docker is a popular container runtime. Kubernetes interacts with the Docker runtime to start, stop, and manage containers.
    • Kube Proxy:

      • Example: Kube Proxy maintains network rules. For example, it sets up routing to forward external traffic to a service and its pods.
      yaml
      apiVersion: v1 kind: Service metadata: name: my-service spec: selector: app: my-app ports: - protocol: TCP port: 80 targetPort: 8080
  3. Pod:

    • Example: A simple pod definition with a single container.
    yaml
    apiVersion: v1 kind: Pod metadata: name: my-pod spec: containers: - name: my-container image: my-image
  4. Controller:

    • ReplicaSet:
      • Example: Ensures a specified number of replicas of a pod are running. If a pod fails, it creates a new one.
      yaml
      apiVersion: apps/v1 kind: ReplicaSet metadata: name: my-replicaset spec: replicas: 3 selector: matchLabels: app: my-app template: metadata: labels: app: my-app spec: containers: - name: my-container image: my-image
  5. Service:

    • Example: Exposes a set of pods as a network service. For instance, a frontend service exposing pods with the label app: frontend.
    yaml
    apiVersion: v1 kind: Service metadata: name: frontend-service spec: selector: app: frontend ports: - protocol: TCP port: 80 targetPort: 8080
  6. Volume:

    • Example: A pod with a persistent volume that survives pod restarts.
    yaml
    apiVersion: v1 kind: Pod metadata: name: my-pod spec: containers: - name: my-container image: my-image volumeMounts: - name: my-volume mountPath: /data volumes: - name: my-volume emptyDir: {}
  7. Namespace:

    • Example: Creating a pod in a specific namespace.
    yaml
    apiVersion: v1 kind: Pod metadata: name: my-pod namespace: my-namespace spec: containers: - name: my-container image: my-image
  8. Label:

    • Example: Applying a label to a pod.
    yaml
    apiVersion: v1 kind: Pod metadata: name: my-pod labels: app: my-app spec: containers: - name: my-container image: my-image
  9. Annotation:

    • Example: Adding an annotation to a pod.
    yaml
    apiVersion: v1 kind: Pod metadata: name: my-pod annotations: description: "This is my pod" spec: containers: - name: my-container image: my-image

Understanding these examples should provide you with a practical overview of how these components are used in Kubernetes architecture.

Search
Related Articles

Leave a Comment: