seheon
seheon

Reputation: 127

The deployment cannot find the PVC

My deployment for InfluxDB can’t find the PVC. The following is how I set up my deployment.

First, I set up a namespace services with commands:

kubectl create namespace services
kubectl config set-context --current --namespace=services

Second, I set up a deplyment, service, volume, and secret with each .yaml files.

kubectl apply -f srcs/influxdb/

influxdb-deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: influxdb
  labels:
    app: influxdb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: influxdb
  template:
    metadata:
      labels:
        app: influxdb
    spec:
      containers:
      - name: influxdb
        image: service_influxdb
        imagePullPolicy: Never
        ports:
        - containerPort: 8086
        envFrom:
        - secretRef:
            name: influxdb-secret
        volumeMounts:
        - mountPath: /var/lib/influxdb
          name: var-lib-influxdb
      volumes:
      - name: var-lib-influxdb
        persistentVolumeClaim:
          claimName: influxdb-pvc
      restartPolicy: Always

influxdb-volume.yaml:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: influxdb-pvc
  labels:
    app: influxdb
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

Then, finally, I check the deployment’s status with minikube dashboard and run into the message persistentvolumeclaim "influxdb-pvc" not found.

Is there anything I need to check? I google it and check the namespace, the volume name and I think everything is perfect!! Please help me.. 😢

Upvotes: 0

Views: 1371

Answers (2)

seheon
seheon

Reputation: 127

This was a problem related to Docker image. There was a problem with the image, so the container shut down immediately. Unexpected results seem to have occurred because it ended at the same time as the start.

(Before) Dockerfile:

...
ENTRYPOINT influxdb & /bin/sh

(After) Dockerfile:

...
ENTRYPOINT influxdb

Upvotes: 0

buchi manikanta reddy
buchi manikanta reddy

Reputation: 51

if you are using the single node clusters , in the pv (influxdb-volume.yaml) you missed two things

  1. storage class (which type of storage it should eg: manual)
  2. hostpath (the path from the host machine to use it as a PV)

https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/

apiVersion: v1
kind: PersistentVolume
metadata:
  name: task-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/mnt/data"

we should define where does the PV getting memory to crated PV and then allow PVC to consume them. in a Real production Environment, we should use the storage that we have available for all pods like NFS share, GCP cloud persistent disk, or AKS storage .please go through the above link for further details as we have many possibilities.

Upvotes: 2

Related Questions