kubernetes / website

Kubernetes website and documentation repo:
https://kubernetes.io
Creative Commons Attribution 4.0 International
4.49k stars 14.42k forks source link

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

Open RajaniCode opened 1 year ago

RajaniCode commented 1 year ago

"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.
sftim commented 1 year ago

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

sftim commented 1 year ago

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)

aj11anuj commented 1 year ago

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

capt4ce commented 1 year ago

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

tim1e9 commented 10 months ago

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:

Some notes:

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.

k8s-triage-robot commented 7 months ago

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

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

You can:

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

/lifecycle stale

sftim commented 6 months ago

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

k8s-ci-robot commented 6 months ago

@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-2054058167): >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](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
sftim commented 6 months ago

/remove-priority awaiting-more-evidence