Skip to content

Commit 248cafa

Browse files
committed
lab16: fix init containers and volume mounts, add evidence
1 parent 6ca7239 commit 248cafa

7 files changed

Lines changed: 66 additions & 21 deletions

File tree

β€Žk8s/devops-python-app/templates/statefulset.yamlβ€Ž

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,18 @@ spec:
4646
serviceAccountName: {{ include "devops-python-app.serviceAccountName" . }}
4747
{{- if .Values.initContainers.download.enabled }}
4848
initContainers:
49-
- name: init-wait-health
49+
- name: init-wait-dns
5050
image: busybox:1.36
5151
command:
5252
- sh
5353
- -c
5454
- |
55-
echo "Waiting for health endpoint to become available..."
56-
until wget -qO- http://127.0.0.1:{{ .Values.container.port }}/health 2>/dev/null; do
57-
echo "Not ready yet, sleeping 2s..."
55+
echo "Waiting for kube-dns service to be available..."
56+
until nslookup kube-dns.kube-system.svc.cluster.local 2>/dev/null | grep -q "Address"; do
57+
echo "DNS not ready yet, sleeping 2s..."
5858
sleep 2
5959
done
60-
echo "Health endpoint ready!"
60+
echo "DNS service is ready!"
6161
- name: init-download
6262
image: busybox:1.36
6363
command:
@@ -95,22 +95,22 @@ spec:
9595
name: {{ include "devops-python-app.configEnvConfigMapName" . }}
9696
{{- end }}
9797
{{- end }}
98-
{{- if or .Values.configMap.file.enabled .Values.persistence.enabled .Values.initContainers.download.enabled }}
99-
volumeMounts:
100-
{{- if .Values.configMap.file.enabled }}
101-
- name: app-config
102-
mountPath: {{ .Values.configMap.file.mountPath }}
103-
readOnly: true
104-
{{- end }}
105-
{{- if .Values.persistence.enabled }}
106-
- name: app-data
107-
mountPath: {{ .Values.persistence.mountPath }}
108-
{{- end }}
109-
{{- if .Values.initContainers.download.enabled }}
110-
- name: workdir
111-
mountPath: /init-data
112-
{{- end }}
113-
{{- end }}
98+
{{- if or .Values.configMap.file.enabled .Values.persistence.enabled .Values.initContainers.download.enabled }}
99+
volumeMounts:
100+
{{- if .Values.configMap.file.enabled }}
101+
- name: app-config
102+
mountPath: {{ .Values.configMap.file.mountPath }}
103+
readOnly: true
104+
{{- end }}
105+
{{- if .Values.persistence.enabled }}
106+
- name: app-data
107+
mountPath: {{ .Values.persistence.mountPath }}
108+
{{- end }}
109+
{{- if .Values.initContainers.download.enabled }}
110+
- name: workdir
111+
mountPath: /init-data
112+
{{- end }}
113+
{{- end }}
114114
resources:
115115
{{- toYaml .Values.resources | nindent 12 }}
116116
readinessProbe:

β€Žk8s/screenshots/lab16-app-health.txtβ€Ž

Whitespace-only changes.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
ο»ΏPods:
2+
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
3+
python-app-devops-python-app-0 1/1 Running 0 3m39s 10.244.0.33 devops-lab-control-plane <none> <none>
4+
python-app-devops-python-app-1 1/1 Running 0 3m12s 10.244.0.34 devops-lab-control-plane <none> <none>
5+
python-app-devops-python-app-2 1/1 Running 0 2m45s 10.244.0.35 devops-lab-control-plane <none> <none>
6+
7+
StatefulSet:
8+
NAME READY AGE CONTAINERS IMAGES
9+
python-app-devops-python-app 3/3 29m devops-python-app ge0s1/devops-python-app:lab16-fix2
10+
11+
Services:
12+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
13+
python-app-devops-python-app-headless ClusterIP None <none> 80/TCP 29m
14+
python-app-devops-python-app-service NodePort 10.96.143.185 <none> 80:30080/TCP 29m
15+
16+
PVCs:
17+
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS VOLUMEATTRIBUTESCLASS AGE
18+
app-data-python-app-devops-python-app-0 Bound pvc-2b4ac241-1796-4eb9-b205-fe558e52a2c4 50Mi RWO standard <unset> 29m
19+
app-data-python-app-devops-python-app-1 Bound pvc-bd1fcff3-0ff0-4905-a90b-e69cd40907ed 50Mi RWO standard <unset> 22m
20+
app-data-python-app-devops-python-app-2 Bound pvc-06f3398f-1d6a-482a-8af4-a454ae459c91 50Mi RWO standard <unset> 17m
21+
22+
Monitoring pods:
23+
NAME READY STATUS RESTARTS AGE
24+
alertmanager-monitoring-kube-prometheus-alertmanager-0 2/2 Running 0 37m
25+
monitoring-grafana-6c9f57469f-9mszr 3/3 Running 0 37m
26+
monitoring-kube-prometheus-operator-646fb7bdb-zdzbt 1/1 Running 0 37m
27+
monitoring-kube-state-metrics-5746795bd9-j4m2k 1/1 Running 0 37m
28+
monitoring-prometheus-node-exporter-f797x 1/1 Running 0 37m
29+
prometheus-monitoring-kube-prometheus-prometheus-0 2/2 Running 0 37m
30+
31+
Init container logs:
32+
Downloading welcome page...
33+
Downloaded successfully
34+
Init container completed
35+
36+
Init container + volume verification:
37+
Defaulted container "devops-python-app" out of: devops-python-app, init-wait-dns (init), init-download (init) <!doctype html><html lang="en"><head><title>Example Domain</title><meta name="viewport" content="width=device-width, initial-scale=1"><style>body{background:#eee;width:60vw;margin:15vh auto;font-family:system-ui,sans-serif}h1{font-size:1.5em}div{opacity:0.8}a:link,a:visited{color:#348}</style></head><body><div><h1>Example Domain</h1><p>This domain is for use in documentation examples without needing permission. Avoid use in operations.</p><p><a href="https://iana.org/domains/example">Learn more</a></p></div></body></html>
38+
39+
App /health endpoint:
40+
Defaulted container "devops-python-app" out of: devops-python-app, init-wait-dns (init), init-download (init) {"status":"healthy","timestamp":"2026-05-14T19:30:06.938108+00:00","uptime_seconds":201}
41+
42+
Per-pod visit counts (storage isolation):
43+
Defaulted container "devops-python-app" out of: devops-python-app, init-wait-dns (init), init-download (init) {"visits":3,"visits_file":"/data/visits"}
44+
Defaulted container "devops-python-app" out of: devops-python-app, init-wait-dns (init), init-download (init) {"visits":5,"visits_file":"/data/visits"}
45+
Defaulted container "devops-python-app" out of: devops-python-app, init-wait-dns (init), init-download (init) {"visits":2,"visits_file":"/data/visits"}
1.93 KB
Binary file not shown.
162 Bytes
Binary file not shown.
3.52 KB
Binary file not shown.
4.06 KB
Binary file not shown.

0 commit comments

Comments
Β (0)