Kubernetes

8 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?

  • Recreating
  • Rolling
  • Blue/Green
  • Canary
  • A/B
  • Ramped Slow Rollout
  • Best-Effort Controlled Rollout
  • Shadow Deployment

See how Spacelift can help you manage the complexities and compliance challenges of using Kubernetes with the newest Kubernetes integration. It brings with it a GitOps flow, so your Kubernetes Deployments are synced with your Kubernetes Stacks, and pull requests show you a preview of what they’re planning to change. It also has an extensive selection of policies, which lets you automate compliance checks and build complex multi-stack workflows.

1. Recreate Deployment

spec:
  replicas: 10
  strategy:
    type: Recreate

2. Rolling Deployment

  • 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. Ramped Slow Rollout

Ramped Slow Rollout means the new version is rolled out slowly, creating new replicas replacing the old ones. This is also another term for a Canary deployment that we discuss later in the article.

4. Blue/Green Deployment

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"

5. Best-Effort Controlled Rollout

Blue / green deployments may also be referred to as ‘best-effort controlled rollouts’ — again, with the focus on updating your application or microservices with a focus on minimizing downtime and ensuring that the application remains available as much as possible during the deployment process.

6. Shadow Deployment

Canary or ‘Ramped slow rollout’ strategies are sometimes used interchangeably with the term ‘Shadow Deployment’.

A Shadow Deployment is a strategy where a new version of an application is deployed alongside the existing production version, primarily for monitoring and testing purposes. User traffic is not actively routed to the new version in a shadow deployment.

7. 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.

8. 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