k8s访问集群外独立的服务最好的方式是采用Endpoint方式,以mysql服务为例:

  • 创建mysql-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: mysql-production
spec:
  ports:
    - port: 3306

  

  • 创建mysql-endpoints.yaml
kind: Endpoints
apiVersion: v1
metadata:
  name: mysql-production
  namespace: default
subsets:
  - addresses:
      - ip: 192.168.1.25
    ports:
      - port: 3306

  

就是将外部IP地址和服务引入到k8s集群内部,由service作为一个代理来达到能够访问外部服务的目的。

 

相关文章:

  • 2021-03-03
  • 2021-08-05
  • 2021-12-06
  • 2021-05-12
  • 2021-05-21
  • 2021-11-13
  • 2021-11-22
猜你喜欢
  • 2021-12-05
  • 2021-10-01
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
  • 2021-10-27
  • 2021-08-30
相关资源
相似解决方案