# Installation



# To install MicroK8s on Ubuntu, you can follow these steps

To install MicroK8s on Ubuntu, you can follow these steps:

1\. Open a terminal on your Ubuntu machine.

2\. Update your system's package list by running the following command:

```
 sudo apt update
```

3\. Install MicroK8s using snap, which is a package management system on Ubuntu:

```
sudo snap install microk8s --classic
```

 The `--classic` flag is used to enable classic snap confinement, allowing MicroK8s to access the host system.

4\. After the installation is complete, add your user to the `microk8s` group so that you can run MicroK8s commands without using `sudo`:

```
sudo usermod -a -G microk8s <your-username>
```

 Replace `&lt;your-username&gt;` with your actual username.

5\. To enable required permissions for your user, run the following command:

```
sudo chown -f -R <your-username> ~/.kube
```

6\. You will need to log out and log back in for the group changes to take effect. So, close the terminal and open a new one.

7\. Verify that MicroK8s is up and running by checking the status:

```
microk8s status --wait-ready
```

 This command will wait until all the MicroK8s services are running.

8\. To enable some useful add-ons, you can use the following commands:

```
microk8s enable dns
```

```
microk8s enable hostpath-storage
```

9\. install Kubernetes dashboard, see nect page

# 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 `&lt;port&gt;` 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 `&lt;port&gt;` 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.

# To automatically start the Kubernetes dashboard after booting your Ubuntu machine

To automatically start the Kubernetes dashboard after booting your Ubuntu machine, you can create a systemd service unit. Here's how you can do it:

1\. Open a terminal on your Ubuntu machine.

2\. Create a new systemd service unit file using a text editor. For example, you can use the following command to create the file with the Nano text editor:  
 ```  
 sudo nano /etc/systemd/system/microk8s-dashboard.service  
 ```

3\. Add the following content to the service unit file:  
 ```  
 \[Unit\]  
 Description=MicroK8s Kubernetes Dashboard  
 After=network.target

 \[Service\]  
 ExecStart=/snap/bin/microk8s.kubectl proxy --port=8001 --address='0.0.0.0' --accept-hosts='.\*'  
 Restart=always  
 RestartSec=10

 \[Install\]  
 WantedBy=multi-user.target  
 ```

 This configuration defines a service unit for the Kubernetes dashboard, specifying the command to start the proxy and enabling automatic restarts.

4\. Save the file and exit the text editor. In Nano, you can do this by pressing Ctrl+O, then Enter to save, and Ctrl+X to exit.

5\. Enable the service to start automatically on boot by running the following command:  
 ```  
 sudo systemctl enable microk8s-dashboard  
 ```

6\. Start the service manually for the current session by running:  
 ```  
 sudo systemctl start microk8s-dashboard  
 ```

7\. Verify that the service is running without any errors by checking its status:  
 ```  
 sudo systemctl status microk8s-dashboard  
 ```

 If everything is set up correctly, the status should indicate that the service is active (running).

After following these steps, the Kubernetes dashboard should start automatically after each boot. You can access it from any machine on the network by using the appropriate URL, as mentioned in the previous responses.

# kubectl

sudo snap install kubectl --classic

microk8s.kubectl config view --raw &gt; <span class="hljs-variable">$HOME</span>/.kube/microk8s.config

<span class="hljs-meta">\# add the minik8s cluster to kubectl</span>

<s>-kubectl config set-cluster microk8s-cluster --server=http:<span class="hljs-comment">//127.0.0.1:8080 --insecure-skip-tls-verify</span> </s>

<span class="hljs-comment">ich habe stattdessen </span>

```
microk8s.kubectl config view --raw > $HOME/.kube/config
```

<span class="hljs-comment"> verwendet</span>

<span class="hljs-meta">\# create the microk8s context</span>

```
kubectl config set-context microk8s --user=admin --cluster=microk8s-cluster
```

<span class="hljs-meta">\# switch to the microk8s context</span>

```
kubectl config use-context microk8s
```

die Datei auf einem externen Rechner kopieren:

```
scp USERNAME@HOST:/home/USERNAME/.kube/config config
```

# Change kubectl editor

sudo -H nano /etc/environment

insert new line: KUBE\_EDITOR="nano"

# Dashboard WithOut Proxy

## Enable additional Add-Ons

We will need to enable a few additional Kubernetes add-ons to get this functionality up and running.

```
microk8s enable ingress # Ingress exposes HTTP and HTTPS routes from outside the cluster to services within the cluster.
microk8s enable dashboard # web-based Kubernetes user interface
microk8s enable dns # creates DNS records for services and pods
microk8s enable storage # provide both long-term and temporary storage to Pods in your cluster.
```

### Enable Host Access

We need to alos enable one more additional add-on `host-access` to enable the access to services running on the host machine via fixed IP address.

We can enable to make use of the default address

```
microk8s enable host-access
```

<div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover " id="bkmrk-"><div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover "><div class="enlighter-code"><div class="enlighter"><div><div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover "><div class="enlighter-code"><div class="enlighter"><div class=""><div>  
</div></div></div></div></div></div></div></div></div></div>### Edit Kubernetes Dashboard Service

We need to edit the kubernetes-dashboard service file which provides dash-board functionality. To to edit this we need to edit dashboard service and change service **type** from **ClusterIP** to **NodePort**.

We use the following command to edit the file using vim.

```
kubectl -n kube-system edit service kubernetes-dashboard
```

This should open the contents of the file in vim and it should look something similar file below

You need to change `type` to `NodePort`

<div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover " id="bkmrk-%23-please-edit-the-ob"><div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover "><div class="enlighter-code"><div class="enlighter"><div><div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover "><div class="enlighter-code"><div class="enlighter"><div class=""><div><span class="enlighter-c0">\# Please edit the object below. Lines beginning with a '#' will be ignored,</span></div></div><div class=""><div><span class="enlighter-c0">\# and an empty file will abort the edit. If an error occurs while saving this file will be</span></div></div><div class=""><div><span class="enlighter-c0">\# reopened with the relevant failures.</span></div></div><div class=""><div><span class="enlighter-c0">\#</span></div></div><div class=""><div><span class="enlighter-text">apiVersion: v1</span></div></div><div class=""><div><span class="enlighter-text">kind: Service</span></div></div><div class=""><div><span class="enlighter-text">metadata:</span></div></div><div class=""><div><span class="enlighter-text"> annotations:</span></div></div><div class=""><div><span class="enlighter-text"> kubectl.</span><span class="enlighter-m3">kubernetes</span><span class="enlighter-text">.</span><span class="enlighter-m3">io</span><span class="enlighter-text">/last-applied-configuration: </span><span class="enlighter-g0">|</span></div></div><div class=""><div><span class="enlighter-g1">{</span><span class="enlighter-s0">"apiVersion"</span><span class="enlighter-text">:</span><span class="enlighter-s0">"v1"</span><span class="enlighter-text">,</span><span class="enlighter-s0">"kind"</span><span class="enlighter-text">:</span><span class="enlighter-s0">"Service"</span><span class="enlighter-text">,</span><span class="enlighter-s0">"metadata"</span><span class="enlighter-text">:</span><span class="enlighter-g1">{</span><span class="enlighter-s0">"annotations"</span><span class="enlighter-text">:</span><span class="enlighter-g1">{}</span><span class="enlighter-text">,</span><span class="enlighter-s0">"labels"</span><span class="enlighter-text">:</span><span class="enlighter-g1">{</span><span class="enlighter-s0">"k8s-app"</span><span class="enlighter-text">:</span><span class="enlighter-s0">"kubernetes-dashboard"</span><span class="enlighter-g1">}</span><span class="enlighter-text">,</span><span class="enlighter-s0">"name"</span><span class="enlighter-text">:</span><span class="enlighter-s0">"kubernetes-dashboard"</span><span class="enlighter-text">,</span><span class="enlighter-s0">"namespace"</span><span class="enlighter-text">:</span><span class="enlighter-s0">"kube-system"</span><span class="enlighter-g1">}</span><span class="enlighter-text">,</span><span class="enlighter-s0">"spec"</span><span class="enlighter-text">:</span><span class="enlighter-g1">{</span><span class="enlighter-s0">"ports"</span><span class="enlighter-text">:</span><span class="enlighter-g1">\[{</span><span class="enlighter-s0">"port"</span><span class="enlighter-text">:</span><span class="enlighter-n1">443</span><span class="enlighter-text">,</span><span class="enlighter-s0">"targetPort"</span><span class="enlighter-text">:</span><span class="enlighter-n1">8443</span><span class="enlighter-g1">}\]</span><span class="enlighter-text">,</span><span class="enlighter-s0">"selector"</span><span class="enlighter-text">:</span><span class="enlighter-g1">{</span><span class="enlighter-s0">"k8s-app"</span><span class="enlighter-text">:</span><span class="enlighter-s0">"kubernetes-dashboard"</span><span class="enlighter-g1">}}}</span></div></div><div class=""><div><span class="enlighter-text"> creationTimestamp: </span><span class="enlighter-s0">"2022-03-09T14:10:50Z"</span></div></div><div class=""><div><span class="enlighter-text"> labels:</span></div></div><div class=""><div><span class="enlighter-text"> k8s-app: kubernetes-dashboard</span></div></div><div class=""><div><span class="enlighter-text"> name: kubernetes-dashboard</span></div></div><div class=""><div><span class="enlighter-text"> namespace: kube-system</span></div></div><div class=""><div><span class="enlighter-text"> resourceVersion: </span><span class="enlighter-s0">"1029725"</span></div></div><div class=""><div><span class="enlighter-text"> selfLink: /api/v1/namespaces/kube-system/services/kubernetes-dashboard</span></div></div><div class=""><div><span class="enlighter-text"> uid: b2608643-a712-4b44-abad-160cf140df49</span></div></div><div class=""><div><span class="enlighter-text">spec:</span></div></div><div class=""><div><span class="enlighter-text"> clusterIP: </span><span class="enlighter-n0">10.152</span><span class="enlighter-text">.</span><span class="enlighter-m3">183</span><span class="enlighter-text">.</span><span class="enlighter-m3">220</span></div></div><div class=""><div><span class="enlighter-text"> clusterIPs:</span></div></div><div class=""><div><span class="enlighter-text"> - </span><span class="enlighter-n0">10.152</span><span class="enlighter-text">.</span><span class="enlighter-m3">183</span><span class="enlighter-text">.</span><span class="enlighter-m3">220</span></div></div><div class=""><div><span class="enlighter-text"> externalTrafficPolicy: Cluster</span></div></div><div class=""><div><span class="enlighter-text"> internalTrafficPolicy: Cluster</span></div></div><div class=""><div><span class="enlighter-text"> ipFamilies:</span></div></div><div class=""><div><span class="enlighter-text"> - IPv4</span></div></div><div class=""><div><span class="enlighter-text"> ipFamilyPolicy: SingleStack</span></div></div><div class=""><div><span class="enlighter-text"> ports:</span></div></div><div class=""><div><span class="enlighter-text"> - nodePort: </span><span class="enlighter-n1">30536</span></div></div><div class=""><div><span class="enlighter-text"> port: </span><span class="enlighter-n1">443</span></div></div><div class=""><div><span class="enlighter-text"> protocol: TCP</span></div></div><div class=""><div><span class="enlighter-text"> targetPort: </span><span class="enlighter-n1">8443</span></div></div><div class=""><div><span class="enlighter-text"> selector:</span></div></div><div class=""><div><span class="enlighter-text"> k8s-app: kubernetes-dashboard</span></div></div><div class=""><div><span class="enlighter-text"> sessionAffinity: None</span></div></div><div class=""><div><span class="enlighter-text"> type: clusterIP </span><span class="enlighter-c0">\## Change this to NodePort</span></div></div><div class=""><div><span class="enlighter-text">status:</span></div></div><div class=""><div><span class="enlighter-text"> loadBalancer: </span><span class="enlighter-g1">{}</span></div></div></div></div></div></div></div></div></div></div>Once you save and exit the file K8s will automatically restart the service.

