I have installed a Kubernetes cluster on VirtualBox (centos7) using a tutorial from here.
Here is my setup:
- kube-master - 10.1.10.152 (etcd, kube-apiserver, kube-controller-manager, kube-scheduler)
- kube-minion1 - 10.1.10.153 (kube-proxy, kubelet, docker, flanneld)
When i finished the setup everything looked good:
$ kubectl get nodes
NAME LABELS STATUS
kube-minion1 kubernetes.io/hostname=kube-minion1 Ready
I tried to add mysql pod and service using the following config:
$ cat mysql.yaml
apiVersion: v1
kind: Pod
metadata:
name: mysql
labels:
name: mysql
spec:
containers:
- resources:
limits :
cpu: 1
image: mysql
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
value: qwe123
ports:
- containerPort: 3306
name: mysql
$ cat mysql-service.yaml
apiVersion: v1
kind: Service
metadata:
labels:
name: mysql
name: mysql
spec:
publicIPs:
- 10.1.10.153
ports:
# the port that this service should serve on
- port: 3306
# label keys and values that must match in order to receive traffic for this service
selector:
name: mysql
Notice that i do provide the publicIPs = 10.1.10.153. Once both mysql.yaml and mysql-service.yaml were injected, here is what i get:
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
mysql 1/1 Running 0 31s
$ kubectl get services
NAME LABELS SELECTOR IP(S) PORT(S)
kubernetes component=apiserver,provider=kubernetes <none> 10.254.0.1 443/TCP
mysql name=mysql name=mysql 10.254.215.138 3306/TCP
$ kubectl describe service mysql
Name: mysql
Namespace: default
Labels: name=mysql
Selector: name=mysql
Type: ClusterIP
IP: 10.254.215.138
Port: <unnamed> 3306/TCP
Endpoints: 172.17.17.5:3306
Session Affinity: None
No events.
So the problem i am having is that mysql is not accessible using 10.1.10.153. The only way to communicate with mysql that i was able to do is accessing from the minion host using 10.254.215.138
Why am i unable to access it using 10.1.10.153? Is there a way to make it work?
Thank you -D