podman icon indicating copy to clipboard operation
podman copied to clipboard

HostPath is currently the only supported VolumeSource

Open djnotes opened this issue 6 years ago • 22 comments

I am trying to create a pod and start my services on it using Podman play kube deploy.yaml. Since I am using MariaDB database image, I need to pass in a named volume, but Podman does not seem to support it. Here's my deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
spec:
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      volumes:
        - name: webapp_initdb
          hostPath:
              path: /home/johndoe/src/webapp/data
              type: Directory  
        - name: webapp_dbvol
                      
      containers:
      - name: webapp_db
        image: mariadb:10.5
        env:
          - name: MYSQL_ROOT_PASSWORD
            value: password
          - name: MYSQL_DATABASE
            value: webapp
          - name: MYSQL_USER
            value: webapp
          - name: MYSQL_PASSWORD
            value: password
        volumeMounts:
          - name: webapp_dbvol
            mountPath: /var/lib/mysql
          - name: webapp_initdb
            mountPath: /docker-entrypoint-initdb.d

        resources:
          limits:
            memory: "128Mi"
            cpu: "500m"
        ports:
        - containerPort: 3306
      - name: webapp_app
        image: webapp
        resources:
          limits:
            memory: "128Mi"
            cpu: "500m"

The error I get:

Error: Error encountered while bringing up pod myapp-pod-0: HostPath is currently the only supported VolumeSource

djnotes avatar Sep 14 '20 13:09 djnotes

Sorry, wrong bug number (ignore "macos: podman 2.0.6 remote support is broken")

afbjorklund avatar Sep 15 '20 10:09 afbjorklund

Hi. What does this mean?

djnotes avatar Sep 15 '20 14:09 djnotes

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Oct 16 '20 00:10 github-actions[bot]

@djnotes I also ran into this issue and found a way to workaround it:

I had this in my YAML at spec.volumes:

  volumes:
    - name: master-secret-volume
      secret:
        secretName: master-secret

In Kubernetes when there's a secret called master-secret, it will automatically be bound to this volume.

Since podman play is not Kubernetes I have no secret, I guess, so I figured to change this to telling which file to mount by using the hostPath:

  volumes:
    - name: master-secret-volume
      hostPath:
            path: master/k8s/secret.yaml

I saw a similar thing in your YAML

      volumes:
        - name: webapp_initdb
          hostPath:
              path: /home/johndoe/src/webapp/data
              type: Directory  
        - name: webapp_dbvol

It's just a guess, but I think the error Error: HostPath is currently the only supported VolumeSource will go away once you either remove the - name: webapp_dbvol line or change it to look similar to the webabb_initdb.

kwk avatar Nov 20 '20 21:11 kwk

@mheon this should be part of the volume plugin work correct?

rhatdan avatar Nov 23 '20 12:11 rhatdan

No, this is not part of the volume plugin work. This is entirely separate and lives exclusively in play kube. Basically we need to figure out the various types of volumes Kubernetes supports and figure out a way of mapping those into Podman volumes.

mheon avatar Nov 23 '20 17:11 mheon

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Jan 01 '21 00:01 github-actions[bot]

We could use some help from community to fix this one.

rhatdan avatar Jan 04 '21 18:01 rhatdan

Pod: podman pod create --name test -p 8080:80

Db: podman run --rm --name mydb --pod test -v webdbvol:/var/lib/mysql -v pwd/data:/docker-entrypoint-initdb.d -e MYSQL_ROOT_PASSWORD=pass -e MYSQL_DATABASE=mydb -e MYSQL_USER=user -e MYSQL_PASSWORD=pass mariadb:10.5

Web: podman run --rm --name myweb --pod test nginx

Generate: podman pod generate kube test > test.yaml

Stop and remove pod: podman pod stop test && podman pod rm test

Play kube file: podman play kube test.yaml

# Generation of Kubernetes YAML is still under development!
#
# Save the output of this file and use kubectl create -f to import
# it into Kubernetes.
#
# Created with podman-2.2.1
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: "2021-01-05T16:57:11Z"
  labels:
    app: test
  name: test
