Kubernetes – You Should ALWAYS Specify A RollingUpdate Strategy On Your Deployments!

apiVersion: apps/v1
kind: Deployment
metadata:
name: helloworld-deployment
spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%

selector:
matchLabels:
app.kubernetes.io/name: helloworld-deployment
replicas: 2
template:
metadata:
labels:
app.kubernetes.io/name: helloworld-deployment
spec:
containers:
- name: hello-world
image: helloworld-webserver:1.0.0
resources:
requests:
cpu: 25m
memory: 32Mi
limits:
cpu: 50m
memory: 64Mi
apiVersion: v1
kind: ResourceQuota
metadata:
name: default-resource-quotas
spec:
hard:
requests.cpu: "50m"
>kubectl -n local-demo-rolloutstrategy-ns get pod
NAME READY STATUS RESTARTS AGE
helloworld-deployment-6469589dcf-l9sfl 1/1 Running 0 72s
helloworld-deployment-6469589dcf-rmbnv 1/1 Running 0 75s
apiVersion: apps/v1
kind: Deployment
metadata:
name: helloworld-deployment
spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
selector:
matchLabels:
app.kubernetes.io/name: helloworld-deployment
replicas: 2
template:
metadata:
labels:
app.kubernetes.io/name: helloworld-deployment
spec:
containers:
- name: hello-world
image: helloworld-webserver:1.0.1
resources:
requests:
cpu: 25m
memory: 32Mi
limits:
cpu: 50m
memory: 64Mi
>kubectl -n local-demo-rolloutstrategy-ns get rs
NAME DESIRED CURRENT READY AGE
helloworld-deployment-6469589dcf 2 2 2 3m11s
helloworld-deployment-6c8c486b5c 1 0 0 119s
> kubectl -n local-demo-rolloutstrategy-ns describe rs helloworld-deployment-6c8c486b5c....
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedCreate 7s replicaset-controller Error creating: pods "helloworld-deployment-6c8c486b5c-lk87v" is forbidden: exceeded quota: default-resource-quotas, requested: requests.cpu=25m, used: requests.cpu=50m, limited: requests.cpu=50m
Warning FailedCreate 7s replicaset-controller Error creating: pods "helloworld-deployment-6c8c486b5c-x5czs" is forbidden: exceeded quota: default-resource-quotas, requested: requests.cpu=25m, used: requests.cpu=50m, limited: requests.cpu=50m
>kubectl -n local-demo-rolloutstrategy-ns get pod
NAME READY STATUS RESTARTS AGE
helloworld-deployment-6469589dcf-l9sfl 1/1 Running 0 4m56s
helloworld-deployment-6469589dcf-rmbnv 1/1 Running 0 4m59s
apiVersion: apps/v1
kind: Deployment
metadata:
name: helloworld-deployment
spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 0%
maxUnavailable: 25%
selector:
matchLabels:
app.kubernetes.io/name: helloworld-deployment
replicas: 2
template:
metadata:
labels:
app.kubernetes.io/name: helloworld-deployment
spec:
containers:
- name: hello-world
image: helloworld-webserver:1.0.1
resources:
requests:
cpu: 25m
memory: 32Mi
limits:
cpu: 50m
memory: 64Mi
>kubectl -n local-demo-rolloutstrategy-ns get pod
NAME READY STATUS RESTARTS AGE
helloworld-deployment-6469589dcf-l9sfl 1/1 Terminating 0 5m31s
helloworld-deployment-6469589dcf-rmbnv 1/1 Running 0 5m34s
...
>kubectl -n local-demo-rolloutstrategy-ns get pod
NAME READY STATUS RESTARTS AGE
helloworld-deployment-5d4b48b96d-4sw7x 1/1 Running 0 3s
helloworld-deployment-6469589dcf-rmbnv 1/1 Terminating 0 5m55s
...
>kubectl -n local-demo-rolloutstrategy-ns get pod
NAME READY STATUS RESTARTS AGE
helloworld-deployment-5d4b48b96d-4sw7x 1/1 Running 0 83s
helloworld-deployment-5d4b48b96d-b24c7 1/1 Running 0 39s

Distinguished Architect at Sun Life Financial. Focused on containers & Kubernetes. Views & opinions expressed here are my own, not necessarily those of Sun Life

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

CRDT storage for the Edge

Building the Brex API

Create Todo list app with Python Flask and Vue.js. Part 1

Shake significant suffer language.

How Salesforce Labs Uses Test Drives to Drive Adoption

Dilemma of a person who is new to learning code.

Starting out into the world of Algorithmic Trading | Python

What is Continuous Delivery? Continuous Delivery Pipeline Using Jenkins | Edureka

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Paul Dally

Paul Dally

Distinguished Architect at Sun Life Financial. Focused on containers & Kubernetes. Views & opinions expressed here are my own, not necessarily those of Sun Life

More from Medium

Why Is Kustomize Adding A Bunch of Characters to my Secret/ConfigMap Names?

Manage security in Kubernetes with audit2rbac

Using Single Load Balancer across multiple namespaces in Kubernetes

What is Argo Workflow Executor & how to choose the best executor for your application?