Need help on this : CKAD course - Additional practice Kubernetes Challenges - Challenge 4

Hi,

I’m new to this platform (less than 2 weeks old) and first time in this forum so I hope this message is the right approach to have.

I’m trying to train using the challenges proposed in the course but I’m struggling on the last one. Basically the 2 problems are:

  • I do not know nor find anything about the “defaultMode” option of this requirement on the StatefulSet we need to build « Volumes - name: ‘conf’, ConfigMap Name: ‘redis-cluster-configmap’, defaultMode = '0755’ »

  • The pods of my statefulset are not created because the first one (redis-cluster-0) is blocked with the following description : « Warning FailedMount 2s (x10 over 4m12s) kubelet MountVolume.NewMounter initialization failed for volume “redis02” : path “/redis02” does not exist »
    I went on node01 using ssh command and created the directories in /root/redis01, /root/redis02, etc… I feel like it was not the right place to create those directories ? Or something else is wrong but I cannot see what.

NB : if needed, I saved the content of the objects I created (PVs, service and statefulset).

Thank you in advance for any help !

Mathieu Ridet

Hi @mathieuridet

Welcome to the KodeKloud community.

We would greatly appreciate it if you could provide the specific lab details or URL, along with the YAML manifest for the StatefulSet you are trying to configure.

Please share the YAML code in a code block by using the </> button located at the top of the editor.

Hi @Santosh_KodeKloud and thank you for your response.
Here is the lab url : Kubernetes Challenges Course | KodeKloud

Here is the content of the StatefulSet I built:

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: redis-cluster
  namespace: default
spec:
  selector:
    matchLabels:
      app: redis-cluster # has to match .spec.template.metadata.labels
  serviceName: "redis-cluster-service"
  replicas: 6
  template:
    metadata:
      labels:
        app: redis-cluster # has to match .spec.selector.matchLabels
    spec:
      containers:
      - name: redis
        image: redis:5.0.1-alpine
        command: ['/conf/update-node.sh', 'redis-server', '/conf/redis.conf']
        env:
        - name: POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        ports:
        - containerPort: 6379
          name: client
        - containerPort: 16379
          name: gossip
        volumeMounts:
        - name: conf
          mountPath: /conf
          readOnly: false
        - name: data
          mountPath: /data
          readOnly: false
      volumes:
        - name: conf
          configMap:
            name: redis-cluster-configmap
  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: "local-storage"
      resources:
        requests:
          storage: 1Gi

If it can help, here are the Persistent Volumes (I pass only the first one but the other ones have been done similarly) and the Service:

redis01.yaml :

apiVersion: v1
kind: PersistentVolume
metadata:
  name: redis01
  namespace: default
spec:
  capacity:
    storage: 1Gi
  volumeMode: Filesystem
  accessModes:
  - ReadWriteOnce
  storageClassName: local-storage
  local:
    path: /redis01
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - controlplane
          - node01

redis-cluster-service.yaml :

apiVersion: v1
kind: Service
metadata:
  name: redis-cluster-service
  namespace: default
spec:
  clusterIP: None
  selector:
    app: redis
  ports:
    - name: client
      port: 6379
      targetPort: 6379
    - name: gossip
      port: 16379
      targetPort: 16379

If you need any other information please let me know !

The defaultMode in Volumes with configMap sets the Permissions on created files. 0755 sets the Read/Write/Execute permissions to the user and only Read/Execute permission to Group and Others.
You can use kubectl explain command to get more insights on the fields.
kubectl explain sts.spec.template.spec.volumes.configMap would give you all the available fields under the volumes.configMap.

The directories you created were correct, as they need to be on worker nodes node01 in this case. You can use Linux for loops to make it a bit quicker.
for i in {1..6}; do mkdir -p "/redis0$i"; done

Also, I do not see the requirement for nodeAffinity in your PV config.

PS: Ensure all the PVs created are correctly mapping the appropriate hostPath, which is conveniently aligning with the PV name.

Thank you for your response, I’ve been able to finish the lab :slight_smile: