我有一個簡單的MYSQL pod坐在MYSQL服務後面。Kubernetes服務DNS解析返回錯誤IP
另外我有另一個運行python進程,試圖連接到MYSQL窗格的pod。
如果我嘗試從python pod手動連接到MYSQL pod的IP地址,則所有內容均爲A-OK。但是,如果我嘗試連接到MYSQL 服務然後我得到一個錯誤,我無法連接到MYSQL。
[email protected]:~/k8s/objects$ kubectl describe pod mysqlpod
Name: mysqlpod
Namespace: default
Node: minikube/192.168.99.100
Start Time: Fri, 20 Jan 2017 11:10:50 -0600
Labels: <none>
Status: Running
IP: 172.17.0.4
Controllers: <none>
[email protected]:~/k8s/objects$ kubectl describe service mysqlservice
Name: mysqlservice
Namespace: default
Labels: <none>
Selector: db=mysqllike
Type: ClusterIP
IP: None
Port: <unset> 3306/TCP
Endpoints: 172.17.0.5:3306
Session Affinity: None
No events.
[email protected]:~/k8s/objects$ kubectl describe pod basic-python-model
Name: basic-python-model
Namespace: default
Node: minikube/192.168.99.100
Start Time: Fri, 20 Jan 2017 12:01:50 -0600
Labels: db=mysqllike
Status: Running
IP: 172.17.0.5
Controllers: <none>
如果我重視我的Python容器並做mysqlservice進行nslookup,然後我確實得到錯誤 IP。正如你在上面看到的,mysqlpod的IP是172.17.0.4,而nslookup mysqlservice解析爲172.17.0.5。
[email protected]:~/k8s/objects$ k8s exec -it basic-python-model bash
[[email protected] /]# nslookup mysqlservice
Server: 10.0.0.10
Address: 10.0.0.10#53
Name: mysqlservice.default.svc.cluster.local
Address: 172.17.0.5
我是相當新的kubernetes,但我一直在敲打我的頭就這個問題進行了幾個小時,我似乎無法理解我在做什麼錯。