Skip to main content

To install the Kubernetes dashboard and set up HTTPS access, you can follow these steps:

To install the Kubernetes dashboard and set up HTTPS access, you can follow these steps:

1. Install the Kubernetes dashboard by running the following command:
   ```
   microk8s enable dashboard
   ```

2. Verify that the dashboard has been successfully installed by checking its status:
   ```
   microk8s kubectl get services -n kube-system
   ```

   Look for a service named `kubernetes-dashboard` in the `kube-system` namespace. Make a note of the port number (usually 443) associated with the service.

3. Generate a self-signed SSL certificate for HTTPS access. Run the following commands to create a directory for the certificates and generate the certificate:
   ```
   sudo mkdir /var/snap/microk8s/current/certs
   sudo microk8s kubectl create secret generic kubernetes-dashboard-certs --from-file=/var/snap/microk8s/current/certs -n kube-system
   ```

4. Access the dashboard with HTTPS by creating a proxy using the `kubectl` command. Replace `<port>` with the port number noted from step 2:
   ```
   microk8s kubectl proxy --port=<port> --address='0.0.0.0' --accept-hosts='.*'
   ```

5. Open a web browser and navigate to `https://localhost:<port>/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/`. Replace `<port>` with the same port number used in step 4.

6. You will encounter a security warning due to the self-signed certificate. Accept the warning and proceed to access the Kubernetes dashboard.

Please note that using a self-signed certificate poses security risks, and it's recommended to use a valid SSL certificate from a trusted certificate authority for production environments.