Docker build webapp-color:stable - CKS Challenge 2

Hello,

I am probably missing something, but I have no clue!

The image is available but the POD deployment fails to pull it.

Very glad if someone can help me :slight_smile:

I did exactly what is being described here https://github.com/kodekloudhub/certified-kubernetes-security-specialist-cks-course/blob/main/docs/09-cks-challenges/02-challenge-2.md

I will retry it again :man_shrugging:

What did you set imagePullPolicy to in the pod spec? If it is Always then it will attempt to get it from dockerhub, where it does not exist.

Hello @Alistair_KodeKloud, thanks for your help.

I tried the three policy options “Never, IfNotPresent and Always” but none of them works.

Thanks!

root@controlplane ~ âžś  docker image ls
REPOSITORY                           TAG                 IMAGE ID            CREATED             SIZE
kodekloud/webapp-color               stable              75a427ac616b        33 seconds ago      51.8MB
busybox                              latest              66ba00ad3de8        12 months ago       4.87MB
nginx                                latest              1403e55ab369        12 months ago       142MB
nginx                                alpine              1e415454686a        12 months ago       40.7MB
k8s.gcr.io/kube-apiserver            v1.23.0             e6bf5ddd4098        2 years ago         135MB
k8s.gcr.io/kube-scheduler            v1.23.0             56c5af1d00b5        2 years ago         53.5MB
k8s.gcr.io/kube-controller-manager   v1.23.0             37c6aeb3663b        2 years ago         125MB
k8s.gcr.io/kube-proxy                v1.23.0             e03484a90585        2 years ago         112MB
python                               3.6-alpine          3a9e80fa4606        2 years ago         40.7MB
k8s.gcr.io/etcd                      3.5.1-0             25f8c7f3da61        2 years ago         293MB
k8s.gcr.io/coredns/coredns           v1.8.6              a4ca41631cc7        2 years ago         46.8MB
k8s.gcr.io/pause                     3.6                 6270bb605e12        2 years ago         683kB
weaveworks/weave-npc                 2.8.1               7f92d556d4ff        2 years ago         39.3MB
weaveworks/weave-kube                2.8.1               df29c0a4002c        2 years ago         89MB
quay.io/coreos/flannel               v0.13.1-rc1         f03a23d55e57        3 years ago         64.6MB
quay.io/coreos/flannel               v0.12.0-amd64       4e9f801d2217        3 years ago         52.8MB
kodekloud/fluent-ui-running          latest              bd30270a8b9a        5 years ago         969MB
kodekloud/webapp-color               latest              32a1ce4c22f2        5 years ago         84.8MB

root@controlplane ~ âžś  cat dev-webapp.yaml 
apiVersion: v1
kind: Pod
metadata:
  labels:
    name: dev-webapp
  name: dev-webapp
  namespace: dev
spec:
  nodeName: controlplane
  containers:
  - env:
    - name: APP_COLOR
      value: darkblue
    image: kodekloud/webapp-color:stable
    imagePullPolicy: Never
    name: webapp-color
    resources: {}
    securityContext:
      capabilities:
        add:
        - NET_ADMIN
      runAsUser: 0
    startupProbe:
      exec:
        command:
        - rm
        - /bin/sh
        - /bin/ash
      initialDelaySeconds: 5
      periodSeconds: 5

root@controlplane ~ âžś  k get po -n dev
NAME         READY   STATUS    RESTARTS   AGE
dev-webapp   1/1     Running   0          2m17s

root@controlplane ~ âžś  date
Sat Jan  6 14:14:15 UTC 2024

If you have not specifically told the pod to schedule on controlplane, and it gets scheduled to node01 then you will get this error, because the image you have built exists only on controlplane. You could also export the image, SCP it to node01 and import it there, then the pod would schedule on either node.

This is CKS - you’re expected to know this sort of thing about clusters without having it explicitly taught.

It’s generally recommended to attempt advanced level certifications when you work with the subject matter on a daily basis.

@Alistair_KodeKloud, thanks once again for your help.

You are definitely right, after comparing your config with mine I noticed I was missing the node selector to the controlplane.

Indeed, it’s CKS and I should know it, but again thanks for your help!

You’re welcome! Happy learning,