Skip to content

Latest commit

 

History

History
152 lines (107 loc) · 3.36 KB

File metadata and controls

152 lines (107 loc) · 3.36 KB

Practice Problems Pods

Read more about Pods
Tips and Tricks

For simulated Practice problems visit KillerCoda.
  1. create cygnus namespace.

    Solution

    k create ns cygnus 

  2. create a yaml file for namespace default.

    Solution

    k get ns default -o yaml > default-ns.yaml

  3. create a pod with name alpha and image nginx in cygnus namespace.

    Solution

    k run alpha --image=nginx --restart=Never -n cygnus

  4. create a pod with name theta and image nginx in default namespace and write env variables of that pod to file theta-env.txt.

    Solution

    k run theta --image=nginx
    k exec theta -ti -- env > theta-env.txt

    -- OR --

    k run theta --image=nginx -ti -- env # this will print env variables copy and paste it to theta-env.txt

  5. create a pod with name beta and image nginx and container name bore.

    Solution

    k run beta --image=nginx --dry-run=client -o yaml > pod.yaml
    
    # update pod.yaml
    apiVersion: v1
    kind: Pod
    metadata:
      creationTimestamp: null
      labels:
        run: beta
      name: beta
    spec:
      containers:
      - image: nginx
        name: bore # update name here
        resources: {}
      dnsPolicy: ClusterFirst
      restartPolicy: Always
    status: {}
    
    # create pod using this yaml file
    k create -f pod.yaml

  6. update image of pod created previously named beta to nginx:1.6

    Solution

    k set image pod/beta bore=nginx:1.6

  7. list all the pods in all namespaces

    Solution

    k get po -A # flag to get pods from all namespaces

  8. create a pod named neon and image nginx it runs env command and gets deleted after returning the environment variables.

    Solution

    k run neon --image=nginx -ti --rm -- env # --rm will delete the pod running env command

  9. create a nginx pod with name delta, expose container port 80 for this pod. Run a temporary busybox pod, to make wget request to delta pod at \.

    Solution

    # create delta pod
    k run delta --image=nginx --port=80
    
    # get ip of the delta pod
    k get po -o wide # this command will return ip details of the pod
    
    # create a temp busybox pod with
    k run temp --image=busybox -ti --rm -- sh
    
    # inside the shell run
    \# wget -qO- ip:80