Skip to content

Latest commit

 

History

History
140 lines (108 loc) · 4.27 KB

File metadata and controls

140 lines (108 loc) · 4.27 KB

Busted Pod Challenge!

It's a "broken pod"... get it?

Below is a familiar looking Pod manifest... you used this when creating a Pod with an nginx image and three mounted configmaps yesterday. However, it is now riddled with errors!... the type of errors that are very common and you're likely to encounter :)

Copy the ENTIRE block of commands below and paste them in one big chunk to your command line. Then press enter.

kubectl delete cm --all
kubectl config use-context kubernetes-the-alta3-way
wget https://static.alta3.com/projects/k8s/nginx.conf.final -O nginx.conf
wget https://static.alta3.com/projects/k8s/index.html2 -O index.html
echo "It was a bright cold day in April, and the clocks were striking thirteen." > nginx.txt
kubectl delete cm --all
kubectl create configmap nginx-txt --from-file=nginx.txt
kubectl create configmap nginx-conf --from-file=nginx.conf
kubectl create configmap index-file --from-file=index.html

Create your pod manifest from the file below. Do your best to find and fix all the errors before creating this Pod! You cannot claim success until the STATUS of the container says Running!

student@bchd:~$ vim troubleshooting-warmup.yml

---
apiVersion:v1
kind: pod
metadata:
  name: nginx-configured
spec:
  containers:
  - name: nginx
    image: nnginx:1.18.0
    ports:
    - containerPort: 80
    volumeMounts: 
    - name: garfield
      mountPath: /etc/nginx
    - name: odie
      mountPath: /var/www/index.html
      subPath: index.html
    - name: john
      mountPath: /var/www/static/nginx.txt
      subPath: nginx.txt
  volumes:
  - name: garfield
    configMap:
      name: nermal-conf 
  - name: odie
    configMap:
      name: index-file 
  - name: jon
    configMap:
      name: nginx-txt

Hints for the errors you're most likely to see!

error: error parsing trial.yml: error converting YAML to JSON: yaml: line 2: mapping values are not allowed in this context

Put a space before v1.

Error from server (BadRequest): error when creating "trial.yml": pod in version "v1" cannot be handled as a Pod: no kind "pod" is registered for version "v1" in scheme "k8s.io/kubernetes/pkg/api/legacyscheme/scheme.go:30"

capitalize "P" in Pod

MountVolume.SetUp failed for volume "garfield" : configmap "nermal-conf" not found

line 23 should be nginx-conf not nermal-conf

Failed to pull image "nnginx:1.18.0": rpc error: code = Unknown desc = failed to pull and unpack image "docker.io/library/nnginx:1.18.0"

Typo in the image name! Should be nginx:1.18.0

Error: failed to create containerd task: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/var/lib/kubelet/pods/ac124c92-65d1-4a5e-a193-7d36b8840ff5/volumes/kubernetes.io~configmap/garfield" to rootfs at "/etc/nginx/nginx.conf"

The garfield volume's mountPath is /etc/nginx/, which overwrites EVERYTHING in that directory! Add a subpath.

SOLUTION
---
apiVersion: v1                               # put a whitespace after the ":"
kind: Pod                                    # capitalize the P in Pod!
metadata:
  name: nginx-configured
spec:
  containers:
  - name: nginx
    image: nginx:1.18.0                      # typo in image name caused ErrImgPull
    ports:
    - containerPort: 80
    volumeMounts: 
    - name: garfield
      mountPath: /etc/nginx/nginx.conf
      subPath: nginx.conf                    # needs subpath!
    - name: odie
      mountPath: /var/www/index.html
      subPath: index.html
    - name: jon                              # volume is jon, not john!
      mountPath: /var/www/static/nginx.txt
      subPath: nginx.txt
  volumes:
  - name: garfield
    configMap:
      name: nginx-conf                       # wrong configmap name!
  - name: odie
    configMap:
      name: index-file 
  - name: jon
    configMap:
      name: nginx-txt