skip to Main Content

I am following this official k8 ingress tutorial. However I am not able to curl the minikube IP address and access the "web" application.

minikube addons enable ingress
kubectl create deployment web --image=gcr.io/google-samples/hello-app:1.0
kubectl expose deployment web --type=NodePort --port=8080
kubectl apply -f https://k8s.io/examples/service/networking/example-ingress.yaml

I’m able to curl the result of minikube service web --url

    curl http://127.0.0.1:64671 
    Hello, world!
    Version: 1.0.0
    Hostname: web-79d88c97d6-8z8tc 

But not though ingress, with kubectl apply -f https://k8s.io/examples/service/networking/example-ingress.yaml

(I don’t have an external IP – just "localhost". )

NGG282 kubernetes-ingress % kubectl get ingress
NAME              CLASS   HOSTS   ADDRESS     PORTS   AGE
example-ingress   nginx   *       localhost   80      66m

This seems to be normal with minikube. Trying to curl the minikube IP:

curl $(minikube ip)
curl: (7) Failed to connect to 192.168.49.2 port 80: Operation timed out

Any help?

———-EDIT :

kubectl get deploy -n ingress-nginx -o yaml

          ports:
          - containerPort: 80
            hostPort: 80
            name: http
            protocol: TCP
          - containerPort: 443
            hostPort: 443
            name: https
            protocol: TCP
          - containerPort: 8443
            name: webhook
            protocol: TCP

kubectl get svc -n ingress-nginx -o yaml
apiVersion: v1
items:
- apiVersion: v1
  kind: Service
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app.kubernetes.io/component":"controller","app.kubernetes.io/instance":"ingress-nginx","app.kubernetes.io/name":"ingress-nginx"},"name":"ingress-nginx-controller","namespace":"ingress-nginx"},"spec":{"ipFamilies":["IPv4"],"ipFamilyPolicy":"SingleStack","ports":[{"appProtocol":"http","name":"http","port":80,"protocol":"TCP","targetPort":"http"},{"appProtocol":"https","name":"https","port":443,"protocol":"TCP","targetPort":"https"}],"selector":{"app.kubernetes.io/component":"controller","app.kubernetes.io/instance":"ingress-nginx","app.kubernetes.io/name":"ingress-nginx"},"type":"NodePort"}}
    creationTimestamp: "2021-12-16T11:41:35Z"
    labels:
      app.kubernetes.io/component: controller
      app.kubernetes.io/instance: ingress-nginx
      app.kubernetes.io/name: ingress-nginx
    name: ingress-nginx-controller
    namespace: ingress-nginx
    resourceVersion: "489"
    uid: 63826bc2-5d90-42f1-861f-f7f082ccf0fb
  spec:
    clusterIP: 10.104.208.171
    clusterIPs:
    - 10.104.208.171
    externalTrafficPolicy: Cluster
    internalTrafficPolicy: Cluster
    ipFamilies:
    - IPv4
    ipFamilyPolicy: SingleStack
    ports:
    - appProtocol: http
      name: http
      nodePort: 30783
      port: 80
      protocol: TCP
      targetPort: http
    - appProtocol: https
      name: https
      nodePort: 30860
      port: 443
      protocol: TCP
      targetPort: https
    selector:
      app.kubernetes.io/component: controller
      app.kubernetes.io/instance: ingress-nginx
      app.kubernetes.io/name: ingress-nginx
    sessionAffinity: None
    type: NodePort
  status:
    loadBalancer: {}
- apiVersion: v1
  kind: Service
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app.kubernetes.io/component":"controller","app.kubernetes.io/instance":"ingress-nginx","app.kubernetes.io/name":"ingress-nginx"},"name":"ingress-nginx-controller-admission","namespace":"ingress-nginx"},"spec":{"ports":[{"appProtocol":"https","name":"https-webhook","port":443,"targetPort":"webhook"}],"selector":{"app.kubernetes.io/component":"controller","app.kubernetes.io/instance":"ingress-nginx","app.kubernetes.io/name":"ingress-nginx"},"type":"ClusterIP"}}
    creationTimestamp: "2021-12-16T11:41:35Z"
    labels:
      app.kubernetes.io/component: controller
      app.kubernetes.io/instance: ingress-nginx
      app.kubernetes.io/name: ingress-nginx
    name: ingress-nginx-controller-admission
    namespace: ingress-nginx
    resourceVersion: "483"
    uid: fe797532-27c9-4dd1-a1bc-0662a3d2a4da
  spec:
    clusterIP: 10.106.175.35
    clusterIPs:
    - 10.106.175.35
    internalTrafficPolicy: Cluster
    ipFamilies:
    - IPv4
    ipFamilyPolicy: SingleStack
    ports:
    - appProtocol: https
      name: https-webhook
      port: 443
      protocol: TCP
      targetPort: webhook
    selector:
      app.kubernetes.io/component: controller
      app.kubernetes.io/instance: ingress-nginx
      app.kubernetes.io/name: ingress-nginx
    sessionAffinity: None
    type: ClusterIP
  status:
    loadBalancer: {}
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

2

Answers


  1. Chosen as BEST ANSWER

    OK so apparently this is a known issue with minikube, Ingress works properly on linux only.

    The ingress, and ingress-dns addons are currently only supported on Linux. See #7332

    you need to minikube tunnel on windows/macOS before being able to curl, but still there are differences:

    On Windows, both 127.0.0.1 and localhost redirect to the application. On macOS, 127.0.0.1 and localhost show an "nginX not found" message, but curl hello-world.info works only after changing etc/hosts.


  2. You need to setup your /etc/hosts, I guess the ingress controller wait for requests with an host defined to redirect them, but it’s pretty strange that it didn’t even respond to the http request with an error.

    Could you show what these commands returns ?

    kubectl get deploy -n ingress-nginx -o yaml  # only the ports section
    kubectl get svc -n ingress-nginx -o yaml
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search