☸️Pod

Describe about What is Pod ?

It is the smallest instance in Kubernetes that running application. It has 1 or multiple containers inside in case that be helper container (helper container will be destroyed when the pod is destroyed).

CheatSheet Command

  1. Get Pods : kubectl get pods

  2. Create Pod: kubectl run <pod_name> --image=<image_name>

  3. Describe information of Pod: kubectl describe po <pod_name or container_name>

  4. Delete Pod: kubectl delete po <pod_name or container_name>

  5. Create template for creating Pod kubectl run <pod_name> --image=<image_name> --dry-run=client -o yaml > <file_name>.yaml (this command only generated template file because of --dry-run=client option)

  6. Check the apiVersion of the template: kubectl explain po

  7. Execute command from file kubectl apply -f <file_name>.yaml

  8. Create Pod using file definition:

# Pod Template
apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - name: nginx
    image: nginx:1.14.2
    # For command it is entryPoint in docker if you add this property,it will override
    # entrypoint within image  
    command: ["sleep"]
    # For args it is CMD in docker if you add this property,it will override
    # CMD within image
    args: ["10"]
    ports:
    - containerPort: 80
    
  1. Force edit pod: kubectl replace --force -f <tmp_file_name>.yaml

  2. Create pod with args: kubectl run <pod_name> --image=<image_name> -- --color=green(example)

Last updated