Hello,
I’m trying to fire up my first application and I’m stuck! I’m running minikube and the (minikube) documentation states that /data on the host i persistent.
So I put a index.html (Hello World) into /data/www.
For my first kubernetes thingy I’m trying to host this using nginx. As far as I can tell i need a persistent volume, a persistent volume claim, deployment and last a service.
Persistent volume yaml:
apiVersion: v1
kind: PersistentVolume
metadata:
name: small-pv
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: local-storage
local:
path: /data
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- my-node
I want to reuse my persistent volume (/data) for other apps so I went with a general name for it. I’m planning on installing nodered (automation app) & others, and nodered for instance could live under /data/nodered. Each app will have its own claim.
Nginx persistent volume claim:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nginx-claim
spec:
storageClassName: local-storage
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
And finally my deployment. I have not gotten to the service yet as something is wrong.
Deployment:
asd
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: nginxapp
name: nginxapp
spec:
replicas: 1
volumes:
- name: nginx-claim
persistentVolumeClaim:
claimName: nginx-claim
selector:
matchLabels:
app: nginxapp
template:
metadata:
labels:
app: nginxapp
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
volumeMounts:
- name: nginx-claim
mountPath: "/data/www"
When publishing the deployment yaml I get this error:
Deployment.apps "nginxapp" is invalid: spec.template.spec.containers[0].volumeMounts[0].name: Not found: "nginx-claim"
I’ve checked the dashboard and both the pv and pvc are green and good.
So now I need some help, I’m pretty new to kubernetes and ba-da-ba-ba-baaa… I’m not loving it