Skip to content

Latest commit

 

History

History
53 lines (35 loc) · 1.98 KB

K8-CreatingPod-Declerative.md

File metadata and controls

53 lines (35 loc) · 1.98 KB

LAB: K8s Creating Pod - Declarative Way (With Yaml File)

This scenario shows:

  • how to create basic K8s pod using yaml file,
  • how to get more information about pod (to solve troubleshooting),

Steps

apiVersion: v1      
kind: Pod                         # type of K8s object: Pod
metadata:
  name: firstpod                  # name of pod
  labels:
    app: frontend                 # label pod with "app:frontend"   
spec:
  containers: 
  - name: nginx                   
    image: nginx:latest           # image name:image version, nginx downloads from DockerHub
    ports:
    - containerPort: 80           # open ports in the container
    env:                          # environment variables
      - name: USER
        value: "username"

image

  • Apply/run the file to create pod in declerative way ("kubectl apply -f pod1.yaml"):

    image

  • Describe firstpod ("kubectl describe pods firstpod"):

    image

  • Delete pod and get all pods in the default namepace ("kubectl delete -f pod1.yaml"):

    image

  • If you want to delete minikube ("minikube delete"):

    image