Using kubeadm with a two-node cluster on VirtualBox Centos7 VMs. I have an app 
written in R and a mysql database each in their own pods. I've successfully 
followed instructions to setup nginx ingress controller so that the app can be 
reached outside the VMs, by my local machine. check :)

However, now when another pod (or the app (R) ) tries to reach to the mysql 
service, the name doesn't resolve. e.g. Pinging 'mysql' or the service's 
clusterIP from bash. This used to work, but no longer works:

mydb<-dbConnect(MySQL(), user = 'root', password ='password',
                dbname = 'prototype', host = 'mysql')

Instead I have to use the pod's IP / endpoint, which does work.

mydb<-dbConnect(MySQL(), user = 'root', password ='password',
                dbname = 'prototype', host = '10.244.1.233')

However, isn't this going to change upon reboots and system changes? I'd like a 
more static way to refer to the mysql db.

$ kubectl get endpoints
NAME         ENDPOINTS                             AGE
kubernetes   192.168.56.101:6443                   5h
mysql        10.244.1.233:3306                     41m
r-user-app   10.244.1.232:8787,10.244.1.232:3838   2h

$ kubectl get svc
NAME         TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)               
          AGE
kubernetes   ClusterIP      10.96.0.1       <none>        443/TCP               
          5h
mysql        ClusterIP      10.96.138.132   <none>        3306/TCP              
          28m
r-user-app   LoadBalancer   10.100.228.80   <pending>     
3838:32467/TCP,8787:31754/TCP   2h

$ kubectl get ing
NAME         HOSTS              ADDRESS   PORTS     AGE
r-user-app   storage.test.com             80, 443   3h

$ kubectl describe service mysql
Name:              mysql
Namespace:         default
Labels:            <none>
Annotations:       <none>
Selector:          app=neurocore,tier=mysql
Type:              ClusterIP
IP:                10.96.138.132
Port:              <unset>  3306/TCP
TargetPort:        3306/TCP
Endpoints:         10.244.1.236:3306
Session Affinity:  None
Events:            <none>

 ps auxw | grep kube-proxy
root      1914  0.1  0.3  44848 21668 ?        Ssl  11:03   0:20 
/usr/local/bin/kube-proxy --config=/var/lib/kube-proxy/config.conf
root     29218  0.0  0.0 112660   980 pts/1    R+   14:23   0:00 grep 
--color=auto kube-proxy

$iptables-save | grep mysql
-A KUBE-SEP-7P27CEQL6WJZRBQ5 -s 10.244.1.236/32 -m comment --comment 
"default/mysql:" -j KUBE-MARK-MASQ
-A KUBE-SEP-7P27CEQL6WJZRBQ5 -p tcp -m comment --comment "default/mysql:" -m 
tcp -j DNAT --to-destination 10.244.1.236:3306
-A KUBE-SERVICES ! -s 10.244.0.0/16 -d 10.96.138.132/32 -p tcp -m comment 
--comment "default/mysql: cluster IP" -m tcp --dport 3306 -j KUBE-MARK-MASQ
-A KUBE-SERVICES -d 10.96.138.132/32 -p tcp -m comment --comment 
"default/mysql: cluster IP" -m tcp --dport 3306 -j KUBE-SVC-M7XME3WTB36R42AM
-A KUBE-SVC-M7XME3WTB36R42AM -m comment --comment "default/mysql:" -j 
KUBE-SEP-7P27CEQL6WJZRBQ5

-- 
You received this message because you are subscribed to the Google Groups 
"Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to kubernetes-users+unsubscr...@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to