Prompt

How do I use Kubernetes for blue-green deployments?

Technology / Cloud Infrastructure1 observationLast seen Oct 13, 2026

Latest observation

Oct 13, 2026OpenAI APIWeb search: off

Blue-green deployments in Kubernetes mean you run two nearly identical environments:

  • Blue = current production version
  • Green = new version you want to release

You switch traffic from Blue to Green only after the new version is verified. If something goes wrong, you switch back quickly.

Common Kubernetes approach

1) Deploy both versions

Create two Deployments, one for each version:

  • app-blue
  • app-green

Each has its own Pods, but both run the same app with different image tags/configs.

2) Use one Service to route traffic

Create a Kubernetes Service that points to only one version at a time by selecting labels:

  • Initially, Service selects version: blue
  • After validation, change Service selector to version: green

This is the main traffic switch.

3) Validate green before switching

Before changing the Service:

  • run smoke tests against green
  • check logs/metrics
  • verify readiness/liveness probes

4) Switch traffic

Update the Service selector:

spec:
  selector:
    app: myapp
    version: green

Kubernetes will start sending new traffic to green Pods.

5) Roll back if needed

If green has issues, switch the Service selector back to blue.


Example

Blue Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp-blue
spec:
  replicas: 3
  selector:
    matchLabels:
      app: myapp
      version: blue
  template:
    metadata:
      labels:
        app: myapp
        version: blue
    spec:
      containers:
      - name: myapp
        image: myapp:1.0.0
        ports:
        - containerPort: 8080

Green Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp-green
spec:
  replicas: 3
  selector:
    matchLabels:
      app: myapp
      version: green
  template:
    metadata:
      labels:
        app: myapp
        version: green
    spec:
      containers:
      - name: myapp
        image: myapp:1.1.0
        ports:
        - containerPort: 8080

Service

apiVersion: v1
kind: Service
metadata:
  name: myapp-service
spec:
  selector:
    app: myapp
    version: blue
  ports:
  - port: 80
    targetPort: 8080

Switching to green

Patch the Service:

kubectl patch service myapp-service -p '{"spec":{"selector":{"app":"myapp","version":"green"}}}'

Important considerations

Readiness probes

Make sure Pods only receive traffic when ready:

readinessProbe:
  httpGet:
    path: /health
    port: 8080
  initialDelaySeconds: 5
  periodSeconds: 5

Sticky sessions/state

Blue-green works best for stateless apps. If your app has:

  • in-memory session state
  • local files
  • incompatible database migrations

you need to handle those carefully.

Database migrations

Prefer backward-compatible migrations so both blue and green can work during the transition.

Resource usage

Blue-green temporarily doubles your resource usage since both versions run at once.


Alternatives

You can also use:

  • Ingress/Load Balancer switching
  • Argo Rollouts
  • Flagger
  • Service mesh like Istio for more advanced traffic splitting

These tools can make blue-green safer and more automated.


If you want, I can also give you:

  1. a full working YAML example,
  2. an Argo Rollouts blue-green setup, or
  3. a step-by-step rollout workflow.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.