[Testing] K8s Deployment Strategies Without the Hype — Just Native Solutions

1 min read

The Recreate strategy is the simplest to understand. When a new version of your application is deployed, Kubernetes terminates all the existing Pods before spinning up the new ones. This strategy ensures that only one version of the application is ever running at a time.
 

However, this simplicity comes at the cost of downtime, which might be acceptable in development or internal services but is usually not desirable for production systems.
 

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  strategy:
    type: Recreate
  replicas: 3
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
      - name: my-container
        image: my-image:v2
        ports:
        - containerPort: 80