Query kubernetes pod (inside VM) from my local machine

1/21/2022

I'm trying to deploy an api (wso2) on kube, and contact this API from my local machine.

Here is my setup :

  • Windows WSL 2 (local machine)
  • Ubuntu (VM)
  • Minikube on the VM

Here is my ingress.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: mi2-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: nginx
  rules:
  - host: mi2-test.fr
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: mi2-httpservice
            port:
              number: 8290
  - host: mi2-test-https.fr
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: mi2-httpservice
            port:
              number: 9201
  - host: mi2-test-http.fr
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: mi2-httpservice
            port:
              number: 9164

After the deployment :

So it looks like my ingress.yaml have done it's work, but when I'm trying to reach http://mi2-test.fr:8290 => CONNECTION REFUSED

I've set up my hosts file too.

Any idea what am I doing wrong ? Thanks

Edit : Here is my hosts file settings :

127.0.0.1 mi2-test.fr
127.0.0.1 mi2-test-http.fr
127.0.0.1 mi2-test-https.fr

And result of kubectl get ingress mi2-ingress:

Results

-- Cesar
kubernetes
kubernetes-ingress
minikube
nginx-ingress

1 Answer

1/28/2022

As suggested above in the comments, You may give a try with port forward:

kubectl forward svc/mi2-httpservice 8290:8290

Afterwards test on localhost:8290

-- Pit
Source: StackOverflow