To Create the pod ( with name nginx-pod by using nginx docker image) with command
kubectl run nginx-pod --image nginx
To list the pod with its IP address and NodeName
kubectl get pods -o wide
To interact with pod's terminal(go inside the pod)
kubectl exec -it nginx-pod-- bash
To Exit from the pod run "exit" command
To access the application running in the pod ( consider 192.168.135.2 is IP of the pod)
curl 192.168.135.2
To find all the properties of the pod in yaml format
kubectl get pods nginx-pod -o yaml
To find all the properties of the pod in json format
kubectl get pods nginx-pod-o json
To Delete the Pod
kubectl delete pod nginx-pod
Manifest file in Kubernetes
IDE (Integrated Development Environment)
Visual Studio Code (VS Code Download)
Notepad/Notepad++
Sublime text editor
Atom
My First Pod Manifest file (nginx-pod.yaml)
To create Pod by using above file you need to run below command
kubectl create -f nginx-pod.yaml
To Verify Pod is created with its IP address and other properties
kubectl get pods -o wide
To Verify the events and other run-time properties of the pod.
kubectl describe pod myapp
If you make any change in the manifest file then use the apply(change/create) command
kubectl apply -f nginx-pod.yaml
To find the logs generated by pod
kubectl logs myapp
To interact with pod
kubectl exec -it myapp -- bash
To delete the pod using manifest file
kubectl delete -f nginx-pod.yaml
To verify pod is deleted or not
kubectl get pods
MultiContainer Pod
Create 2 containers (nginx, tomcat) within a single pod multicont.yaml
To create Pod by using above file you need to run below command
kubectl create -f multicont.yaml
To Verify Pod is created with its IP address and other properties
kubectl get pods -o wide
To Verify the events and other run-time properties of the pod.
kubectl describe pod myapp
If you make any change in the manifest file then use the apply(change/create) command
kubectl apply -f multicont.yaml
To find the logs generated by pod nginx-container
kubectl logs myapp -c nginx-container
To find the logs generated by pod nginx-container
kubectl logs myapp -c tomcat-container
kubectl exec -it myapp -c nginx-container -- bash
kubectl exec -it myapp -c tomcat-container -- bash
To access nginx app using multicontainer pod (IP 192.168.135.3)
curl 192.168.135.3:80
To access tomcat app using multicontainer pod (IP 192.168.135.3)
curl 192.168.135.3:8080
To delete the pod using manifest file
kubectl delete -f multicont.yaml
To verify pod is deleted or not
kubectl get pods
1 comments:
Hi Raman, try to change the pod image at runtime from nginx to ubuntu the pod1 get crashed and status showing is "CrashLoopBackoff"
events which run are have message as "Back-off restarting failed container "
Post a Comment