Kubernetes

5 Different Types of Kubernetes Deployment Strategies

Kubernetes Deployment Strategies

In this post, we will delve into Kubernetes (K8s) deployment concepts and some common strategies, looking at the advantages and disadvantages of each. A suitable deployment strategy enables you to minimize downtime, enhance your customer experience, and increase reliability when releasing your application.

What is a Kubernetes Deployment Strategy?

See how Spacelift can help you manage the complexities and compliance challenges of using Kubernetes with the newest Kubernetes integration.

1) Recreating Deployments

spec:
  replicas: 10
  strategy:
    type: Recreate

2) Rolling Deployments

  • Readiness probes monitor when the application becomes available. If the probes fail, no traffic will be sent to the pod. These are used when an app needs to perform certain initialization steps before it becomes ready. An application may also become overloaded with traffic and cause the probe to fail, preventing more traffic from being sent to it and allowing it to recover.
  • MaxSurge specifies the maximum number of pods the Deployment is allowed to create at one time.
  • MaxUnavailable specifies the maximum number of pods that are allowed to be unavailable during the rollout.
spec:
  replicas: 10
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 3
      maxUnavailable: 1

3) Blue/Green Deployments

kind: Service
metadata:
 name: web-app-01
 labels:
   app: web-app
selector:
   app: web-app
   version: v1.0.0

And the deployment for the blue web app:

kind: Deployment
metadata:
  name: web-app-01
spec:
  template:
        metadata:
           labels:
             app: web-app
             version: "v1.0.0"

When we want to direct traffic to the new (green) version of the app, we update the manifest to point to the new version, v2.0.0.

kind: Service
metadata:
 name: web-app-02
 labels:
   app: web-app
selector:
   app: web-app
   version: v2.0.0

The deployment for the green app:

kind: Deployment
metadata:
  name: web-app-02
spec:
  template:
        metadata:
           labels:
             app: web-app
             version: "v2.0.0"

4) Canary Deployments

spec:
  replicas: 95

And the new application manifest:

spec:
  replicas: 5

In the example above, it might be impractical and costly to run 100 pods. A better way to achieve this is to use a load balancer such as NGINXHAProxy, or Traefik, or a service mesh like IstioHashicorps Consul, or Linkrd.

For painless and efficient maintenance of your K8s clusters, follow these 15 Kubernetes Best Practices.

5) A/B Deployments

Key Points

The most Flexible CI/CD Automation Tool

Spacelift is an alternative to using homegrown solutions on top of a generic CI. It helps overcome common state management issues and adds several must-have capabilities s for infrastructure management.

Start free trial