简体   繁体   English

Kubernetes NFS:使用服务名称而不是硬编码的服务器IP地址

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

I was able to get it working following NFS example in Kubernetes. 我能够按照Kubernetes中的NFS示例使其工作。

https://github.com/kubernetes/kubernetes/tree/master/examples/volumes/nfs 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. 但是,当我想自动化所有步骤时,我需要找到IP并使用示例链接页面中提到的硬编码IP地址更新nfs-pv.yaml PV文件。

Replace the invalid IP in the nfs PV. 替换nfs PV中的无效IP。 (In the future, we'll be able to tie these together using the service names, but for now, you have to hardcode the IP.) (将来,我们将能够使用服务名称将它们捆绑在一起,但现在,您必须对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 ) ? 或者,在最新版本的Kubernetes上是不可能的(到目前为止,最新的稳定版本是v1.6.2 )?

I got it working after I add kube-dns address to the each minion|node where Kubernetes is running. 在将kube-dns地址添加到运行Kubernetes的每个minion |节点后, 它就可以工作了。 After login each minion, update resolv.conf file as the following; 登录每个奴才后,按以下步骤更新resolv.conf文件;

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, 您可以在kube-dns的帮助下执行此操作,检查它是否正在运行服务,

kubectl get svc --namespace=kube-system

and kube-dns pod also, 还有kube-dns pod

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/ 您必须根据群集中每个节点上的kube-dns添加受尊敬的名称服务器,有关更多故障排除,请遵循此文档, https: //kubernetes.io/docs/concepts/services-networking/dns-pod-service/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Kubernetes NFS服务器pod挂载适用于pod ip,但不适用于kubernetes服务 - Kubernetes NFS server pod mount works with pod ip but not with kubernetes service 如何使用服务 IP 地址在 Kubernetes 代替 POD IP 地址 - how to use service IP address at Kubernetes instead of POD IP address 我可以在 Kubernetes Ingress 中使用 ip 地址代替域名吗? - Can I use ip address in Kubernetes Ingress instead of domain name? 在aws上使用弹性ip地址公开kubernetes服务 - Exposing kubernetes service using elastic ip address on aws Kubernetes服务-无法访问服务IP地址 - Kubernetes service - service IP address is not accessible 如何在kubernetes中使用服务名称而不是外部IP /域名作为服务端点URL - How to use service name instead of External IP/domain name for a service endpoint url in kubernetes Kubernetes - 服务群集IP地址与Pod IP地址 - Kubernetes - service cluster IP address vs Pod IP address Kubernetes服务的对外连接IP地址是多少? - What is the external connection IP address of Kubernetes service? 使用主机名而不是 ip 地址访问 kuberntes 上的服务 - Access service on kuberntes using hostname instead of ip Address 未为 Kubernetes 服务分配(外部)IP 地址 - Kubernetes Service not being assigned an (external) IP address
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM