From 74dc4b1a42ac32c3d63cd7d4a05ef659c1b71131 Mon Sep 17 00:00:00 2001 From: Louie S Date: Thu, 4 Jan 2024 16:44:29 -0500 Subject: Watched through ch. 14 --- kubernetes_cheat_sheet.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'kubernetes_cheat_sheet.md') diff --git a/kubernetes_cheat_sheet.md b/kubernetes_cheat_sheet.md index 00103bc..3af0af6 100644 --- a/kubernetes_cheat_sheet.md +++ b/kubernetes_cheat_sheet.md @@ -40,8 +40,10 @@ |`kubectl describe pod [podname]` |Show pod info | |`kubectl get pod [podname] -o yaml > file.yaml`|Extract the pod definition in YAML and save it to a file| |`kubectl exec -it [podname] -- sh` |Interactive mode | +|`kubectl exec -it [podname] -c [containername] -- sh`|Exec into a pod| |`kubectl delete -f [pod-definition.yml]`|Delete a pod | |`kubectl delete pod [podname]` |Same using the pod's name | +|`kubectl logs [podname] -c [containername]`|Get the logs for a container| ### Misc. @@ -223,3 +225,32 @@ spec: image: busybox:1.28 command: ['sh', '-c', "until lookup mydb.namespace.svc.cluster.local; do echo waiting for mydb; sleep 2; done"] ``` + +--- + +### Multi-Containers Pods + +Example of defining multiple containers in a single pod definition + +```yaml +apiVersion: v1 +kind: Pod +metadata: + name: two-containers +spec: + restartPolicy: Always + containers: + # Container #1 + - name: mynginx + image: nginx + ports: + - containerPort: 80 + # Container #2 + - name: mybox + image: busybox + ports: + - containerPort: 81 + command: + - sleep + - "3600" +``` -- cgit