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:
PersistentVolume named as pv-xfusion. Configure the spec as storage class should be manual, set capacity to 3Gi, set access mode to ReadWriteOnce, volume type should be hostPath and set path to /mnt/security (this directory is already created, you might not be able to access it directly, so you need not to worry about it).PersistentVolumeClaim named as pvc-xfusion. Configure the spec as storage class should be manual, request 3Gi of the storage, set access mode to ReadWriteOnce.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).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.
Create a persistent volume k3s-pv.yaml with this content:
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-xfusion
spec:
capacity:
storage: 3Gi
accessModes:
- ReadWriteOnce
storageClassName: manual
hostPath:
path: /mnt/security
Create the volume:
kubectl apply -f k3s-pv.yaml
Create the persistent volume claim k3s-pvc.yaml with this following content:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-xfusion
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3Gi
storageClassName: manual
To create the pvc:
kubectl k3s-pvc.yaml
Create the pod k3s-pod.yaml:
apiVersion: v1
kind: Pod
metadata:
name: pod-xfusion
labels:
app: xfusion
spec:
containers:
- name: container-xfusion
image: httpd:latest
volumeMounts:
- name: xfusion-volume
mountPath: /mnt/security
resources:
limits:
memory: "128Mi"
cpu: "500m"
requests:
memory: "64Mi"
cpu: "250m"
volumes:
- name: xfusion-volume
persistentVolumeClaim:
claimName: pvc-xfusion
run the pod
kubectl apply -f k3s-pod.yaml
And finally, create the service k3s-svc.yaml:
apiVersion: v1
kind: Service
metadata:
name: web-xfusion
labels:
app: xfusion
spec:
type: NodePort
ports:
- port: 80
targetPort: 80
nodePort: 30008
selector:
app: xfusion
kubectl apply -f k3s-svc.yaml
We can put all in one file k3s-pod.yaml