website icon indicating copy to clipboard operation
website copied to clipboard

Trouble following tutorial "Set up Ingress on Minikube with the NGINX Ingress Controller"

Open RajaniCode opened this issue 2 years ago β€’ 11 comments

"Create an Ingress" is not working. Maintainer edit: see https://github.com/kubernetes/website/issues/43673#issuecomment-1873049333

Part A: Verify that the Ingress controller is directing traffic is not working. Part B: Add external IP address as reported by minikube is not working. Also, Tried creating minikube tunnel for service example-ingress in vain.

Please refer to the terminal output(s) for details:

Terminal Output 1 Part A - Verify that the Ingress controller is directing traffic

Last login: Tue Oct 24 19:11:06 on console
rajaniapple@Rajanis-MacBook-Pro ~ % sw_vers                                                                               
ProductName:		macOS
ProductVersion:		14.0
BuildVersion:		23A344
rajaniapple@Rajanis-MacBook-Pro ~ % arch                                                                                  
arm64
rajaniapple@Rajanis-MacBook-Pro ~ % pwd                                                      
/Users/rajaniapple
rajaniapple@Rajanis-MacBook-Pro ~ % cd /Users/rajaniapple/Desktop/Working/Technology/Kubernetes/Proof-of-Concept/minikube 
rajaniapple@Rajanis-MacBook-Pro minikube % pwd                                                                                   
/Users/rajaniapple/Desktop/Working/Technology/Kubernetes/Proof-of-Concept/minikube
rajaniapple@Rajanis-MacBook-Pro minikube % docker version
Client:
 Cloud integration: v1.0.35
 Version:           24.0.2
 API version:       1.43
 Go version:        go1.20.4
 Git commit:        cb74dfc
 Built:             Thu May 25 21:51:16 2023
 OS/Arch:           darwin/arm64
 Context:           desktop-linux

Server: Docker Desktop 4.21.1 (114176)
 Engine:
  Version:          24.0.2
  API version:      1.43 (minimum version 1.12)
  Go version:       go1.20.4
  Git commit:       659604f
  Built:            Thu May 25 21:50:59 2023
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.21
  GitCommit:        3dce8eb055cbb6872793272b4f20ed16117344f8
 runc:
  Version:          1.1.7
  GitCommit:        v1.1.7-0-g860f061
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
rajaniapple@Rajanis-MacBook-Pro minikube % kubectl version --output=yaml
clientVersion:
  buildDate: "2023-10-18T11:33:16Z"
  compiler: gc
  gitCommit: a8a1abc25cad87333840cd7d54be2efaf31a3177
  gitTreeState: clean
  gitVersion: v1.28.3
  goVersion: go1.20.10
  major: "1"
  minor: "28"
  platform: darwin/arm64
kustomizeVersion: v5.0.4-0.20230601165947-6ce0bf390ce3

The connection to the server localhost:8080 was refused - did you specify the right host or port?
rajaniapple@Rajanis-MacBook-Pro minikube % kubectl config view
apiVersion: v1
clusters: null
contexts: null
current-context: ""
kind: Config
preferences: {}
users: null
rajaniapple@Rajanis-MacBook-Pro minikube % minikube version
minikube version: v1.31.2
commit: fd7ecd9c4599bef9f04c0986c4a0187f98a4396e
rajaniapple@Rajanis-MacBook-Pro minikube % minikube start
πŸ˜„  minikube v1.31.2 on Darwin 14.0 (arm64)
✨  Automatically selected the docker driver
πŸ“Œ  Using Docker Desktop driver with root privileges
πŸ‘  Starting control plane node minikube in cluster minikube
🚜  Pulling base image ...
πŸ’Ύ  Downloading Kubernetes v1.27.4 preload ...
    > preloaded-images-k8s-v18-v1...:  327.74 MiB / 327.74 MiB  100.00% 2.23 Mi
    > gcr.io/k8s-minikube/kicbase...:  404.50 MiB / 404.50 MiB  100.00% 2.57 Mi
πŸ”₯  Creating docker container (CPUs=2, Memory=4000MB) ...
🐳  Preparing Kubernetes v1.27.4 on Docker 24.0.4 ...
    β–ͺ Generating certificates and keys ...
    β–ͺ Booting up control plane ...
    β–ͺ Configuring RBAC rules ...
πŸ”—  Configuring bridge CNI (Container Networking Interface) ...
πŸ”Ž  Verifying Kubernetes components...
    β–ͺ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🌟  Enabled addons: storage-provisioner, default-storageclass
πŸ„  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
rajaniapple@Rajanis-MacBook-Pro minikube % minikube addons enable ingress
πŸ’‘  ingress is an addon maintained by Kubernetes. For any concerns contact minikube on GitHub.
You can view the list of minikube maintainers at: https://github.com/kubernetes/minikube/blob/master/OWNERS
πŸ’‘  After the addon is enabled, please run "minikube tunnel" and your ingress resources would be available at "127.0.0.1"
    β–ͺ Using image registry.k8s.io/ingress-nginx/controller:v1.8.1
    β–ͺ Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20230407
    β–ͺ Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20230407
πŸ”Ž  Verifying ingress addon...
🌟  The 'ingress' addon is enabled
rajaniapple@Rajanis-MacBook-Pro minikube % kubectl get pods -n ingress-nginx
NAME                                        READY   STATUS      RESTARTS   AGE
ingress-nginx-admission-create-v4vnj        0/1     Completed   0          46s
ingress-nginx-admission-patch-dw4xw         0/1     Completed   0          46s
ingress-nginx-controller-7799c6795f-7fb9w   0/1     Running     0          46s
rajaniapple@Rajanis-MacBook-Pro minikube % kubectl create deployment web --image=gcr.io/google-samples/hello-app:1.0
deployment.apps/web created
rajaniapple@Rajanis-MacBook-Pro minikube % kubectl expose deployment web --type=NodePort --port=8080
service/web exposed
rajaniapple@Rajanis-MacBook-Pro minikube % kubectl get service web
NAME   TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
web    NodePort   10.98.92.201   <none>        8080:31242/TCP   30s
rajaniapple@Rajanis-MacBook-Pro minikube % minikube service web --url
http://127.0.0.1:49557
❗  Because you are using a Docker driver on darwin, the terminal needs to be open to run it.
^C%                                                                                                                                                             
rajaniapple@Rajanis-MacBook-Pro minikube % wget https://k8s.io/examples/service/networking/example-ingress.yaml
--2023-10-24 19:39:16--  https://k8s.io/examples/service/networking/example-ingress.yaml
Resolving k8s.io (k8s.io)... 34.107.204.206
Connecting to k8s.io (k8s.io)|34.107.204.206|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://kubernetes.io/examples/service/networking/example-ingress.yaml [following]
--2023-10-24 19:39:17--  https://kubernetes.io/examples/service/networking/example-ingress.yaml
Resolving kubernetes.io (kubernetes.io)... 147.75.40.148
Connecting to kubernetes.io (kubernetes.io)|147.75.40.148|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 390 [application/x-yaml]
Saving to: β€˜example-ingress.yaml’

example-ingress.yaml                    100%[===============================================================================>]     390  --.-KB/s    in 0s      

2023-10-24 19:39:18 (372 MB/s) - β€˜example-ingress.yaml’ saved [390/390]

rajaniapple@Rajanis-MacBook-Pro minikube % cat example-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: example-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
    - host: hello-world.info
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: web
                port:
                  number: 8080%                                                                                                                                 rajaniapple@Rajanis-MacBook-Pro minikube % kubectl apply -f example-ingress.yaml
ingress.networking.k8s.io/example-ingress created
rajaniapple@Rajanis-MacBook-Pro minikube % kubectl get ingress
NAME              CLASS   HOSTS              ADDRESS        PORTS   AGE
example-ingress   nginx   hello-world.info   192.168.49.2   80      58s
rajaniapple@Rajanis-MacBook-Pro minikube % curl --resolve "hello-world.info:80:$( minikube ip )" -i http://hello-world.info
curl: (28) Failed to connect to hello-world.info port 80 after 75000 ms: Couldn't connect to server
rajaniapple@Rajanis-MacBook-Pro minikube % 

Terminal Output 1 Part B - Add external IP address as reported by minikube

rajaniapple@Rajanis-MacBook-Pro minikube % sudo vim /etc/hosts
Password:
rajaniapple@Rajanis-MacBook-Pro minikube % cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
172.17.0.15 hello-world.info
# End of section
rajaniapple@Rajanis-MacBook-Pro minikube % open http://hello-world.info/
rajaniapple@Rajanis-MacBook-Pro minikube % curl http://hello-world.info/
curl: (28) Failed to connect to hello-world.info port 80 after 75010 ms: Couldn't connect to server
rajaniapple@Rajanis-MacBook-Pro minikube %

Terminal Output 2: - Created minikube tunnel for service example-ingress in vain

Last login: Tue Oct 24 19:14:56 on ttys000
rajaniapple@Rajanis-MacBook-Pro ~ % curl http://127.0.0.1:49557
Hello, world!
Version: 1.0.0
Hostname: web-548f6458b5-gqllc
rajaniapple@Rajanis-MacBook-Pro ~ % sudo minikube tunnel
Password:
βœ…  Tunnel successfully started

πŸ“Œ  NOTE: Please do not close this terminal as this process must stay alive for the tunnel to be accessible ...

❗  The service/ingress example-ingress requires privileged ports to be exposed: [80 443]
πŸ”‘  sudo permission will be asked for it.
πŸƒ  Starting tunnel for service example-ingress.

RajaniCode avatar Oct 24 '23 14:10 RajaniCode

