Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to connect to mysql database present outside kubernetes cluster via egressgateway and service entry #40640

Closed
akankshyad opened this issue Aug 24, 2022 · 1 comment
Labels
lifecycle/automatically-closed Indicates a PR or issue that has been closed automatically. lifecycle/stale Indicates a PR or issue hasn't been manipulated by an Istio team member for a while

Comments

@akankshyad
Copy link

akankshyad commented Aug 24, 2022

I am trying to connect one microservice to external mysql database by egress gateway from kubernetes cluster. But it is not working. My yaml files look like below.


apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: mysql
  namespace: istio-system
spec:
  hosts:
  - dbhost.svc.local
  addresses:
  - X.X.X.X/32
  ports:
  - number: 3306
    name: tcp
    protocol: TCP
  location: MESH_EXTERNAL
  resolution: STATIC
  endpoints:
  - address: X.X.X.X
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: istio-egressgateway
  namespace: istio-system
spec:
  selector:
    istio: egressgateway
  servers:
  - port:
      number: 777
      name: tcp
      protocol: TCP
    hosts:
    - dbhost.svc.local
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: egressgateway-for-mysql
  namespace: istio-system
spec:
  host: istio-egressgateway.istio-system.svc.cluster.local
  subsets:
  - name: mysql
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: mysql
  namespace: istio-system
spec:
  host: dbhost.svc.local
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: direct-mysql-through-egress-gateway
  namespace: istio-system
spec:
  hosts:
  - dbhost.svc.local
  gateways:
  - mesh
  - istio-egressgateway
  tcp:
  - match:
    - gateways:
      - mesh
      destinationSubnets:
      - X.X.X.X/32
      port: 3306
    route:
    - destination:
        host: istio-egressgateway.istio-system.svc.cluster.local
        subset: mysql
        port:
          number: 777
  - match:
    - gateways:
      - istio-egressgateway
      port: 777
    route:
    - destination:
        host: dbhost.svc.local
        port:
          number: 3306
      weight: 100

trying to connect to db which has hostname and port as dbhost.svc.local:3306

I am getting below error.
java.net.UnknownHostException: dbhost.svc.local

kubectl get svc istio-egressgateway -n istio-system -o wide
NAME                  TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                       AGE   SELECTOR
istio-egressgateway   ClusterIP   X.X.X.X   <none>        80/TCP,443/TCP,777/TCP   26d   app=istio-egressgateway,istio=egressgateway
@ericvn ericvn transferred this issue from istio/istio.io Aug 24, 2022
@istio-policy-bot istio-policy-bot added the lifecycle/stale Indicates a PR or issue hasn't been manipulated by an Istio team member for a while label Nov 23, 2022
@istio-policy-bot
Copy link

🚧 This issue or pull request has been closed due to not having had activity from an Istio team member since 2022-08-24. If you feel this issue or pull request deserves attention, please reopen the issue. Please see this wiki page for more information. Thank you for your contributions.

Created by the issue and PR lifecycle manager.

@istio-policy-bot istio-policy-bot added the lifecycle/automatically-closed Indicates a PR or issue that has been closed automatically. label Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/automatically-closed Indicates a PR or issue that has been closed automatically. lifecycle/stale Indicates a PR or issue hasn't been manipulated by an Istio team member for a while
Projects
None yet
Development

No branches or pull requests

2 participants