We can then get the Port the service is running by using the following command

<div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover " id="bkmrk-kubectl--n-kube-syst-1"><div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover "><div class="enlighter-code"><div class="enlighter"><div><div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover "><div class="enlighter-code"><div class="enlighter"><div class=""><div><span class="enlighter-text">kubectl -n kube-system get services</span></div></div></div></div></div></div></div></div></div></div>Which should display something similar to the below and which we can see that the Dashboard is available on port `30536` in my case

<div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover " id="bkmrk--1"><div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover "><div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover "><div class="enlighter-code"><div class="enlighter"><div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover "><div class="enlighter-toolbar-top enlighter-toolbar">  
</div></div></div></div></div></div></div>### Check Port

<div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover " id="bkmrk--2"><div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover "><div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover "><div class="enlighter-code"><div class="enlighter"><div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover "><div class="enlighter-toolbar-top enlighter-toolbar"><div class="enlighter-btn enlighter-btn-copy">  
</div></div></div></div></div></div></div></div>```
sudo snap install nmap
```

```
nmap localhost -p 32061
```

<div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover " id="bkmrk-name-type-cluster-ip"><div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover "><div class="enlighter-code"><div class="enlighter"><div class="enlighter-default enlighter-v-standard enlighter-t-monokai enlighter-l-generic enlighter-hover "><div class="enlighter-toolbar-top enlighter-toolbar"></div><div class="enlighter-code"><div class="enlighter"><div class=""><div><span class="enlighter-text">NAME TYPE CLUSTER-IP EXTERNAL-IP </span><span class="enlighter-m0">PORT</span><span class="enlighter-g1">(</span><span class="enlighter-text">S</span><span class="enlighter-g1">)</span><span class="enlighter-text"> AGE</span></div></div><div class=""><div><span class="enlighter-text">metrics-server ClusterIP </span><span class="enlighter-n0">10.152</span><span class="enlighter-text">.</span><span class="enlighter-m3">183</span><span class="enlighter-text">.</span><span class="enlighter-m3">108</span> <span class="enlighter-g1">&lt;</span><span class="enlighter-text">none</span><span class="enlighter-g1">&gt;</span> <span class="enlighter-n1">443</span><span class="enlighter-text">/TCP 7d4h</span></div></div><div class=""><div><span class="enlighter-text">dashboard-metrics-scraper ClusterIP </span><span class="enlighter-n0">10.152</span><span class="enlighter-text">.</span><span class="enlighter-m3">183</span><span class="enlighter-text">.</span><span class="enlighter-m3">170</span> <span class="enlighter-g1">&lt;</span><span class="enlighter-text">none</span><span class="enlighter-g1">&gt;</span> <span class="enlighter-n1">8000</span><span class="enlighter-text">/TCP 7d4h</span></div></div><div class=""><div><span class="enlighter-text">kube-dns ClusterIP </span><span class="enlighter-n0">10.152</span><span class="enlighter-text">.</span><span class="enlighter-m3">183</span><span class="enlighter-text">.</span><span class="enlighter-m3">10</span> <span class="enlighter-g1">&lt;</span><span class="enlighter-text">none</span><span class="enlighter-g1">&gt;</span> <span class="enlighter-n1">53</span><span class="enlighter-text">/UDP,</span><span class="enlighter-n1">53</span><span class="enlighter-text">/TCP,</span><span class="enlighter-n1">9153</span><span class="enlighter-text">/TCP 7d4h</span></div></div><div class=""><div><span class="enlighter-text">kubernetes-dashboard NodePort </span><span class="enlighter-n0">10.152</span><span class="enlighter-text">.</span><span class="enlighter-m3">183</span><span class="enlighter-text">.</span><span class="enlighter-m3">220</span> <span class="enlighter-g1">&lt;</span><span class="enlighter-text">none</span><span class="enlighter-g1">&gt;</span> <span class="enlighter-n1">443</span><span class="enlighter-text">:</span><span class="enlighter-n1">30536</span><span class="enlighter-text">/TCP 7d4h</span></div></div></div></div><div class="enlighter-toolbar-bottom enlighter-toolbar">  
</div></div></div></div></div></div>We can now open our Firefox browser on any workstation on our network and navigate to `https://{server ip}:{port number}` in my case it is `<a href="https://192.168.0.35:30536">https://192.168.0.35:30536</a>`

