From 83946594481ae43c081cf3bd89796bca24f25494 Mon Sep 17 00:00:00 2001 From: marceldempers Date: Wed, 8 Jan 2025 22:16:57 +1100 Subject: [PATCH] add sidecar pod example --- kubernetes/pods/pod-sidecar.yaml | 64 ++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 kubernetes/pods/pod-sidecar.yaml diff --git a/kubernetes/pods/pod-sidecar.yaml b/kubernetes/pods/pod-sidecar.yaml new file mode 100644 index 0000000..dcbfd6f --- /dev/null +++ b/kubernetes/pods/pod-sidecar.yaml @@ -0,0 +1,64 @@ +# kind create cluster --name pods --image kindest/node:v1.31.1 +apiVersion: v1 +kind: Pod +metadata: + name: example-pod + namespace: default + labels: + app: example-app +spec: + shareProcessNamespace: true + nodeSelector: + kubernetes.io/os: linux + containers: + - name: config-watcher + image: alpine:latest + command: ["/bin/sh", "-c"] + args: + - | + apk add --no-cache inotify-tools + while true; do + inotifywait -e modify /etc/nginx/nginx.conf + pkill -HUP nginx + done + volumeMounts: + - name: config-volume + mountPath: /etc/nginx/ + - name: nginx + image: nginx:latest + imagePullPolicy: Always + ports: + - containerPort: 80 + volumeMounts: + - name: config-volume + mountPath: /etc/nginx/ + volumes: + - name: config-volume + configMap: + name: nginx-config +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: nginx-config +data: + nginx.conf: | + events {} + http { + server { + listen 80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + location = /health { + access_log off; + default_type text/plain; + add_header Content-Type text/plain; + return 200 "ok"; + } + } + } \ No newline at end of file