Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

4/12/2019

I'm trying to mount a hostPath volume to a pod during deployment but getting

"Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type"

These are my manifest files:

Service

apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: kompose convert --volumes hostPath
    kompose.version: 1.17.0 (a74acad)
  creationTimestamp: null
  labels:
    io.kompose.service: decs-zc1
  name: decs-zc1
spec:
  ports:
  - name: "2201"
    port: 2201
    targetPort: 22
  selector:
    io.kompose.service: decs-zc1
status:
  loadBalancer: {}

PersistentVolume

apiVersion: v1
kind: PersistentVolume
metadata:
  name: decs-zc1-0
spec:
  hostPath:
    path: '/home/ubuntu/docker-compose/usr/local/ihi/pilot/zc1'
  capacity:
    storage: 10Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: decs-zc1-0
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: decs-zc1-1
spec:
  hostPath:
    path: '/home/ubuntu/docker-compose/usr/local/ihi/pilot/zc1/runtime/'
  capacity:
          storage: 2Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: decs-zc1-1
---
uapiVersion: v1
kind: PersistentVolume
metadata:
  name: decs-zc1-2
spec:
  hostPath:
    path: '/home/ubuntu/docker-compose/etc/localtime/'
  capacity:
          storage: 1Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: decs-zc1-2  

PersistentVolumeClaim

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: decs-zc1-claim0
  name: decs-zc1-claim0
spec:
  storageClassName: decs-zc1-0
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: decs-zc1-claim1
  name: decs-zc1-claim1
spec:
  storageClassName: decs-zc1-1
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 2Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: decs-zc1-claim2
  name: decs-zc1-claim2
spec:
  storageClassName: decs-zc1-2
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

Deployment

apiVersion: apps/v1beta2
kind: Deployment
metadata:
  annotations:
    kompose.cmd: kompose --file docker-compose.yml convert
    kompose.version: 1.17.0 (a74acad)
  creationTimestamp: null
  labels:
    io.kompose.service: decs-zc1
  name: decs-zc1
spec:
  replicas: 1
  selector:
        matchLabels:
      app: decs-zc1
  strategy:
    type: Recreate
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: decs-zc1
    spec:
      containers:
      - args:
        - sh
        - /home/decs/ihi_run_zc.sh
        image: 460093719278.dkr.ecr.us-east-1.amazonaws.com/pilot-zc:latest
        name: decs-zc1
        ports:
        - containerPort: 22
        resources: {}
        volumeMounts:
        - mountPath: /usr/local/ihi-decs
          name: decs-zc1-claim0
        - mountPath: /tmp
          name: decs-zc1-claim1
        - mountPath: /etc/localtime
          name: decs-zc1-claim2
      restartPolicy: Always
      volumes:
      - name: decs-zc1-claim0
        persistentVolumeClaim:
          claimName: decs-zc1-claim0
      - name: decs-zc1-claim1
        persistentVolumeClaim:
          claimName: decs-zc1-claim1
      - name: decs-zc1-claim2
        persistentVolumeClaim:
          claimName: decs-zc1-claim2
status: {}

Expected results for the pod to be able to mount the volumes and start.

-- Barak
kubernetes

0 Answers