...

/

Dealing with Bad Releases

Dealing with Bad Releases

Learn how we can manually and automatically prevent bad releases.

We'll cover the following...

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

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:

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

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

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 the rolling update happening again until all the pods running are using this new ...