Sunday, August 24, 2025

What is Blue / Green deployment in Kubernetes? What are best practices for this?

Details about Kubernetes namespaces and Blue / Green deployment 


Namespaces provide isolation and multi-tenancy. Teams can be restricted to their namespace.

Most Kubernetes resources (Pods, Deployments, Services, ConfigMaps, Secrets) are namespace-scoped.

Some resources (Nodes, PVs, ClusterRoles, StorageClasses) are cluster-scoped.

Services are namespaced, but accessible across namespaces using FQDN.

Blue/Green deployment in Kubernetes typically uses two Deployments and a single Service to switch traffic.

Blue/Green does not require separate namespaces, but namespaces can be used if teams want strict separation.

Tools like kubens make namespace management easier.


Expanding on Blue/Green Deployment in Kubernetes


Blue/Green Deployment is a strategy where you run two parallel environments:

- Blue → the current running version

- Green → the new version


After verification, traffic is switched from Blue → Green.


How it works in Kubernetes:

- Typically, two Deployments (blue + green) run in the same namespace.

- Both versions exist simultaneously (e.g., my-app-blue, my-app-green).

- A Service acts as a stable entry point and is switched from pointing to Blue Pods → Green Pods.


Are Blue/Green deployments categorized by namespaces?

- Not necessarily.

- They are usually implemented within the same namespace (e.g., prod) to simplify Service routing.

- But some organizations use separate namespaces (blue-ns, green-ns) for stricter isolation. In that case, Service discovery uses cross-namespace FQDNs.


Are underlying resources the same between Blue/Green?

- No, Blue and Green typically have separate resources (Pods, ConfigMaps, Secrets, PVCs if needed).

- Shared cluster-wide resources like Nodes, PVs, Network Policies may be reused.

- Whether you duplicate configs or not depends on your CI/CD pipeline.


How namespaces help in Blue/Green?

- If you use separate namespaces: you get clean isolation (configs, secrets, RBAC).

- If you use the same namespace: switching traffic is simpler (Service just updates its selector).


No comments:

Post a Comment