spec:
  containers:
  - command:
    - nginx
    - -g
    - daemon off;
    env:
    - name: PATH
      value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    - name: TERM
      value: xterm
    - name: container
      value: podman
    - name: PKG_RELEASE
      value: 1~buster
    - name: NGINX_VERSION
      value: 1.19.6
    - name: NJS_VERSION
      value: 0.5.0
    - name: HOSTNAME
      value: test
    image: docker.io/library/nginx:latest
    name: myweb
    ports:
    - containerPort: 80
      hostPort: 8080
      protocol: TCP
    resources: {}
    securityContext:
      allowPrivilegeEscalation: true
      capabilities:
        drop:
        - CAP_MKNOD
        - CAP_NET_RAW
        - CAP_AUDIT_WRITE
      privileged: false
      readOnlyRootFilesystem: false
      seLinuxOptions: {}
    workingDir: /
  - command:
    - mysqld
    env:
    - name: PATH
      value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    - name: TERM
      value: xterm
    - name: container
      value: podman
    - name: MYSQL_PASSWORD
      value: pass
    - name: GPG_KEYS
      value: 177F4010FE56CA3336300305F1656F24C74CD1D8
    - name: MYSQL_USER
      value: user
    - name: MYSQL_ROOT_PASSWORD
      value: pass
    - name: MYSQL_DATABASE
      value: mydb
    - name: GOSU_VERSION
      value: "1.12"
    - name: MARIADB_MAJOR
      value: "10.5"
    - name: MARIADB_VERSION
      value: 1:10.5.5+maria~focal
    - name: HOSTNAME
      value: test
    image: docker.io/library/mariadb:10.5
    name: mydb
    resources: {}
    securityContext:
      allowPrivilegeEscalation: true
      capabilities:
        drop:
        - CAP_MKNOD
        - CAP_NET_RAW
        - CAP_AUDIT_WRITE
      privileged: false
      readOnlyRootFilesystem: false
      seLinuxOptions: {}
    volumeMounts:
    - mountPath: /docker-entrypoint-initdb.d
      name: home-johndoe-src-proj-data
    workingDir: /
  restartPolicy: Never
  volumes:
  - hostPath:
      path: /home/johndoe/src/proj/data
      type: Directory
    name: home-johndoe-src-proj-data
status: {}
---
metadata:
  creationTimestamp: null
spec: {}
status:
  loadBalancer: {}

Seems like the new version has fixed the problem. Hmm, at least we can say it is apparently skipping dealing with named volumes. As you can see, there is no mention of the db named volume in the kube file. So, maybe this can be a close.

djnotes avatar Jan 05 '21 17:01 djnotes

This is half-fixed at present. We have added support for additional volume types to podman play kube but not podman generate kube - so named volumes are handled if they are present in the YAML, but we do not presently have support for adding them automatically.

mheon avatar Jan 05 '21 18:01 mheon

This did not make the cut for 3.0 release. Hope to work on it afterwards.

rhatdan avatar Jan 14 '21 19:01 rhatdan

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Feb 14 '21 00:02 github-actions[bot]

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Mar 18 '21 00:03 github-actions[bot]

@umohnani8 Any chance you could look at this?

rhatdan avatar Mar 22 '21 14:03 rhatdan

I believe that play kube support for named volumes was added in this PR #8497 and generate kube support for named volumes is being worked here #9749. This information might help.

EduardoVega avatar Mar 23 '21 01:03 EduardoVega

At this point this is probably a documentation task - we need to document that these additional volume types are supported (I think we also support a few other types in the play kube code at this point, even).

mheon avatar Mar 23 '21 01:03 mheon

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Apr 23 '21 00:04 github-actions[bot]

@EduardoVega Interested in working on this?

rhatdan avatar Apr 23 '21 11:04 rhatdan

@rhatdan let me work on this.

EduardoVega avatar Apr 23 '21 12:04 EduardoVega

While you are in there want to look at https://github.com/containers/podman/issues/9763

rhatdan avatar Apr 23 '21 13:04 rhatdan