Daily Shaarli

All links of one day in a single page.

December 4, 2024

Note: What is a deployment and a pod in GKE?

Let me explain Deployments and Pods in the context of Google Kubernetes Engine (GKE):

Pod:

  1. Basic Unit of Deployment

    • Smallest and simplest Kubernetes object
    • Represents a single instance of a running process
    • Can contain one or more containers
    • All containers in a pod share:
    • Network namespace
    • IP address
    • Storage volumes
    • Host ports
  2. Key Characteristics:

    • Ephemeral (can be created and destroyed quickly)
    • Have a unique IP address within the cluster
    • Designed to be disposable and replaceable
    • Containers within a pod can communicate easily

Deployment:

  1. Management Object

    • Provides declarative updates for Pods and ReplicaSets
    • Defines the desired state for your application
    • Manages the scaling and self-healing of pods
    • Ensures specified number of pod replicas are running
  2. Key Features:

    • Automatic rollbacks
    • Easy scaling of application instances
    • Rolling updates with zero downtime
    • Ensures high availability of applications

Example Kubernetes Deployment YAML:

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

Relationship:

  • A Deployment manages multiple Pods
  • Ensures specified number of Pod replicas are running
  • Handles pod replacement if they fail
  • Facilitates updates and rollbacks

In GKE:

  • Provides managed Kubernetes environment
  • Handles cluster infrastructure
  • Simplifies deployment and management of containerized applications
  • Offers automatic scaling and updates