Skip to content

Instantly share code, notes, and snippets.

@coolpalani
Forked from jkpl/deploy.md
Created August 27, 2019 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coolpalani/79dc2609637045eeae2eacf633200ff2 to your computer and use it in GitHub Desktop.
Save coolpalani/79dc2609637045eeae2eacf633200ff2 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# This script deploys the given manifest,
# tracks the deployment, and rolls back on failure.
#
# First execute this with "myapp.yaml" and then try it with "myapp.failing.yaml"
#
MANIFEST_PATH=$1
DEPLOYMENT_NAME=myapp
if [ -n "$2" ]; then
DEPLOYMENT_NAME=$2
fi
kubectl apply -f "$MANIFEST_PATH"
if ! kubectl rollout status deployment "$DEPLOYMENT_NAME"; then
echo "Rolling back deployment!" >&2
kubectl rollout undo deployment "$DEPLOYMENT_NAME"
kubectl rollout status deployment myapp
exit 1
fi
# Example hello world app deployment that fails
# because of an incorrectly configured readiness probe.
#
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: myapp
name: myapp
spec:
replicas: 3
progressDeadlineSeconds: 30
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- image: polarsquad/hello-world-app:master
name: hello-world
ports:
- containerPort: 3000
readinessProbe:
httpGet:
path: /this-does-not-exist
port: 3000
# Example hello world app deployment
# including a readiness probe and a progress deadline.
#
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: myapp
name: myapp
spec:
replicas: 3
progressDeadlineSeconds: 30
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- image: polarsquad/hello-world-app:master
name: hello-world
ports:
- containerPort: 3000
readinessProbe:
httpGet:
path: /
port: 3000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment