ThomasVitale / cloud-native-spring-in-action

🍃 Code samples and projects from the book "Cloud Native Spring in Action - With Spring Boot and Kubernetes" (Manning)
https://www.manning.com/books/cloud-native-spring-in-action
Apache License 2.0
426 stars 257 forks source link

Chapter 9 minikube addons enable ingress failure in China #52

Closed ongiant closed 10 months ago

ongiant commented 1 year ago

Hi, I'm stuck in chapter 9.5.1. When I tried to enable ingress, but always failed.

  1. First, I start a minikube cluster with 2 nodes:
cluster details

➜  ~ minikube start -p polar --nodes 2                                                                                                                       
😄  [polar] minikube v1.30.1 on Arch "23.0.0"                                                                                                                
✨  Automatically selected the docker driver                                                                                                                 
📌  Using Docker driver with root privileges                                                                                                                 
👍  Starting control plane node polar in cluster polar                                                                                                       
🚜  Pulling base image ...                                                                                                                                   
🔥  Creating docker container (CPUs=2, Memory=2200MB) ...                                                                                                    
🐳  Preparing Kubernetes v1.26.3 on Docker 23.0.2 ...                                                                                                        
    ▪ Generating certificates and keys ...                                                                                                                   
    ▪ Booting up control plane ...                                                                                                                           
    ▪ Configuring RBAC rules ...                                                                                                                             
🔗  Configuring CNI (Container Networking Interface) ...                                                                                                     
    ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5                                                                                                 
🌟  Enabled addons: storage-provisioner, default-storageclass                                                                                                
🔎  Verifying Kubernetes components...                                                                                                                       

👍  Starting worker node polar-m02 in cluster polar                                                                                                          
🚜  Pulling base image ...                                                                                                                                   
🔥  Creating docker container (CPUs=2, Memory=2200MB) ...                                                                                                    
🌐  Found network options:                                                                                                                                   
    ▪ NO_PROXY=192.168.49.2                                                                                                                                  
🐳  Preparing Kubernetes v1.26.3 on Docker 23.0.2 ...                                                                                                        
    ▪ env NO_PROXY=192.168.49.2                                                                                                                              
🔎  Verifying Kubernetes components...                                                                                                                       
🏄  Done! kubectl is now configured to use "polar" cluster and "default" namespace by default
  1. Then I tried to enable ingress :

➜  ~ minikube addons enable ingress -p polar
💡  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
    ▪ Using image registry.k8s.io/ingress-nginx/controller:v1.7.0
    ▪ Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20230312-helm-chart-4.5.2-28-g66a760794
    ▪ Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20230312-helm-chart-4.5.2-28-g66a760794
🔎  Verifying ingress addon...

❌  Exiting due to MK_ADDON_ENABLE: enable failed: run callbacks: running callbacks: [waiting for app.kubernetes.io/name=ingress-nginx pods: timed out waiting for the condition]

