Kubernetes Storage type Hostpath- files mapping issue

1/8/2019

Hi I am using latest kubernetes 1.13.1 and docker-ce (Docker version 18.06.1-ce, build e68fc7a).

I setup a deployment file that mount a file from the host (host-path) and mounts it inside a container (mountPath).

The bug is when I am trying to mount a find from the host to the container I get an error message that It's not a file. (Kubernetes think that the file is a directory for some reason)

When I am trying to run the containers using the command: Kubectl create -f it stay at ContainerCreating stage forever.

after deeper look on it using Kubectl describe pod it say:
Is has an error message the the file is not recognized as a file.

Here is the deployment file:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: notixxxion
  name: notification
spec:
  replicas: 1
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: notification
    spec:
      containers:
      - image: docker-registry.xxxxxx.com/xxxxx/nxxxx:laxxt
        name: notixxxion
        ports:
        - containerPort: xxx0
####   host file configuration
        volumeMounts:
        - mountPath: /opt/notification/dist/hellow.txt
          name: test-volume
          readOnly: false
      volumes:
      - name: test-volume
        hostPath:
        # directory location on host
          path: /exec-ui/app-config/hellow.txt
        # this field is optional
          type: FileOrCreate
          #type: File
status: {}
-- Yaniv Hakim
docker
kubernetes

2 Answers

1/9/2019

Check for file permissions which you are trying to mount!

As a last resort try using privileged mode.

Hope it helps!

-- Vishwa
Source: StackOverflow

1/9/2019

I have reinstalled the kubernetes cluster and it got little bit better. kubernetes now can read files without any problem and the container in creating and running But, there is some other issue with the host path storage type:

hostPath containing mounts do not update as they change on the host even after I delete the pod and create it again

-- Yaniv Hakim
Source: StackOverflow