/retitle Trouble following tutorial "Set up Ingress on Minikube with the NGINX Ingress Controller"

sftim avatar Oct 24 '23 14:10 sftim

Please refer to the terminal output(s) for details:

It sounds like what you're asking for is a volunteer to read what's there and solve a little puzzle about what is wrong. If you're willing to explain that, then the other contributors in this SIG do not need to become detectives - and will thank you for the extra hint @RajaniCode.

(you might not have realized that the people triaging this issue are volunteers, but that's the truth of it for a very large proportion of our contributors)

sftim avatar Oct 24 '23 16:10 sftim

More clear explanation of what's wrong and what needs to be fixed in precise format will be very helpful, if you can provide it. /triage needs-information /priority awaiting-more-evidence

aj11anuj avatar Oct 25 '23 01:10 aj11anuj

I faced the same issue as @RajaniCode. Here's some information from my side:

  • without the tunnel, the curl command to resolve the host also timed out as describe by @RajaniCode
  • after starting the tunnel, executing commant curl 127.0.0.1 gives me Nginx's 404 Not Found page. It means now I can connect the nginx but the nginx failed to proxy the request to the backend server

capt4ce avatar Nov 07 '23 02:11 capt4ce

Oh boy, this documentation needs help. Hopefully this comment will make it fairly easy for the volunteers to make the necessary updates.

Here's how I got it to work for me:

  • In the section titled Create Ingress, there needs to be something else after step 3. Specifically, the tunnel needs to be started. I opened a new terminal and typed: sudo minikube tunnel.
  • Update your local hosts file to resolve hello-world.info to 127.0.0.1 (This is an optional step - see below)
  • Go back to the original terminal, and change step 4 to be as follows: curl http://hello-world.info
  • You should now see the following output:
Hello, world!
Version: 1.0.0
Hostname: web-<somelongnumber>

Some notes:

  • The following curl command will work without updating the hosts file:
curl --resolve "hello-world.info:80:127.0.0.1" -i http://hello-world.info
  • None of the following will work:
curl http://127.0.0.1
curl localhost
curl http://localhost
curl --resolve "hello-world.info:80:$( minikube ip )" -i http://hello-world.info

I am using an M1 Mac with Docker, so this may be why the minikube ip command won't work. Nonetheless, this is a fairly standard developer platform so I'm surprised none of the documentation testers were able to get this page to work on their machines.

It still confuses me why I need to use a tunnel with an Ingress, but I suppose that's another story for another day...

Hope this helps... Tim.

tim1e9 avatar Dec 31 '23 22:12 tim1e9

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Mar 30 '24 23:03 k8s-triage-robot

https://github.com/kubernetes/website/issues/43673#issuecomment-1873049333 is helpful /remove-triage needs-information /remove-lifecycle stale /remove-priority awaitring-more-evidence /triage accepted /priority backlog

sftim avatar Apr 14 '24 13:04 sftim

@sftim: Those labels are not set on the issue: priority/awaitring-more-evidence

In response to this:

https://github.com/kubernetes/website/issues/43673#issuecomment-1873049333 is helpful /remove-triage needs-information /remove-lifecycle stale /remove-priority awaitring-more-evidence /triage accepted /priority backlog

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Apr 14 '24 13:04 k8s-ci-robot

/remove-priority awaiting-more-evidence

sftim avatar Apr 14 '24 13:04 sftim

Thanks @tim1e9, your comment was super useful! The only other thing I had to do (being on M1 mac: arm64 architecture), was to use for a web app an image that has arm architecture (e.g. https://github.com/Ealenn/Echo-Server kubectl create deployment web --image=ghcr.io/ealen/echo-server) as the tutorial specifies google-samples/hello-app which is only provided in amd64.

edit: Actually it didn't work even with @tim1e9 -suggested corrections - I thought I'm getting something but I was in fact seeing response of the actual website hello-world.info, not my cluster!

I have finally managed to get the basics to work by creating the service as in tutorial from https://devopscube.com/minikube-mac/:

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Service
metadata:
  name: web-service
spec:
  ports:
  - name: http
    port: 80
  selector:
    app: web
  type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web-deployment
spec:
  replicas: 2
  selector:
    matchLabels:
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
      - image: nginx:1.14.2
        name: nginx
        ports:
        - containerPort: 80
EOF

Seems networking on macos are something else. :(

mixmixmix avatar Jan 15 '25 16:01 mixmixmix

This issue has not been updated in over 1 year, and should be re-triaged.

You can:

  • Confirm that this issue is still relevant with /triage accepted (org members only)
  • Close this issue with /close

For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/

/remove-triage accepted

k8s-triage-robot avatar Jan 15 '26 17:01 k8s-triage-robot

Let's drop that tutorial; we should boost Gateway over Ingress.

lmktfy avatar Jan 18 '26 09:01 lmktfy