Cannot connecto to external database from inside kubernetes pod

前端 未结 3 1847
时光说笑
时光说笑 2021-01-27 00:24

I am trying to connect my spring-boot api inside a kubernetes pod to an external database (a separate machine but within the local network), however when running, I get SQLNonTr

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-27 01:07

    After hours of digging and reconfiguring, I finally get it to work, thanks to Xenwar from kubernetes group for pointing out the externalIP property, it turns out that i need to point my app to an external ip, in this case the database, here is the service object:

    apiVersion: v1
    kind: Service
    metadata:
      name: db-con
    spec:
      selector:
        app: api2
      ports:
        - name: http
          protocol: TCP
          port: 3306
          targetPort: 3306
      externalIPs:
        - 10.0.123.28
    

提交回复
热议问题