Skip to content

Commit a0ec4a4

Browse files
committed
Kubernetes: Enhance alpine pod configurations with improved resource management, security contexts, and startup messages
Signed-off-by: NotHarshhaa <[email protected]>
1 parent 83ef54b commit a0ec4a4

4 files changed

+109
-64
lines changed

Diff for: alpine/alpine-pod-2-containers.yaml

+38-18
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,46 @@
11
apiVersion: v1
22
kind: Pod
33
metadata:
4-
#creationTimestamp: null
5-
labels:
6-
run: alpine-2-containers
74
name: alpine-2-containers
5+
labels:
6+
app: alpine-2-containers
87
spec:
98
containers:
10-
- args:
11-
- /bin/sh
12-
- -c
13-
- echo hello;sleep 10000
14-
image: alpine
15-
name: alpine1
16-
#resources: {}
17-
- args:
18-
- /bin/sh
19-
- -c
20-
- echo hello;sleep 10000
21-
image: alpine
22-
name: alpine2
23-
#resources: {}
9+
- name: alpine1
10+
image: alpine:latest
11+
command: ["/bin/sh", "-c"]
12+
args:
13+
- |
14+
echo "[alpine1] Starting up...";
15+
sleep 10000;
16+
resources:
17+
requests:
18+
cpu: "100m"
19+
memory: "64Mi"
20+
limits:
21+
cpu: "250m"
22+
memory: "128Mi"
23+
securityContext:
24+
runAsNonRoot: true
25+
allowPrivilegeEscalation: false
26+
27+
- name: alpine2
28+
image: alpine:latest
29+
command: ["/bin/sh", "-c"]
30+
args:
31+
- |
32+
echo "[alpine2] Starting up...";
33+
sleep 10000;
34+
resources:
35+
requests:
36+
cpu: "100m"
37+
memory: "64Mi"
38+
limits:
39+
cpu: "250m"
40+
memory: "128Mi"
41+
securityContext:
42+
runAsNonRoot: true
43+
allowPrivilegeEscalation: false
44+
2445
dnsPolicy: ClusterFirst
2546
restartPolicy: Never
26-
#status: {}

Diff for: alpine/alpine-pod-service-account.yaml

+19-11
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
apiVersion: v1
22
kind: Pod
33
metadata:
4-
#creationTimestamp: null
5-
labels:
6-
run: alpine-sa
74
name: alpine-sa
5+
labels:
6+
app: alpine-sa
87
spec:
98
serviceAccountName: mysa
109
containers:
11-
- args:
12-
- /bin/sh
13-
- -c
14-
- echo hello;sleep 3600
15-
image: alpine
16-
name: alpine-2-containers
17-
# resources: {}
10+
- name: alpine
11+
image: alpine:latest
12+
command: ["/bin/sh", "-c"]
13+
args:
14+
- |
15+
echo "[INFO] Starting container with ServiceAccount: mysa";
16+
sleep 3600;
17+
resources:
18+
limits:
19+
memory: "64Mi"
20+
cpu: "250m"
21+
requests:
22+
memory: "32Mi"
23+
cpu: "100m"
24+
securityContext:
25+
runAsNonRoot: true
26+
allowPrivilegeEscalation: false
1827
dnsPolicy: ClusterFirst
1928
restartPolicy: Never
20-
#status: {}

Diff for: alpine/alpine-pod-share-volumes.yaml

+33-24
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,41 @@
11
apiVersion: v1
22
kind: Pod
33
metadata:
4-
labels:
5-
run: alpine-2-containers
64
name: alpine-2-containers-share-volume
5+
labels:
6+
app: alpine-volume-demo
77
spec:
88
containers:
9-
- args:
10-
- /bin/sh
11-
- -c
12-
- echo hello;sleep 10000
13-
image: alpine
14-
name: alpine1
15-
volumeMounts:
16-
- name: share
17-
mountPath: "/tmp/share1"
18-
- args:
19-
- /bin/sh
20-
- -c
21-
- echo hello;sleep 10000
22-
image: alpine
23-
name: alpine2
24-
volumeMounts:
25-
- name: share
26-
mountPath: "/tmp/share2"
27-
dnsPolicy: ClusterFirst
28-
restartPolicy: Never
9+
- name: writer
10+
image: alpine
11+
command: ["/bin/sh", "-c"]
12+
args:
13+
- |
14+
echo "[Writer] Writing to shared volume...";
15+
echo "Shared data from writer" > /shared/message.txt;
16+
echo "[Writer] Sleeping...";
17+
sleep 10000;
18+
volumeMounts:
19+
- name: shared-volume
20+
mountPath: /shared
21+
22+
- name: reader
23+
image: alpine
24+
command: ["/bin/sh", "-c"]
25+
args:
26+
- |
27+
echo "[Reader] Waiting for message...";
28+
sleep 5;
29+
cat /shared/message.txt || echo "No message found!";
30+
echo "[Reader] Sleeping...";
31+
sleep 10000;
32+
volumeMounts:
33+
- name: shared-volume
34+
mountPath: /shared
35+
2936
volumes:
30-
- name: share
37+
- name: shared-volume
3138
emptyDir: {}
32-
#status: {}
39+
40+
dnsPolicy: ClusterFirst
41+
restartPolicy: Never

Diff for: alpine/alpine-pod.yaml

+19-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
apiVersion: v1
22
kind: Pod
33
metadata:
4-
#creationTimestamp: null
5-
labels:
6-
run: alpine-2-containers
74
name: alpine-2-containers
5+
labels:
6+
app: alpine-2-containers
87
spec:
98
containers:
10-
- args:
11-
- /bin/sh
12-
- -c
13-
- echo hello;sleep 3600
14-
image: alpine
15-
name: alpine-2-containers
16-
#resources: {}
9+
- name: alpine
10+
image: alpine:latest
11+
command: ["/bin/sh", "-c"]
12+
args:
13+
- |
14+
echo "[alpine] Hello from container";
15+
sleep 3600;
16+
resources:
17+
requests:
18+
memory: "32Mi"
19+
cpu: "100m"
20+
limits:
21+
memory: "64Mi"
22+
cpu: "250m"
23+
securityContext:
24+
runAsNonRoot: true
25+
allowPrivilegeEscalation: false
1726
dnsPolicy: ClusterFirst
1827
restartPolicy: Never
19-
#status: {}

0 commit comments

Comments
 (0)