Search⌘ K
AI Features

Dealing with Bad Releases

Explore how to manage Kubernetes deployments effectively by learning to handle bad releases. Understand manual rollbacks and how readiness probes can automatically prevent problematic updates, ensuring your application stays stable and responsive during deployments.

Deployments also allow us to mitigate the risk of a bad release either by letting us manually rollback this release or by automatically preventing this release from happening.

Let’s test that out by creating a new version that simulates an issue. Here’s the updated code for our app:

Manually blocking the bad release

Ruby
require "sinatra"
set :bind, "0.0.0.0"
$counter = 0
get "*" do
$counter += 1
if $counter > 3
raise "Whoops, something is wrong"
end
"[buggy] Hello, Kubernetes!\n"
end

After three successful responses, the app crashes with an exception. This allows us to simulate a case where the app starts running correctly but after some time it starts failing. We’ve pushed this buggy image to Docker Hub by using the following commands:

Rust 1.40.0
docker build . -t brianstorti/hellok8s:buggy
docker push brianstorti/hellok8s:buggy

Let’s update the manifest to start using this new image.

YAML
apiVersion: apps/v1
kind: Deployment
metadata:
name: hellok8s
spec:
replicas: 2
selector:
matchLabels:
app: hellok8s
template:
metadata:
labels:
app: hellok8s
spec:
containers:
- image: brianstorti/hellok8s:buggy
name: hellok8s-container

We can apply this manifest using the following command to see ...