╭───────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                           │
│    😿  If the above advice does not help, please let us know:                             │
│    👉  https://github.com/kubernetes/minikube/issues/new/choose                           │
│                                                                                           │
│    Please run `minikube logs --file=logs.txt` and attach logs.txt to the GitHub issue.    │
│    Please also attach the following file to the GitHub issue:                             │
│    - /tmp/minikube_addons_ae4fcb4856619e6ac42e679469959984454bfd00_0.log                  │
│                                                                                           │
╰───────────────────────────────────────────────────────────────────────────────────────────╯

  1. some infomation (These are all collapsible code blocks, you can expand by clicking them):
    • kubectl get pods -A
      
      ➜  ~ kubectl get pods -A                                                      
      NAMESPACE       NAME                                        READY   STATUS              RESTARTS      AGE
      ingress-nginx   ingress-nginx-admission-create-wkf7d        0/1     ImagePullBackOff    0             16m
      ingress-nginx   ingress-nginx-admission-patch-2pqg8         0/1     ImagePullBackOff    0             16m
      ingress-nginx   ingress-nginx-controller-6cc5ccb977-q2w47   0/1     ContainerCreating   0             16m
      kube-system     coredns-787d4945fb-xjw4m                    1/1     Running             2 (16m ago)   17m
      kube-system     etcd-polar                                  1/1     Running             0             17m
      kube-system     kindnet-96ksk                               1/1     Running             0             17m
      kube-system     kindnet-q8vlj                               1/1     Running             0             17m
      kube-system     kube-apiserver-polar                        1/1     Running             0             17m
      kube-system     kube-controller-manager-polar               1/1     Running             0             17m
      kube-system     kube-proxy-5l2zn                            1/1     Running             0             17m
      kube-system     kube-proxy-ng6q8                            1/1     Running             0             17m
      kube-system     kube-scheduler-polar                        1/1     Running             0             17m
      kube-system     storage-provisioner                         1/1     Running             1 (17m ago)   17m
      
  1. log file:

    minikube logs --file=logs.txt

logs.txt

abel533 commented 1 year ago

China is unable to download images from registry.k8s.io. You can use a github codespace to download them from here, then upload to your own dockerhub, and download these images locally from dockerhub. Change them to the corresponding names with docker tag and try again.

ongiant commented 1 year ago

China is unable to download images from registry.k8s.io. You can use a github codespace to download them from here, then upload to your own dockerhub, and download these images locally from dockerhub. Change them to the corresponding names with docker tag and try again.

Thanks for your answer, But I have configed a proxy on my local machine and downloaded the image. Afterwards, I used minikube image load command to load the image and attempted to enable ingress, but it still failed. Could there be an issue with my image name and tag?

➜  ~ docker images
REPOSITORY                                           TAG                                        IMAGE ID       CREATED        SIZE
paketobuildpacks/run                                 base-cnb                                   f2e5000af0cb   2 weeks ago    87MB
registry.k8s.io/ingress-nginx/kube-webhook-certgen   v20230407                                  7e7451bb7042   3 months ago   47.2MB
kicbase/stable                                       v0.0.39                                    67a4b1138d2d   3 months ago   1.05GB
gcr.io/k8s-minikube/kicbase                          v0.0.39                                    67a4b1138d2d   3 months ago   1.05GB
registry.k8s.io/ingress-nginx/controller             v1.7.0                                     0d4c0564c465   3 months ago   283MB
registry.k8s.io/ingress-nginx/kube-webhook-certgen   v20230312-helm-chart-4.5.2-28-g66a760794   5a86b03a88d2   4 months ago   47.1MB
edge-service                                         latest                                     068862751604   43 years ago   297MB
config-service                                       latest                                     9ccc5cc0068a   43 years ago   289MB
order-service                                        latest                                     b91d8d94ccb3   43 years ago   298MB
paketobuildpacks/builder                             base                                       99ec7fb86b9d   43 years ago   1.34GB
catalog-service                                      latest                                     595998cf4202   43 years ago   293MB
ongiant commented 1 year ago

I solved it by changing the image registry. However, I had to set .spec.template.spec.hostNetwork: to true (see:https://github.com/kubernetes/minikube/issues/16828#issuecomment-1716160177 ) in the Deployment of ingress-nginx-controller in order for ingress-nginx-controller to work properly. I would like to know why it can work correctly just by using the minikube addons enable ingress command as mentioned in the book.

ThomasVitale commented 10 months ago

@ongiant thanks for reporting the issue and for sharing a working solution. I have now included a guide for configuring Minikube behind a proxy and linked to your instructions to make the ingress work. Thank you!

I'm closing this issue for now, but feel free to leave new comments in case you find new information about this problem, or open a new issue. It looks like there's some problem in the specific ingress add-on in Minikube, so I hope that will be fixed in the Minikube project to make the setup easier when behind a proxy.