10. Kubernetes: Multi Container Pod design patterns and Logging

Опубликовано: 21 Ноябрь 2024
на канале: iMustLearn
187
5

** Example:1 **
vi multi-container.yaml

apiVersion: v1
kind: Pod
metadata:
name: multi-container-pod
spec:
containers:
image: busybox
name: mybusybox-mc
command: ["/bin/sh", "-c", "while true; do sleep 9999; done"]
volumeMounts:
mountPath: /tmp/storage
name: myvolume-mc
image: nginx
name: mynginx-mc
volumeMounts:
name: myvolume-mc
mountPath: /usr/share/nginx/html
readOnly: true
ports:
containerPort: 80
protocol: TCP
volumes:
name: myvolume-mc
emptyDir: {}

kubectl create -f multi-container.yaml

kubectl get pods

kubectl logs multi-container-pod -c mynginx-mc

kubectl logs multi-container-pod --all-containers=true