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
PersistentVolumenamed aspv-devops. Configure thespecas storage class should bemanual, set capacity to4Gi, set access mode toReadWriteOnce, volume type should behostPathand set path to/mnt/itadmin(this directory is already created, you might not be able to access it directly, so you need not to worry about it). - Create a
PersistentVolumeClaimnamed aspvc-devops. Configure thespecas storage class should bemanual, request1Giof the storage, set access mode toReadWriteOnce. - Create a
podnamed aspod-devops, mount the persistent volume you created with claim namepvc-devopsat document root of the web server, the container within the pod should be named ascontainer-devopsusing imagenginxwithlatesttag only (remember to mention the tag i.enginx:latest). - Create a node port type service named
web-devopsusing node port30008to expose the web server running within the pod.
Note: The kubectl utility on jump_hos
solution
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-devops
spec:
capacity:
storage: 4Gi
accessModes:
- ReadWriteOnce
storageClassName: manual
hostPath:
path: /mnt/itadmin
type: “”
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-devops
spec:
accessModes:
- ReadWriteOnce
storageClassName: manual
resources:
requests:
storage: 1Gi
apiVersion: v1
kind: Pod
metadata:
name: pod-devops
labels:
app: devops
spec:
containers:
- name: container-devops
image: nginx:latest
volumeMounts:
- name: data
mountPath: /usr/share/nginx/html
volumes:
- name: data
persistentVolumeClaim:
claimName: pvc-devops
apiVersion: v1
kind: Service
metadata:
name: web-devops
spec:
type: NodePort
selector:
app: devops
ports:
- name: http
port: 80
targetPort: 80
error i am getting
Please provide where i am getting wrong.
