Persistent volumes in Kubernetes - Website not up

Instructions were:
The Nautilus DevOps team is working on a Kubernetes template to deploy a web application on the cluster. There are some requirements to create/use persistent volumes to store the application code, and the template needs to be designed accordingly. Please find more details below:

Create a PersistentVolume named as pv-xfusion. Configure the spec as storage class should be manual, set capacity to 4Gi, set access mode to ReadWriteOnce, volume type should be hostPath and set path to /mnt/devops (this directory is already created, you might not be able to access it directly, so you need not to worry about it).

Create a PersistentVolumeClaim named as pvc-xfusion. Configure the spec as storage class should be manual, request 2Gi of the storage, set access mode to ReadWriteOnce.

Create a pod named as pod-xfusion, mount the persistent volume you created with claim name pvc-xfusion at document root of the web server, the container within the pod should be named as container-xfusion using image httpd with latest tag only (remember to mention the tag i.e httpd:latest).

Create a node port type service named web-xfusion using node port 30008 to expose the web server running within the pod.

Note: The kubectl utility on jump_host has been configured to work with the kubernetes cluster.


I created the app.yml


apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-xfusion
spec:
capacity:
storage: 4Gi
accessModes:
- ReadWriteOnce
storageClassName: manual
hostPath:
path: /mnt/devops
type: “”

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-xfusion
spec:
accessModes:
- ReadWriteOnce
storageClassName: manual
resources:
requests:
storage: 2Gi

apiVersion: v1
kind: Pod
metadata:
name: pod-xfusion
spec:
containers:
- name: container-xfusion
image: httpd:latest
volumeMounts:
- name: data
mountPath: /usr/local/apache2/htdocs/
volumes:
- name: data
persistentVolumeClaim:
claimName: pvc-xfusion

apiVersion: v1
kind: Service
metadata:
name: web-xfusion
spec:
type: NodePort
selector:
app: xfusion
ports:
- name: http
port: 80
targetPort: 80
nodePort: 30008

I verified all resources are running, pod is running, PV/PVC are bound. Service is using correct port. Plus the error only says the issue is about web nto accesible. i checked the logs, and it seems like something is wrong with server name which is under control of Kodekloud, and out of my control.

Then I check logs:

This seems to be out of scope of the requirements/instructions.
Please check.

@mmumshad @mumshadgmail @Inderpreet @Alistair_KodeKloud

Hi @Joseeden
Base on the information provided, you use a selector app: xfusion on the service, but you did not create the corresponding label on pod

Regard

1 Like

Hi @Joseeden

When posting code and YAML, please

post them as code blocks like this

because if we need to run them to verify something, we do not want to have to re-code them from screen shots.

Thanks

1 Like

Okay, I didn’t know there are code blocks here, sorry.
Here’s the YAML file.

---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-xfusion
spec:
  capacity:
    storage: 4Gi
  accessModes:
    - ReadWriteOnce
  storageClassName: manual
  hostPath:
    path: /mnt/devops
    type: ""
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-xfusion
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: manual
  resources:
    requests:
      storage: 2Gi
---
apiVersion: v1
kind: Pod
metadata:
  name: pod-xfusion
spec:
  containers:
    - name: container-xfusion
      image: httpd:latest
      volumeMounts:
        - name: data
          mountPath: /usr/local/apache2/htdocs/
  volumes:
    - name: data
      persistentVolumeClaim:
        claimName: pvc-xfusion
---
apiVersion: v1
kind: Service
metadata:
  name: web-xfusion
spec:
  type: NodePort
  selector:
    app: xfusion
  ports:
    - name: http
      port: 80
      targetPort: 80
      nodePort: 30008

Thank you.

Did you try the suggestion from @mmkmou_KodeKloud yet?

Is it possible to redo the task again? It’s just saying “Under review” in the task status so I cannot retry.

@Tej-Singh-Rana Can you reset please ^^

Base on the information provided, you use a selector app: xfusion on the service, but you did not create the corresponding label on pod

Service

I shared this on the review. Please accept it and go for the task.

Regards,

Re-did the tasks and its okay now. Thanks @Alistair_KodeKloud @Tej-Singh-Rana @mmkmou_KodeKloud for your responses. Appreciate it guys!

1 Like