Search code examples
kubernetesmicrok8skompose

After running Kompose I get: pod has unbound immediate PersistentVolumeClaims


Whats the Problem?

I can't get my pods running which are using a volume. In the Kubernetes Dashboard I got the following error:

running "VolumeBinding" filter plugin for pod "influxdb-6979bff6f9-hpf89": pod has unbound immediate PersistentVolumeClaims

What did I do?

After running Kompose convert to my docker-compose.yml file I tried to start the pods with micro8ks kubectl apply -f . (I am using micro8ks) I had to replace the version of the networkpolicy yaml files with networking.k8s.io/v1 (see here) but except of this change, I didn't change anything.

YAML Files

influxdb-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: ./kompose convert
    kompose.version: 1.21.0 (992df58d8)
  creationTimestamp: null
  labels:
    io.kompose.service: influxdb
  name: influxdb
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: influxdb
  strategy:
    type: Recreate
  template:
    metadata:
      annotations:
        kompose.cmd: ./kompose convert
        kompose.version: 1.21.0 (992df58d8)
      creationTimestamp: null
      labels:
        io.kompose.network/cloud-net: "true"
        io.kompose.network/default: "true"
        io.kompose.service: influxdb
    spec:
      containers:
      - env:
        - name: INFLUXDB_HTTP_LOG_ENABLED
          value: "false"
        image: influxdb:1.8
        imagePullPolicy: ""
        name: influxdb
        ports:
        - containerPort: 8086
        resources: {}
        volumeMounts:
        - mountPath: /var/lib/influxdb
          name: influx
      restartPolicy: Always
      serviceAccountName: ""
      volumes:
      - name: influx
        persistentVolumeClaim:
          claimName: influx
status: {} 

influxdb-service.yaml

apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: ./kompose convert
    kompose.version: 1.21.0 (992df58d8)
  creationTimestamp: null
  labels:
    io.kompose.service: influxdb
  name: influxdb
spec:
  ports:
  - name: "8087"
    port: 8087
    targetPort: 8086
  selector:
    io.kompose.service: influxdb
status:
  loadBalancer: {} 

influx-persistenvolumeclaim.yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: influx
  name: influx
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 100Mi
status: {} 

Solution

  • The PersistentVolumeClaim will be unbound if either the cluster does not have a StorageClass which can dynamically provision a PersistentVolume or it does not have a manually created PersistentVolume to satisfy the PersistentVolumeClaim

    Here is a guide on how to configure a pod to use PersistentVolume

    To solve the current scenario you can manually create a PV

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

    Please note usage of hostPath is only as an example. It's not recommended for production usage. Consider using external block or file storage from the supported types here