{"id":5136,"date":"2018-08-10T11:11:49","date_gmt":"2018-08-10T11:11:49","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/?p=5136"},"modified":"2023-09-28T09:34:55","modified_gmt":"2023-09-28T09:34:55","slug":"how-to-setup-kubernetes-dashboard-in-eks-using-nodeport","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-setup-kubernetes-dashboard-in-eks-using-nodeport\/","title":{"rendered":"How to setup Kubernetes Dashboard in EKS using NodePort?"},"content":{"rendered":"\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">$ kubectl apply -f https:<span class=\"hljs-comment\">\/\/raw.githubusercontent.com\/kubernetes\/dashboard\/v2.7.0\/aio\/deploy\/recommended.yaml<\/span>\r\n$ kubectl patch svc kubernetes-dashboard --type=<span class=\"hljs-string\">'json'<\/span> -p <span class=\"hljs-string\">'&#91;{\"op\":\"replace\",\"path\":\"\/spec\/type\",\"value\":\"NodePort\"}]'<\/span> -n kubernetes-dashboard\r\n$ kubectl -n kube-system describe secret $(kubectl -n kube-system <span class=\"hljs-keyword\">get<\/span> secret | awk '\/^deployment-controller-token-\/{print $<span class=\"hljs-number\">1<\/span>}<span class=\"hljs-string\">') | awk '<\/span>$<span class=\"hljs-number\">1<\/span>==<span class=\"hljs-string\">\"token:\"<\/span>{print $<span class=\"hljs-number\">2<\/span>}<span class=\"hljs-string\">'<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5146\" src=\"http:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2018\/08\/kubernetes.png\" alt=\"\" width=\"600\" height=\"315\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2018\/08\/kubernetes.png 600w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2018\/08\/kubernetes-300x158.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><strong>How to setup Kubernetes Dashboard in EKS using NodePort?<\/strong><\/p>\n<p><strong>Step 1: Deploy the Dashboard<\/strong><br \/># Deploy the Kubernetes dashboard to your cluster:<\/p>\n<p>[code]kubectl apply -f https:\/\/raw.githubusercontent.com\/kubernetes\/dashboard\/master\/src\/deploy\/recommended\/kubernetes-dashboard.yaml[\/code]<\/p>\n<p># Deploy heapster to enable container cluster monitoring and performance analysis on your cluster:<\/p>\n<p>[code]$ kubectl apply -f https:\/\/raw.githubusercontent.com\/kubernetes\/heapster\/master\/deploy\/kube-config\/influxdb\/heapster.yaml[\/code]<\/p>\n<p># Deploy the influxdb backend for heapster to your cluster:<\/p>\n<p>[code]$ kubectl apply -f https:\/\/raw.githubusercontent.com\/kubernetes\/heapster\/master\/deploy\/kube-config\/influxdb\/influxdb.yaml[\/code]<\/p>\n<p># Create the heapster cluster role binding for the dashboard:<\/p>\n<p>[code]$ kubectl apply -f https:\/\/raw.githubusercontent.com\/kubernetes\/heapster\/master\/deploy\/kube-config\/rbac\/heapster-rbac.yaml[\/code]<\/p>\n<p><strong>Step 2: Create an eks-admin Service Account and Cluster Role Binding<\/strong><br \/># Create a file called eks-admin-service-account.yaml with the text below:<\/p>\n<p>[code]<br \/>vi eks-admin-service-account.yaml<br \/>apiVersion: v1<br \/>kind: ServiceAccount<br \/>metadata:<br \/>name: eks-admin<br \/>namespace: kube-system<\/p>\n<p>$ kubectl apply -f eks-admin-service-account.yaml<\/p>\n<p>vi eks-admin-cluster-role-binding.yaml<\/p>\n<p>apiVersion: rbac.authorization.k8s.io\/v1beta1<br \/>kind: ClusterRoleBinding<br \/>metadata:<br \/>name: eks-admin<br \/>roleRef:<br \/>apiGroup: rbac.authorization.k8s.io<br \/>kind: ClusterRole<br \/>name: cluster-admin<br \/>subjects:<br \/>&#8211; kind: ServiceAccount<br \/>name: eks-admin<br \/>namespace: kube-system<\/p>\n<p>$ kubectl apply -f eks-admin-cluster-role-binding.yaml<br \/>[\/code]<\/p>\n<p><strong>Step 3:\u00a0Retrieve an authentication token\u00a0<\/strong><br \/>Retrieve an authentication token for the eks-admin service account. Copy the &lt;authentication_token&gt; value from the output. You use this token to connect to the dashboard.<\/p>\n<p>[code]kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep eks-admin | awk &#8216;{print $1}&#8217;)[\/code]<\/p>\n<p><strong>Step 4: Connect to the Dashboard Via Node Port<\/strong><br \/>Retrieve an authentication token for the eks-admin service account. Copy the &lt;authentication_token&gt; value from the output. You use this token to connect to the dashboard.<\/p>\n<p>[code]<br \/>$ kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep eks-admin | awk &#8216;{print $1}&#8217;)<br \/>$ kubectl get pods &#8211;all-namespaces<br \/>$ kubectl get pods &#8211;namespace=kube-system<br \/>$ kubectl get svc &#8211;all-namespaces<\/p>\n<p>$ kubectl edit svc\/kubernetes-dashboard &#8211;namespace=kube-system<br \/>or<br \/>$ kubectl -n kube-system edit service kubernetes-dashboard<br \/>Just change &#8220;type: NodePort&#8221; only<\/p>\n<p># Please edit the object below. Lines beginning with a &#8216;#&#8217; will be ignored,<br \/># and an empty file will abort the edit. If an error occurs while saving this file will be<br \/># reopened with the relevant failures.<br \/>#<br \/>apiVersion: v1<br \/>kind: Service<br \/>metadata:<br \/>creationTimestamp: 2018-07-27T10:22:50Z<br \/>labels:<br \/>k8s-app: kubernetes-dashboard<br \/>name: kubernetes-dashboard<br \/>namespace: kube-system<br \/>resourceVersion: &#8220;3288196&#8221;<br \/>selfLink: \/api\/v1\/namespaces\/kube-system\/services\/kubernetes-dashboard<br \/>uid: 03f2f747-9187-11e8-9432-02b761c0deac<br \/>spec:<br \/>clusterIP: 10.100.194.75<br \/>externalTrafficPolicy: Cluster<br \/>ports:<br \/>&#8211; nodePort: 30530<br \/>port: 443<br \/>protocol: TCP<br \/>targetPort: 8443<br \/>selector:<br \/>k8s-app: kubernetes-dashboard<br \/>sessionAffinity: None<br \/>type: NodePort<br \/>status:<br \/>loadBalancer: {}<\/p>\n<p>$ kubectl describe pods kubernetes-dashboard-7d5dcdb6d9-mt9b9 &#8211;namespace=kube-system<br \/>#Find which node is running and get a Port of SVC<\/p>\n<p>$ kubectl get svc &#8211;all-namespaces<br \/>$ kubectl get pods &#8211;all-namespaces<br \/>$ kubectl describe pods kubernetes-dashboard-7d5dcdb6d9-h9dcb &#8211;namespace=kube-system<br \/>[\/code]<\/p>\n<p><strong>Step 5: Connect to the Dashboard Via ClustorIP and Proxy<\/strong><br \/>http:\/\/localhost:8001\/api\/v1\/namespaces\/kube-system\/services\/https:kubernetes-dashboard:\/proxy\/<\/p>\n<p>https:\/\/10.16.39.28:30178\/<\/p>\n<p>\u00a0<\/p>\n<p><strong>IMPORTANT &#8211; Kubernetes Dashboard should be HTTPS<\/strong><\/p>\n<p>\u00a0<\/p>\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_74481\"><iframe loading=\"lazy\"  id=\"_ytid_82745\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_74481\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>How to setup Kubernetes Dashboard in EKS using NodePort? Step 1: Deploy the Dashboard# Deploy the Kubernetes dashboard to your cluster: [code]kubectl apply -f https:\/\/raw.githubusercontent.com\/kubernetes\/dashboard\/master\/src\/deploy\/recommended\/kubernetes-dashboard.yaml[\/code] # Deploy heapster to enable&#8230; <\/p>\n","protected":false},"author":1,"featured_media":5146,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[4859],"tags":[439,4940,4860,4992,4993],"class_list":["post-5136","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-kubernetes","tag-dashboard","tag-eks","tag-kubernetes","tag-kubernetes-dashboard","tag-nodeport"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/5136","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=5136"}],"version-history":[{"count":5,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/5136\/revisions"}],"predecessor-version":[{"id":40535,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/5136\/revisions\/40535"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/5146"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=5136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=5136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=5136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}