简体   繁体   中英

Not able to access Kubernetes service among nodes

I have two services- Tomcat and Mysql. Tomcat is front facing and hence I am using node port for that but for the mysql container, I am using Cluster Ip type for service.

I have multiple nodes in Kuberntes cluster and multiple replicas of tomcat. When tomcat container is coming in the master node, It is working fine, But when spawned on other nodes, It is failing as it is not able to make a connection to other services.

Can anyone please help with this how to provide the endpoint here so that Tomcat will able to make a connection to MySQL service through JDBC.

Currently, I am referencing services using service name itself.

Error -
I am accessing the db through db hostname and jdbc url, I am getting unkown host error.

I suggest you to use statefulset for MySQL and "none" as clusterIp.

apiVersion: v1
kind: Service
metadata:
  name: mysql
  labels:
    app: mysql
spec:
  clusterIP: None
  ports:
  - port: 3306
    name: server
  selector:
    app: mysql

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM