Last active
August 15, 2022 05:27
-
-
Save jpallari/1d6b5dfbc6660021557ad1e56029e48a to your computer and use it in GitHub Desktop.
Check your Kubernetes deployments! https://medium.com/polarsquad/check-your-kubernetes-deployments-46dbfbc47a7c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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