Wondering how to install Kubernetes Dashboard with NodePort? We can help you.
As part of our Google Cloud Platform Services, we assist our customers with several Kubernetes queries.
Today, let us see how our Support Techs perform the installation for our customers.
Install Kubernetes Dashboard with NodePort
A web-based user interface, Kubernetes provides information on the state of the Kubernetes cluster resources and any errors that may occur.
Moving ahead, let us see the steps our Support Techs employ for a smooth installation.
Step 1: Configure kubectl
To deploy the dashboard to the Kubernetes cluster, we use the kubectl Kubernetes management tool.
Step 2: Deploy Kubernetes Dashboard
By default, the dashboard deployment contains a minimal set of RBAC privileges it needs to run.
To deploy the Kubernetes dashboard, we run:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended.yaml
After that, we need to set Service to use NodePort.
To modify the file, we have to download it to the local machine:
wget https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended.yaml-O kubernetes-dashboard-deployment.yml
Now, we can modify the file to fit the deployment needs.
vim kubernetes-dashboard-deployment.yml
For example, here we modify the Kubernetes dashboard service to be of NodePort type:
kind: Service apiVersion: v1 metadata: labels: k8s-app: kubernetes-dashboard name: kubernetes-dashboard namespace: kubernetes-dashboard spec: ports: - port: 443 targetPort: 8443 selector: k8s-app: kubernetes-dashboard type: NodePort
Later, to specify NodePort, we use:
kind: Service apiVersion: v1 metadata: labels: k8s-app: kubernetes-dashboard name: kubernetes-dashboard namespace: kubernetes-dashboard spec: ports: - port: 443 targetPort: 8443 nodePort: 32000 type: NodePort selector: k8s-app: kubernetes-dashboard
Once done, we need to apply the changes:
kubectl apply -f kubernetes-dashboard-deployment.yml
Then we go ahead and check the deployment status:
$ kubectl get deployments -n kubernetes-dashboard NAME READY UP-TO-DATE AVAILABLE AGE dashboard-metrics-scraper 1/1 1 1 86s kubernetes-dashboard 1/1 1 1
It should create two pods, one for the dashboard and another for metrics.
$ kubectl get pods -n kubernetes-dashboard NAME READY STATUS RESTARTS AGE dashboard-metrics-scraper-7b64584c5c-xvtqp 1/1 Running 0 2m4s kubernetes-dashboard-566f567dc7-w59rn 1/1 Running 0 2m4s
Since we made the service type to NodePort, let’s confirm its creation:
$ kubectl get service -n kubernetes-dashboard NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE dashboard-metrics-scraper ClusterIP 10.103.159.77 <none> 8000/TCP 8m40s kubernetes-dashboard NodePort 10.101.194.22 <none> 443:32000/TCP 8m40s
Step 3: Access Kubernetes Dashboard
Suppose, the Service deployment was assigned a port 32000/TCP.
# Example https://xxx.xxx.xxx.xx:32000
Now, we need to confirm if access to the dashboard is working.
To do so, we need a token to access the dashboard.
Then we will see a web dashboard.
Nginx Ingress:
--- apiVersion: extensions/v1beta1 kind: Ingress metadata: name: k8s-dashboard namespace: kubernetes-dashboard annotations: nginx.ingress.kubernetes.io/secure-backends: "true" nginx.ingress.kubernetes.io/ssl-passthrough: "true" spec: tls: - hosts: - k8sdash.mydomain.com secretName: tls-secret rules: - host: k8sdash.mydomain.com http: paths: - path: / backend: serviceName: kubernetes-dashboard servicePort: 443
[Need further assistance? We’d be happy to help you]
Conclusion
In short, we saw how our Support Techs perform the installation of Kubernetes Dashboard with NodePort.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
0 Comments