I’ve completed the task successfully. But it is still showing as failed
Please share more information about how did you do the task.
yes no problem.
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-datacenter
spec:
capacity:
storage: 7Gi
accessModes:
- ReadWriteOnce
storageClassName: manual
local:
path: /mnt/dba
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- node01
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-datacenter
spec:
accessModes:
- ReadWriteOnce
volumeName: pv-datacenter
resources:
requests:
storage: 2Gi
storageClassName: manual
---
apiVersion: v1
kind: Pod
metadata:
name: pod-datacenter
spec:
containers:
- image: httpd:latest
name: container-datacenter
ports:
- containerPort: 80
name: web
volumeMounts:
- name: storage-datacenter
mountPath: /usr/local/apache2/htdocs
volumes:
- name: storage-datacenter
persistentVolumeClaim:
claimName: pvc-datacenter
@nilso
There are 2 things you missed.
one in persistentvolume set hostPath instead of local and remove all other lines below it.
another one in pod specs set mountPath as “/var/www/html” as its the document root for httpd, if image is nginx then mountPath should be “/usr/share/nginx/html”
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-datacenter
spec:
capacity:
storage: 7Gi
accessModes:
- ReadWriteOnce
storageClassName: manual
local: <------ hostPath [Replace local with hostPath]
path: /mnt/dba
[/quote]
In the pod .yml file mountpath should be “/var/www/html”
mountPath: /usr/local/apache2/htdocs
<---- /var/www/html [as this is DocumentRoot for httpd web server]
okay thanks than it is clear