Scalable-WordPress-deployment-on-Kubernetes
Scalable-WordPress-deployment-on-Kubernetes copied to clipboard
pods scheduled on different node can not communicate with each other
trafficstars
I created my cluster(k8s 1.8) by kubeadm on 2 physical server( os:ubuntu 16.04)
$ kubectl get nodes
NAME STATUS AGE VERSION
digital Ready 21m v1.8.0
next Ready 22m v1.8.0
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
wordpress-76b66d5644-76rtc 1/1 Running 4 7m
wordpress-mysql-5cdbc78858-vxnmn 1/1 Running 0 7m
By following this guide , I tried to deploy it on my cluster. WordPress pod was deployed on master node , and mysql pod was deployed on another worker node.
But wordpress pod can not connect mysql.
$ kubectl logs -f wordpress-76b66d5644-76rtc
MySQL Connection Error: (2002) No route to host
Warning: mysqli::mysqli(): (HY000/2002): No route to host in - on line 22
Warning: mysqli::mysqli(): (HY000/2002): No route to host in - on line 22
I had the same error, Then I made changes in the MySQL service file and it worked for me. Below is my MySQL_service.yaml file
================= apiVersion: v1 kind: Service metadata: name: wordpress-mysql labels: app: wordpress spec: ports: - port: 3306 selector: app: wordpress tier: mysql
=================