Skip to content

Instantly share code, notes, and snippets.

@brianpursley
Created June 24, 2022 20:42
Show Gist options
  • Save brianpursley/bc591d6b10707c61b5ecf86fa89bbe1e to your computer and use it in GitHub Desktop.
Save brianpursley/bc591d6b10707c61b5ecf86fa89bbe1e to your computer and use it in GitHub Desktop.
Nginx pod with readiness probe using path that is 302 redirected to another path
kubectl create ns nginx-test
kubectl apply --namespace nginx-test -f - << EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-config
data:
default.conf: |
server {
absolute_redirect off;
location ~ ^/health$ {
add_header Content-Type text/plain;
return 200 'healthy';
}
rewrite ^/old$ /health redirect;
}
---
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx
volumeMounts:
- name: config
mountPath: /etc/nginx/conf.d
readinessProbe:
httpGet:
path: /old
port: 80
volumes:
- name: config
configMap:
name: nginx-config
items:
- key: default.conf
path: default.conf
EOF
kubectl wait --for=condition=Ready pod/nginx
kubectl describe pod nginx | grep Readiness
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment