Kubernetes Dashboard & Ingress on Docker Desktop

3/22/2021

I am trying to access kubernetes dashboard on my local PC through Ingress. The steps I've done so far are: 1. Install Nginx Ingress by:

    kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.44.0/deploy/static/provider/cloud/deploy.yaml

PS D:\dev\kubernetes-dashboard-ingress> kubectl get all -n ingress-nginx
NAME                                            READY   STATUS      RESTARTS   AGE
pod/ingress-nginx-admission-create-7rzdl        0/1     Completed   0          148m
pod/ingress-nginx-admission-patch-295pf         0/1     Completed   0          148m
pod/ingress-nginx-controller-7fc74cf778-jz6ts   1/1     Running     0          148m

NAME                                         TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
service/ingress-nginx-controller             LoadBalancer   10.106.183.115   localhost     80:30673/TCP,443:32591/TCP   148m
service/ingress-nginx-controller-admission   ClusterIP      10.103.188.122   <none>        443/TCP                      148m

NAME                                       READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/ingress-nginx-controller   1/1     1            1           148m

NAME                                                  DESIRED   CURRENT   READY   AGE
replicaset.apps/ingress-nginx-controller-7fc74cf778   1         1         1       148m

NAME                                       COMPLETIONS   DURATION   AGE
job.batch/ingress-nginx-admission-create   1/1           16s        148m
job.batch/ingress-nginx-admission-patch    1/1           16s        148m
  1. Install kubernetes dashboard:
   kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml

When I inspect kubernetes dashboard namespace, I notice that the service is running on port 443:

PS D:\dev\kubernetes-dashboard-ingress> kubectl  get service -n kubernetes-dashboard -o wide
NAME                        TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE    SELECTOR
dashboard-metrics-scraper   ClusterIP   10.110.109.6     <none>        8000/TCP   135m   k8s-app=dashboard-metrics-scraper
kubernetes-dashboard        ClusterIP   10.110.230.166   <none>        443/TCP    135m   k8s-app=kubernetes-dashboard

So I created Ingress rule:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: dashboard-ingress
  namespace: kubernetes-dashboard
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/ssl-passthrough: "true"
    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
spec:
  rules:
  - host: "my-dashboard.com"
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: kubernetes-dashboard
            port: 
              number: 443

and after applying this rule:

PS D:\dev\kubernetes-dashboard-ingress> kubectl  get ingress -n kubernetes-dashboard -o wide
Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
NAME                CLASS    HOSTS                ADDRESS     PORTS   AGE
dashboard-ingress   <none>   my-dashboard.com   localhost   80      121m

I just add the following entry in my windows host file:

127.0.0.1 my-dashboard.com

However, I am getting nothing when I tried to access the dashboard through my browser (http://my-dashboard.com). Have I missed anything?

I was following the tutorial here: https://www.youtube.com/watch?v=X48VuDVv0do. The tutorial was done using minikube - so the dashboard there was available on port 80. Whereas the one i installed directly from github above was available on port 443. Do I need to configure some certificate / secret? I noticed that a few stuffs were created in the Secret by kubernetes-dashboard:

PS D:\dev\kubernetes-dashboard-ingress> kubectl  get secret -n kubernetes-dashboard -o wide
NAME                               TYPE                                  DATA   AGE
default-token-97skl                kubernetes.io/service-account-token   3      140m
kubernetes-dashboard-certs         Opaque                                0      140m
kubernetes-dashboard-csrf          Opaque                                1      140m
kubernetes-dashboard-key-holder    Opaque                                2      140m
kubernetes-dashboard-token-rwgs4   kubernetes.io/service-account-token   3      140m

and if i tried to describe Ingress:

PS D:\dev\kubernetes-dashboard-ingress> kubectl describe ingress  dashboard-ingress -n kubernetes-dashboard
Warning: extensions/v1beta1 Ingress is deprecated in v1.14+, unavailable in v1.22+; use networking.k8s.io/v1 Ingress
Name:             dashboard-ingress
Namespace:        kubernetes-dashboard
Address:          localhost
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
  Host                Path  Backends
  ----                ----  --------
  my-dashboard.com
                      /   kubernetes-dashboard:443 (10.1.0.106:8443)
Annotations:          kubernetes.io/ingress.class: nginx
                      nginx.ingress.kubernetes.io/backend-protocol: HTTPS
                      nginx.ingress.kubernetes.io/ssl-passthrough: true
Events:
  Type    Reason  Age                   From                      Message
  ----    ------  ----                  ----                      -------
  Normal  Sync    7m4s (x10 over 144m)  nginx-ingress-controller  Scheduled for sync

I know I can access the dashboard using kubectl proxy - but I would like to test out Ingress (learning it). Thank you in advance!

I'm running the following:

  • Docker Desktop 3.2.2 (61853)
  • Engine: 20.10.5
  • Compose: 1.28.5
  • Kubernetes: v1.19.7
-- caffeine_inquisitor
docker-desktop
kubernetes
kubernetes-ingress
nginx-ingress

2 Answers

3/22/2021

Your service name seems to be wrong:

You listed your services:

PS D:\dev\kubernetes-dashboard-ingress> kubectl  get service -n kubernetes-dashboard -o wide
NAME                        TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE    SELECTOR
dashboard-metrics-scraper   ClusterIP   10.110.109.6     <none>        8000/TCP   135m   k8s-app=dashboard-metrics-scraper
kubernetes-dashboard        ClusterIP   10.110.230.166   <none>        443/TCP    135m   k8s-app=kubernetes-dashboard

In your ingress:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: dashboard-ingress
  namespace: kubernetes-dashboard
  annotations:
    nginx.ingress.kubernetes.io/ssl-passthrough: "true"
    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
spec:
  rules:
  - host: "my-dashboard.com"
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: my-dashboard  # <<< This line should be kubernetes-dashboard
            port: 
              number: 443
-- Ghokun
Source: StackOverflow

3/22/2021

Ok. Figured out the issue. My request (in chrome) went through the corporate proxy, and that did not forward the request further to my kubernetes cluster. After adding 'my-dashboard.com' to the no proxy list, I can access it through browser.

Thank you thomas for the pointer !

-- caffeine_inquisitor
Source: StackOverflow