Dunge
Dunge

Reputation: 758

Exposing kubernetes ingress to host machine running KinD on Windows and WSL2

I'm using KinD on Windows via Docker Destop running on WSL2 and trying to set up the ingress to expose port on my host machine.

I followed the guide and installed the cluster with the config as shown here: https://kind.sigs.k8s.io/docs/user/ingress/, along with Ingress NGINX controller (from helm) and a custom Ingress ressource redirecting to my service with the proper classname.

apiVersion: kind.x-k8s.io/v1alpha4
kind: Cluster
nodes:
- role: control-plane
  kubeadmConfigPatches:
  - |
    kind: InitConfiguration
    nodeRegistration:
      kubeletExtraArgs:
        node-labels: "ingress-ready=true"
  extraPortMappings:
  - containerPort: 80
    hostPort: 5180
    protocol: TCP
  - containerPort: 443
    hostPort: 51443
    protocol: TCP

If I kubectl port-forward to the ingress service, it works fine and I can access service website.

But I'm unable to access directly it via the hostPort setting set on the cluster config without port-forward (http://localhost:5180). KinD doesn't seem to attribute an external-ip to the ingress controller, it remains in <Pending> state.

Any idea why and how to diagnose further? Thanks!

pod/ingress-nginx-controller-6bf7bc7f94-2r74v                   1/1     Running     0             15h
service/ingress-nginx-controller                         LoadBalancer   10.96.1.208     <pending>     80:30674/TCP,443:30800/TCP              15h
service/ingress-nginx-controller-admission               ClusterIP      10.96.103.184   <none>        443/TCP                                 15h
my-ingress   nginx   *                 80      16h

Upvotes: 3

Views: 477

Answers (1)

Karol Flis
Karol Flis

Reputation: 311

Hmm. I dont know about KinD but as a general principle, ingress creates public load balancer which has external ip (globaly available). Also in the configuration of ingress (vanilla/nginx ingress), you would have to configure endpoints (paths). Also try to check this stuff: https://kubernetes.io/docs/concepts/services-networking/ingress/#name-based-virtual-hosting

Upvotes: -1

Related Questions