0

Hy guys, please I need some help; I'm using Kubernetes in minikube on Ubuntu 20.04 with ingress add-on enabled. I want my NextJS service to communicate to my Express Service connected via ingress server by making request only via Ingress controller. So when I use cross namespace communication it doesn't work as illustrated in the tutorial presented. Since ingress-nginx in minikube runs on kube-system namespace.


$ kubectl get service -n kube-system

NAME                                 TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)                  AGE
ingress-nginx-controller-admission   ClusterIP   10.103.20.47   none          443/TCP                  15d
kube-dns                             ClusterIP   10.96.0.10     none          53/UDP,53/TCP,9153/TCP   36d

The services that I am running

$ kubectl get services  
                        
NAME             TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)     AGE
auth-mongo-srv   ClusterIP   10.96.2.86       <none>        27017/TCP   20m
auth-srv         ClusterIP   10.106.150.115   <none>        3000/TCP    20m
client-srv       ClusterIP   10.106.45.17     <none>        3000/TCP    20m
kubernetes       ClusterIP   10.96.0.1        <none>        443/TCP     26h

Expected request url was: http://ingress-nginx.ingress-nginx.svc.cluster.local(Communication through nginx) But instead I have to go through http://auth-srv:3000 (Which is direct communication between services)

My Ingress Config file

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: 'true'
spec:
  rules:
    - host: ticketing.dev
      http:
        paths:
          - path: /api/users/?(.*)
            pathType: Prefix
            backend:
              service:
                name: auth-srv
                port:
                  number: 3000
          - path: /?(.*)
            pathType: Prefix
            backend:
              service:
                name: client-srv
                port:
                  number: 3000

  • 1
    All services listed are using Cluster IP service type. I recommend taking a look at the following post for a comparision between available K8s service types, and the DNS names available for each service type: https://stackoverflow.com/questions/41509439/whats-the-difference-between-clusterip-nodeport-and-loadbalancer-service-types – Attila Viniczai Oct 19 '20 at 20:35
  • Can you update your questions with your ingress definition? – thomas Oct 20 '20 at 09:45
  • @thomas, I've updated it with the Ingress config file. Thanks. – OBIDI ISAAC Oct 21 '20 at 10:42
  • It is still not clear to me where the NextJs service is located. Is it inside the cluster or running in the host machine? Can you provide output from the command `kubectl get pods,svc --all-namespaces --show-labels`. You mentioned some tutorial that you are using? Can you also provide some reference to it? – thomas Oct 21 '20 at 11:27

1 Answers1

0

I see this is Stephen Grider course about microservices.

As a temporary solution, you can try to do next:

$ kubectl get ingress

Take an IP Address.

You can use it as next link in your application.

192-168-49-2.kubernetes.default.svc.cluster.local

Instead of ingress-service.default.svc.cluster.local

====

More detailed information if needed.

Marley
  • 1
  • 3