Tuesday, March 26, 2019

How to access external service port or external database from istio installed Kubernetes cluster


If you are using istio service mesh you will not be able to access external services (egress) by default.

If you check container logs, you can see that there is a communication link failure(you error message should be difference from below if you are using any other database other than mysql)

$ kubectl logs -f <pod name> -c <container name>
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

And you can see that the pod is not deployed correctly,

To access mysql external service(or any other external service) you need to create a serviceentry in istio,

$ kubectl apply -f - <<EOF
apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: mysql
spec:
  hosts:
  - <hostname of the service>
  addresses:
  - <IP address of the service>
  ports:
  - name: tcp
    number: <external port number>
    protocol: tcp
  location: MESH_EXTERNAL
EOF

After running above yml file, you can remove existing pods and check with newly created pods whether successfully connected to the database,





https://istio.io/blog/2018/egress-tcp/

No comments:

Post a Comment