LAB 13.3 trouble finding token
I followed lab steps and the dashboard page is loading.
Just to mention that other than changing port type to NodePort, I also had to edit values.yaml to enable insecure login
extraArgs: - --enable-insecure-login
or otherwise I was only getting an error page about requesting HTTP website over HTTPS
So, now I am at step 6 but I don't have dashboard-kubernetes-dashboard-token- object.
kubectl get serviceaccounts
NAME SECRETS AGE dashboard-kubernetes-dashboard 0 19m default 1 5d1h myingress-ingress-nginx 0 19h
I noticed that in the lab that SECRETS is 1 for dashboard-kubernetes-dashboard and I get 0...
kubectl get secrets
NAME TYPE DATA AGE dashboard-kubernetes-dashboard-certs Opaque 0 14m default-token-56tsp kubernetes.io/service-account-token 3 5d1h kubernetes-dashboard-csrf Opaque 1 14m kubernetes-dashboard-key-holder Opaque 2 14m myingress-ingress-nginx-admission Opaque 3 19h sh.helm.release.v1.dashboard.v1 helm.sh/release.v1 1 14m sh.helm.release.v1.myingress.v1 helm.sh/release.v1 1 19h
What am I missing?
Thanks in advance
Comments
-
UPDATE
Apparently Kubernetes does not automatically create secrets anymore starting from 1.24
I've tried manually creating a secret for service account, and it seemed to have worked, however when I
kubectl get serviceaccountI still get 0 secrets for dashboard-kubernetes-dashboard although secret is visible when Ikubectl get secretsI also tried creating a token with
kubectl create tokenHowever, I've ran into another issue which is disabled login even with
- --enable-insecure-loginflag set:Insecure access detected. Sign in will not be available. Access Dashboard securely over HTTPS or using localhost. Read more here
0 -
Hi @k0dard,
I can't remember having to enable insecure login, but I did have to enable the integration with the metrics-server around line 257 of values.yaml (the metrics-server was pre-installed on my cluster, otherwise there was an install option in values.yaml as well).
Now back to the token... or the lack of it. Secrets holding service account tokens are no longer created by default, so it becomes the user's responsibility to create the token secret for the desired service account.
The command is simple, from the official documentation:
kubectl apply -f - <<EOF apiVersion: v1 kind: Secret metadata: name: kubernetes-dashboard-token annotations: kubernetes.io/service-account.name: kubernetes-dashboard type: kubernetes.io/service-account-token EOFIt creates a secret name
kubernetes-dashboard-tokenassociated with mykubernetes-dashboardservice account (replace the name if your service account has a different name). You can also create the secret definition manifest first, and then run thekubectl applycommand.Once created, you can describe the secret to reveal the value of the token:
kubectl describe secrets kubernetes-dashboard-tokenRegards,
-Chris0 -
Using imperative commands:
$ kubectl get serviceaccounts -n kubernetes-dashboard NAME SECRETS AGE default 0 10m kubernetes-dashboard 0 9m44s $ kubectl create clusterrolebinding dashaccess --clusterrole=cluster-admin --serviceaccount=kubernetes-dashboard:kubernetes-dashboard clusterrolebinding.rbac.authorization.k8s.io/dashaccess created $ kubectl get clusterrolebinding dashaccess NAME ROLE AGE dashaccess ClusterRole/cluster-admin 9m30s $ curl ifconfig.io 173.28.225.52 $ kubectl -n kubernetes-dashboard create token kubernetes-dashboard
I didn't need
--enable-insecure-loginbut I did need--kubelet-insecure-tls0 -
Thanks for your help!
When you say enable the integration with the metrics-server, do you mean metricsScraper option (line 252 in my values.yaml). Otherwise, there is metric-server option (line 279) but in the comment it is written
Enable this if you don't already have metrics-server enabled on your cluster and want to use it with dashboard metrics-scraper
which is not the case...
To get back to the issue, after some additional testing I've got the following:
- if I don't set protocolHttp to true (line 139), I always get the same error (Client sent an HTTP request to an HTTPS server.)
- if I set protocolHttp to true I can see the metrics without logging in, token or anything
- if I add - --enable-insecure-login I cannot login anymore with or without token, on the bottom of the screen I get Insecure access message mentioned in my OP and Sign in button stays inactive even if I paste a token.
This seems strange, doesn't it?
@headkaze If you read the update I've posted just under my OP you'll see that I've already tried adding token with
kubectl create tokencommand, so I don't really see what was the point of your post? You say you needed--kubelete-insecure-tls, are you referring to the setup of metrics-server?0 -
I make notes when I do a LAB so I'll paste them in here assuming you've already done the
metrics-serverpart correctly.$ helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/ "kubernetes-dashboard" has been added to your repositories $ helm pull kubernetes-dashboard/kubernetes-dashboard $ tar -zxvf kubernetes-dashboard-5.7.0.tgz $ cd kubernetes-dashboard $ nano values.yaml
I did have to enable the
metricsScraperotherwise the dashboard doesn't show any CPU or memory usage etc.... service: type: NodePort # Dashboard service port externalPort: 443 ... metricsScraper: ## Wether to enable dashboard-metrics-scraper enabled: true image: repository: kubernetesui/metrics-scraper tag: v1.0.8 resources: {} ...$ kubectl create ns kubernetes-dashboard namespace/kubernetes-dashboard created $ helm install kubernetes-dashboard --namespace kubernetes-dashboard .
Then I created the cluster role and token (as posted above)
$ kubectl get serviceaccounts -n kubernetes-dashboard NAME SECRETS AGE default 0 10m kubernetes-dashboard 0 9m44s $ kubectl create clusterrolebinding dashaccess --clusterrole=cluster-admin --serviceaccount=kubernetes-dashboard:kubernetes-dashboard clusterrolebinding.rbac.authorization.k8s.io/dashaccess created $ kubectl get clusterrolebinding dashaccess NAME ROLE AGE dashaccess ClusterRole/cluster-admin 9m30s $ curl ifconfig.io 173.28.225.52 $ kubectl -n kubernetes-dashboard create token kubernetes-dashboard
Finally to get the url:
$ export NODE_PORT=$(kubectl get -n kubernetes-dashboard -o jsonpath="{.spec.ports[0].nodePort}" services kubernetes-dashboard) $ export NODE_IP=$(kubectl get nodes -o jsonpath="{.items[0].status.addresses[0].address}") $ echo https://$NODE_IP:$NODE_PORT/In my case I place in my browser
https://mycluster-cp1:31370then it should take you to a login where you paste in your token.0 -
Hi @k0dard,
Yes, I did mean the metricsScraper, which oddly is on a different line in my values.yaml file

