This scenario shows:
- how to create basic K8s pod using imperative commands,
- how to get more information about pod (to solve troubleshooting),
- how to run commands in pod,
- how to delete pod.
-
Run minikube (in this scenario, K8s runs on WSL2- Ubuntu 20.04)
-
Run pod in imperative way
- "kubectl run podName --image=imageName"
- "kubectl get pods -o wide" : get info about pods
-
Describe pod to get mor information about pods (when encountered troubleshooting):
-
To reach logs in the pod (when encountered troubleshooting):
-
To reach logs in the pod 2ith "-f" (LIVE Logs, attach to the pod's log):
-
Run command on pod ("kubectl exec podName -- command"):
-
Entering into the pod and running bash or sh on pod:
- "kubectl exec -it podName -- bash"
- "kubectl exec -it podName -- /bins/sh"
- exit from pods 2 ways:
- "exit" command
- "CTRL+P+Q"
-
Delete pod:
-
Imperative way could be difficult to store and manage process. Every time we have to enter commands. To prevent this, we can use YAML file to define pods and pods' feature. This way is called Declerative Way.