k8s: how to reach services behind ingresses

2/4/2020

This is my current ingress:

$ kubectl get ingress -o wide
NAME                   HOSTS          ADDRESS      PORTS   AGE
chart-1580851873-dev   feedly.local   172.18.0.2   80      3m21s

I've added this on my /etc/hosts:

172.18.0.2      *.local

This is my nodes ip:

$ kubectl get nodes -o wide
NAME               STATUS   ROLES    AGE    VERSION         INTERNAL-IP   EXTERNAL-IP   OS-IMAGE   KERNEL-VERSION     CONTAINER-RUNTIME
k3d-k3s-worker-1   Ready    <none>   6d3h   v1.17.0+k3s.1   172.18.0.3    <none>        Unknown    5.3.0-28-generic   containerd://1.3.0-k3s.5
k3d-k3s-worker-0   Ready    <none>   6d3h   v1.17.0+k3s.1   172.18.0.4    <none>        Unknown    5.3.0-28-generic   containerd://1.3.0-k3s.5
k3d-k3s-server     Ready    master   6d3h   v1.17.0+k3s.1   172.18.0.2    <none>        Unknown    5.3.0-28-generic   containerd://1.3.0-k3s.5

I'm trying to get reach my service behind feedly.local...

These are my service and running pods:

$ kubectl get services -o wide
NAME                   TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)    AGE     SELECTOR
chart-1580851873-dev   ClusterIP   10.43.17.2   <none>        8080/TCP   7m26s   app.kubernetes.io/instance=chart-1580851873,app.kubernetes.io/name=dev

$ kubectl get pods -o wide
NAME                                    READY   STATUS    RESTARTS   AGE     IP           NODE               NOMINATED NODE   READINESS GATES
chart-1580851873-dev-79f8df5858-bp9wx   1/1     Running   0          7m48s   10.42.2.35   k3d-k3s-worker-0   <none>           <none>

Important: I don't want to run kubectl proxy neither port-forwarding. I want to get access to internal kubernetes dns service in order to reach services behind ingresses.

Any ideas?

-- Jordi
kubernetes

1 Answer

2/5/2020

To fully link your local workstation into the internal cluster network you can look at tools like Telepresence or VPNs like WireGuard. That said, this is probably a bad idea, the point of the internal network is that its internal. If you want to expose a service, do that through the Service system. If you want access for debugging either use port-forward or kubectl run -it a temporary pod with a shell and tools you need.

-- coderanger
Source: StackOverflow