简体   繁体   中英

Kubernetes NFS: Using service name instead of hardcoded server IP address

I was able to get it working following NFS example in Kubernetes.

https://github.com/kubernetes/kubernetes/tree/master/examples/volumes/nfs

However, when I want to automate all the steps, I need to find the IP and update nfs-pv.yaml PV file with the hard coded IP address as mentioned in the example link page.

Replace the invalid IP in the nfs PV. (In the future, we'll be able to tie these together using the service names, but for now, you have to hardcode the IP.)

Now, I wonder that how can we tie these together using the services names ?

Or, it is not possible at the latest version of Kubernetes (as of today, the latest stable version is v1.6.2 ) ?

I got it working after I add kube-dns address to the each minion|node where Kubernetes is running. After login each minion, update resolv.conf file as the following;

cat /etc/resolv.conf
# Generated by NetworkManager
search openstacklocal localdomai
nameserver 10.0.0.10 # I added this line
nameserver 159.107.164.10
nameserver 153.88.112.200
....

I am not sure is it the best way but this works.

Any better solution is welcome.

You can use do this with the help of kube-dns , check whether it's service running or not,

kubectl get svc --namespace=kube-system

and kube-dns pod also,

kubectl get pods --namespace=kube-system

you have to add respected name-server according to kube-dns on each node in cluster, For more troubleshooting, follow this document, https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM