Skip to content

Latest commit

 

History

History
53 lines (31 loc) · 2.09 KB

K8s-CreatingPod-Imperative.md

File metadata and controls

53 lines (31 loc) · 2.09 KB

LAB: K8s Creating Pod - Imperative Way

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.

Steps

  • Run minikube (in this scenario, K8s runs on WSL2- Ubuntu 20.04)

    image

  • Run pod in imperative way

    • "kubectl run podName --image=imageName"
    • "kubectl get pods -o wide" : get info about pods

    image

  • Describe pod to get mor information about pods (when encountered troubleshooting):

    image

  • To reach logs in the pod (when encountered troubleshooting):

    image

  • To reach logs in the pod 2ith "-f" (LIVE Logs, attach to the pod's log):

    image

  • Run command on pod ("kubectl exec podName -- command"):

    image

  • 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"

    image

  • Delete pod:

    image

  • 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.