### Get the token

We need to get the token from the server so we can do so using the following command in the server terminal

```
token=$(kubectl -n kube-system get secret | grep default-token | cut -d " " -f1) kubectl -n kube-system describe secret $token
```

This should return something similar too

<div class="wp-block-image is-style-default" id="bkmrk--3"><figure class="aligncenter size-large">[![](https://garywoodfine.com/wp-content/uploads/2022/03/image-6-1024x303.png)](https://garywoodfine.com/wp-content/uploads/2022/03/image-6.png)</figure></div>Copy the token text and paste it into the login dialog in the browser

<div class="wp-block-image is-style-default" id="bkmrk--4"><figure class="aligncenter size-large">[![](https://garywoodfine.com/wp-content/uploads/2022/03/image-7-1024x371.png)](https://garywoodfine.com/wp-content/uploads/2022/03/image-7.png)</figure></div>Then you should be able to login with ease.

<div class="wp-block-image is-style-default" id="bkmrk--5"><figure class="aligncenter size-large">[![](https://garywoodfine.com/wp-content/uploads/2022/03/image-8-1024x774.png)](https://garywoodfine.com/wp-content/uploads/2022/03/image-8.png)</figure></div>

# Dashboard - TimeOut

kubectl -n kube-system edit deployments kubernetes-dashboard

\- --token-ttl<span class="o">=</span><span class="m"><span class="hljs-number">0</span></span>

```
spec:
      containers:
      - args:
        - --auto-generate-certificates
        - --token-ttl=0   
```

[![image.png](https://howto.triples-web.de/uploads/images/gallery/2023-06/scaled-1680-/image.png)](https://howto.triples-web.de/uploads/images/gallery/2023-06/image.png)

# Dashboard Get Token

sudo cat /var/snap/microk8s/current/credentials/client.config

# To use a container registry with MicroK8s, you can follow these steps:

To use a container registry with MicroK8s, you can follow these steps:

1\. Enable the `registry` add-on in MicroK8s by running the following command:  
 ```bash  
 microk8s enable registry  
 ```

 This command will start a local container registry in your MicroK8s cluster.

2\. Verify that the `registry` add-on is running by checking the status:  
 ```bash  
 microk8s status | grep registry  
 ```

 The output should show `enabled` next to the `registry` add-on.

3\. Push an image to the local container registry. First, tag an existing Docker image with the address of the local registry. For example:  
 ```bash  
 docker tag my-image:latest localhost:32000/my-image:latest  
 ```

 Replace `my-image` with the name of your image. The address `localhost:32000` corresponds to the default address of the local registry in MicroK8s.

4\. Push the tagged image to the local container registry:  
 ```bash  
 docker push localhost:32000/my-image:latest  
 ```

 This will push the image to the local registry within MicroK8s.

5\. Use the image from the local registry in your Kubernetes manifests or deployments. Update your YAML files to reference the image from the local registry. For example:  
 ```yaml  
 apiVersion: v1  
 kind: Pod  
 metadata:  
 name: my-pod  
 spec:  
 containers:  
\- name: my-container  
 image: localhost:32000/my-image:latest  
 ```

 Replace `my-image` with the name of your image, and `localhost:32000` with the address of the local registry.

MicroK8s will now use the local container registry for pulling images within your cluster.

Please note that the local container registry in MicroK8s uses port `32000` by default. If you encounter any issues or conflicts with this port, you can customize the port by modifying the `registry` add-on configuration.

By following these steps, you can enable and use a local container registry with MicroK8s to push and pull container images within your cluster.

To resolve this issue, you can configure Docker to allow insecure connections to the local registry by following these steps:

1. Open the Docker configuration file (`daemon.json`) for editing. The location of this file depends on your operating system:
    
    
    - Linux: `/etc/docker/daemon.json`
    - Windows: `C:\ProgramData\Docker\config\daemon.json`
    - macOS: `~/Library/Group Containers/group.com.docker/daemon.json`
2. If the file doesn't exist, create it.
3. Add the following content to the `daemon.json` file:
    
    <div class="bg-black rounded-md mb-4"><div class="flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md">json<button class="flex ml-auto gap-2"><svg class="h-4 w-4" fill="none" height="1em" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewbox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"></svg>Copy code</button></div><div class="p-4 overflow-y-auto">`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"insecure-registries"</span><span class="hljs-punctuation">:</span> <span class="hljs-punctuation">[</span><span class="hljs-string">"192.168.178.100:32000"</span><span class="hljs-punctuation">]</span><span class="hljs-punctuation">}</span>`</div></div>Replace `192.168.178.100:32000` with the IP address and port of your local container registry.
4. Save the changes to the `daemon.json` file.
5. Restart the Docker daemon for the changes to take effect. The procedure for restarting the Docker daemon varies depending on your operating system. You can usually do this by restarting the Docker service or using the Docker desktop application.
6. ```
    sudo snap restart docker.dockerd
    ```

Once Docker is configured to allow insecure connections, you should be able to push images to the local container registry without encountering the HTTPS error.

# Installationanleitung 2

1. The first thing to do is open a [command line](https://linuxconfig.org/linux-command-line-tutorial) on your Ubuntu system and execute the following `snap` command to install MicroK8s: ```
    sudo snap install microk8s --classic
    ```
2. Then, execute the following commands to configure Ubuntu’s [ufw firewall](https://linuxconfig.org/how-to-install-ufw-and-use-it-to-set-up-a-basic-firewall) to allow communication between the Kubernetes pods and traffic to and from the internet to pods. ```
    sudo ufw allow in on cni0
    sudo ufw allow out on cni0
    sudo ufw default allow routed
    ```
3. Next, add your current user to the MicroK8s user group so you have access to all of the necessary commands: ```
    sudo usermod -a -G microk8s $USER
    sudo mkdir ~/.kube && sudo chown -R $USER ~/.kube
    sudo newgrp microk8s
    ```
4. The MicroK8s deployment only has the essential elements enabled out of the box. You can see a full list with the following command: ```
    microk8s status
    
    ```
5. You can enable any number of needed services with the following commands. Enable all of the services that you will need: ```
    $ microk8s enable dns
    $ microk8s enable dashboard
    $ microk8s enable storage
    $ microk8s enable ingress
    $ microk8s enable gpu
    $ microk8s enable istio
    $ microk8s enable registry
    ```
    
    To disable any of these services later, just issue the same command but replace `enable` with `disable`:
    
    ```
    $ microk8s disable dns 
    ```
    
    ---
    
    <div class="incontent_ads" data-fuse="22189504224">  
    </div>---
6. You can see the status of your services with the following command. They are ready to go once they switch to the ‘Running’ status: ```
    $ microk8s kubectl get all --all-namespaces
    ```
    
    <figure aria-describedby="caption-attachment-18202" class="wp-caption alignnone" id="bkmrk-checking-the-status-">[![Checking the status of services in MicroK8s on Ubuntu Linux](https://linuxconfig.org/wp-content/uploads/2023/03/01-install-and-use-microk8s-on-ubuntu.png)](https://linuxconfig.org/wp-content/uploads/2023/03/01-install-and-use-microk8s-on-ubuntu.png)<figcaption class="wp-caption-text" id="bkmrk-checking-the-status--1">Checking the status of services in MicroK8s on Ubuntu Linux</figcaption></figure>
7. As we can see in the screenshot above, our Cluster IP Kubernetes dashboard is `10.152.183.38` but yours might be different, so be sure to check. We can now navigate to this address in our browser to access the web based dashboard. <figure aria-describedby="caption-attachment-18201" class="wp-caption alignnone" id="bkmrk-accessing-the-microk">[![Accessing the MicroK8s web based dashboard in Firefox](https://linuxconfig.org/wp-content/uploads/2023/03/02-install-and-use-microk8s-on-ubuntu.png)](https://linuxconfig.org/wp-content/uploads/2023/03/02-install-and-use-microk8s-on-ubuntu.png)<figcaption class="wp-caption-text" id="bkmrk-accessing-the-microk-1">Accessing the MicroK8s web based dashboard in Firefox</figcaption></figure>
8. To log in to the web based dashboard, generate a token with the following commands, and then paste it into login prompt in Firefox. ```
    $ token=$(microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)
    $ microk8s kubectl -n kube-system describe secret $token
    ```
9. You can now get started with deploying your containerized application, or follow along with the three commands below to deploy, and expose a microbot service as an example and proof of concept: ```
    $ microk8s kubectl create deployment microbot --image=dontrebootme/microbot:v1
    $ microk8s kubectl scale deployment microbot --replicas=2
    $ microk8s kubectl expose deployment microbot --type=NodePort --port=80 --name=microbot-service
    ```
10. You will see your new deployment in the output when executing: ```
    $ microk8s kubectl get all --all-namespaces
    ```
11. To see all of the other MicroK8s commands available, you can use the `-h` option and view a full list: ```
    $ microk8s -h
    ```
12. If, after your testing, you need to get rid of MicroK8s, you can execute: ```
    $ microk8s stop
    $ sudo snap remove microk8s
    ```