skip to content
Alvin Lucillo

Reach service from another namespace

/ 1 min read

For example, if your webapp (webapp-c58766496-vz7tc) wants to connect to mysql service, since the service is in another namespace, you would need to use webapp-service.svc.payroll.cluster.local.

controlplane ~  k get po -owide -A
NAMESPACE      NAME                                   READY   STATUS    RESTARTS   AGE   IP               NODE           NOMINATED NODE   READINESS GATES
default        webapp-c58766496-vz7tc                 1/1     Running   0          7s    172.17.0.14      controlplane   <none>           <none>
payroll        mysql                                  1/1     Running   0          13m   172.17.0.10      controlplane   <none>           <none>

controlplane ~  k get svc -owide
NAME             TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE   SELECTOR
kubernetes       ClusterIP   172.20.0.1       <none>        443/TCP          36m   <none>
webapp-service   NodePort    172.20.110.197   <none>        8080:30082/TCP   16m   name=webapp

controlplane ~  k get nodes -owide
NAME           STATUS   ROLES           AGE   VERSION   INTERNAL-IP      EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION    CONTAINER-RUNTIME
controlplane   Ready    control-plane   36m   v1.33.0   192.168.56.151   <none>        Ubuntu 22.04.5 LTS   5.15.0-1083-gcp   containerd://1.6.26