Home > Net >  Kubernetes Ingress objects return no response on Windows 10 Minikube
Kubernetes Ingress objects return no response on Windows 10 Minikube

Time:10-24

I try to test Kubernetes Ingress on Minikube. My OS is windows 10. Minikube is installed successfully as well as nginx ingress controller.

> minikube addons enable ingress

Below is my Kubernetes manifest file.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
  namespace: ingress-nginx
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
    kubernetes.io/ingress.class: 'nginx'
    nginx.ingress.kubernetes.io/default-backend: app-nginx-svc
spec:
  rules:
    - host: boot.aaa.com
      http:
        paths:
          - path: /path
            pathType: Prefix
            backend:
              service:
                name: app-nginx-svc
                port:
                  number: 80

---
apiVersion: v1
kind: Service
metadata:
  name: app-nginx-svc
  namespace: ingress-nginx
spec:
  type: NodePort  
  selector:
    app: test-nginx  
  ports:
  - name: http
    port: 80
    targetPort: 80
    nodePort: 30000

---
apiVersion: v1
kind: Pod
metadata:
  name: app-nginx
  namespace: ingress-nginx  
  labels:
    app: test-nginx
spec:
  containers:
  - name: nginx
    image: nginx
    ports: 
    - containerPort: 80

Kubernetes Pod and Service are generated on minikube without errors. When I test service with the below commands, the pod shows the right values.

> minikube service -n ingress-nginx app-nginx-svc --url
* app-nginx-svc 서비스의 터널을 시작하는 
|--------------------|---------------|-------------|------------------------|
|   NAMESPACE   |     NAME     | TARGET PORT |      URL           |
|--------------------|---------------|-------------|------------------------|
|  ingress-nginx  | app-nginx-svc |           | http://127.0.0.1:63623 |
|-------------------|---------------|-------------|------------------------|
http://127.0.0.1:63623

But the problem occurs in the Ingress object. The minikube ingress generates the endpoint and host domain.

enter image description here

I type in the domain mapping hostname in windows 10 host file

192.168.49.2       boot.aaa.com

But I can not receive any response from nginx conatiner.

http://boot.aaa.com/path

The above URL does not work at all. Any reply will be welcomed. Best Regards.

CodePudding user response:

When you try to access http://boot.aaa.com/path - do you provide the port on whitch it listens ? From what I see from the output of:

minikube service -n ingress-nginx app-nginx-svc --url
* app-nginx-svc 서비스의 터널을 시작하는 중
|--------------------|---------------|-------------|------------------------|
|   NAMESPACE        |      NAME     | TARGET PORT |          URL           |
|--------------------|---------------|-------------|------------------------|
|  ingress-nginx     | app-nginx-svc |             | http://127.0.0.1:63623 |
|--------------------|---------------|-------------|------------------------|
==> http://127.0.0.1:63623 <==

I think that you need to make request on: http://boot.aaa.com:63623/path

If you don't want to use hostname in you Ingress, just remove it from manifest.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
  namespace: ingress-nginx
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
    kubernetes.io/ingress.class: 'nginx'
    nginx.ingress.kubernetes.io/default-backend: app-nginx-svc
spec:
  rules:
    - http:
        paths:
          - path: /path
            pathType: Prefix
            backend:
              service:
                name: app-nginx-svc
                port:
                  number: 80

You should be able then to access your pod by only http://{IP}:{PORT}/path

My additional questions:

  • Are you trying to make request from the same OS where the minikube is installed?
  • Is the hostfile edited on the OS you are making requests from?
  • If yes, is the Windows firewall turned on?

Also, I see that you Service expose a NodePort directly to your App on port 30000. ( It will not pass throught Ingress controller ). Usually if we are setting up an Ingress endpoint to a Pod, we do it to avoid exposing it directly by the NodePort. Using ClusterIP service type will do so.

apiVersion: v1
kind: Service
metadata:
  name: app-nginx-svc
  namespace: ingress-nginx
spec:
  type: ClusterIP
  selector:
    app: test-nginx  
  ports:
  - name: http
    port: 80
    targetPort: 80

  • Related