Within kubernetes cluster access to external services via endpoint

External access to the cluster service within kubernetes independent service is the best way through the endpoint, such as MySQL

1. Create mysql-service.yaml

apiVersion: v1
kind: Service
metadata:
  name: mysql-production
  namespace: ms
spec:
  ports:
    - port: 3306
      targetPort: 3306
      protocol: TCP

2. Create mysql-endpoints.yaml

kind: Endpoints
apiVersion: v1
metadata:
  name: mysql-production
  namespace: ms
subsets:
  - addresses:
      - ip: 10.255.20.176
    ports:
      - port: 3306

3. View service

 

4. Testing via telnet

 

Guess you like

Origin www.cnblogs.com/chadiandianwenrou/p/11929295.html