kubernetes内的服务访问集群外独立的服务最好通过endpoint方式,例如MySQL
1.创建mysql-service.yaml
apiVersion: v1 kind: Service metadata: name: mysql-production namespace: ms spec: ports: - port: 3306 targetPort: 3306 protocol: TCP
2.创建mysql-endpoints.yaml
kind: Endpoints apiVersion: v1 metadata: name: mysql-production namespace: ms subsets: - addresses: - ip: 10.255.20.176 ports: - port: 3306
3.查看 service
4.通过telnet测试