As far as https - it is default, just as @headkaze confirmed in his comment. If you have a chance to describe the kubernetes-dashboard service, the ports object defines port number 443 tagged with name=https, which even as a NodePort accepts https traffic.
The protocolHttp behavior makes some sense. When false, it allows the https default protocol, and throws the http request to https server error if the request is http instead of the expected https. When true, it overrides https and accepts http traffic instead.
I have not yet explored the enable-insecure-login so I can't comment on its behavior.
Regards,
-Chris0 -
-
It turns out that my browser, since the SSL certificate is not valid, automatically redirected me to http. If I manually add https:// before my server IP and accept the security risk, the Sign in button becomes active again...
Thanks everyone for your help, I appreciate it!
0
Categories
- All Categories
- 177 LFX Mentorship
- 177 LFX Mentorship: Linux Kernel
- 750 Linux Foundation IT Professional Programs
- 373 Cloud Engineer IT Professional Program
- 169 Advanced Cloud Engineer IT Professional Program
- 74 DevOps IT Professional Program - Discontinued
- 4 DevOps & GitOps IT Professional Program
- 99 Cloud Native Developer IT Professional Program
- 7.6K Training Courses & Learning Paths
- 1 AI & ML Training
- 1 Blockchain & Decentralized Identity Training
- 5 Cloud & Containers Training
- 1 Cybersecurity Training
- 2 DevOps & Site-Reliability Training
- 1 Linux Kernel Development Training
- 1 Networking Training
- 2 Open Source Best Practice Training
- 1 System Administration Training
- 1 System Engineering Training
- 1 Web & Application Development Training
- 792 Hardware
- 202 Drivers
- 68 I/O Devices
- 37 Monitors
- 95 Multimedia
- 173 Networking
- 91 Printers & Scanners
- 87 Storage
- 769 Linux Distributions
- 81 Debian
- 68 Fedora
- 22 Linux Mint
- 13 Mageia
- 24 openSUSE
- 150 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 356 Ubuntu
- 465 Linux System Administration
- 31 Cloud Computing
- 73 Command Line/Scripting
- Github systems admin projects
- 98 Linux Security
- 78 Network Management
- 101 System Management
- 46 Web Management
- 106 Mobile Computing
- 18 Android
- 73 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 392 Off Topic
- 121 Introductions
- 181 Small Talk
- 29 Study Material
- 956 Programming and Development
- 310 Kernel Development
- 628 Software Development
- 984 Software
- 376 Applications
- 182 Command Line
- 5 Compiling/Installing
- 68 Games
- 317 Installation
- Archived
- 2 LFD140 Class Forum
- 1.4K LFS258 Class Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)

