3

What I Have:

A Kubernetes Deployment on a Cluster with Googles Container Optimized OS as Node OS

result of cat /etc/*-release

Further the deployment.yaml

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: my-app
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
        - name: my-app
          image: eu.gcr.io/my-project/my-app
          ports:
          - containerPort: 8013

          volumeMounts:
          - mountPath: /my/cache/
            name: cache

       volumes:
       - name: cache
         nfs:
           server: cache
           path: /cache/my-app/
           readOnly: false

The problem is that the nfs-mount works when I explicitly enter the IP-Address but for whatever reason it is not possible to resolve the hostname.

volumes:
   - name: cache
     nfs:
       server: 192.168.1.1 # this example would work
       path: /cache/my-app/
       readOnly: false

However with the hostname entered mount.nfs exits with

Mount failed: exit status 32 ... Output: mount.nfs: Failed to resolve server cache

However I am able to ping the server by hostname from the Node. It also works when I use a normal Container-VM indicating it might be a problem with Googles Container Optimized OS...

How can I tell Kubernetes to resolve the server of the nfs-mount by hostname?

1

This seems to be known issue tracked under github [1][2]. As workaround, You can "Copy the /etc/resolv.conf from the GCE VM (this will include the GCP search path, metadata DNS resolver) into the chroot env (/home/kubernetes/containerized_mounter/rootfs) directory" and use NFS FQDN eg: server-name.svc.cluster.local as hostname.

In addition, Here is [3] the pull request(PR) on github to set up DNS server in containerized mounter path to resolve the hostname.

[1] https://github.com/kubernetes/kubernetes/issues/48212

[2] https://github.com/kubernetes/kubernetes/pull/42376

[3] https://github.com/kubernetes/kubernetes/pull/51645

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.