Home > front end >  podman play kubernetes: Volume mount database-data-volume specified for container but not configured
podman play kubernetes: Volume mount database-data-volume specified for container but not configured

Time:08-09

I have a kubernetes pod configuration with a named volume and want to run it via podman play kube which fails for an unknown reason:

podman play kube kubernetes.yml:

Error: kubernetes.yml: Volume mount database-data-volume specified for container but not configured in volumes

The error indicates that the volume does not exist, but it's there:

> podman volume list

DRIVER      VOLUME NAME
local       database-data-volume

kubernetes.yml

apiVersion: v1
kind: Pod
...
spec:
  containers:
  ...
  - image: it.impl/h2-database:2.1.214-0
    name: database
    ports:
      - containerPort: 8082
        hostPort: 8082
      - containerPort: 9092
        hostPort: 9092
    volumeMounts:
      - mountPath: /opt/h2-database/data
        name: database-data-volume
  volumes:
    - persistentVolumeClaim:
        claimName: database-data-volume
  restartPolicy: Never

CodePudding user response:

Your volume is missing a name (this would fail on Kubernetes as well). The volumes section maps a volume name to some sort of volume definition; when you write:

  volumes:
    - persistentVolumeClaim:
        claimName: database-data-volume

You have a volume definition but no volume name. You need:

  volumes:
    - name: database-data-volume
      persistentVolumeClaim:
        claimName: database-data-volume
  • Related