# How to use launch configurations

**URL:** <https://discuss.kubernetes.io/t/how-to-use-launch-configurations/23359>\
**Category:** microk8s\
**Tags:** docs\
**Created:** [March 8, 2023, 6:26am UTC](https://discuss.kubernetes.io/t/how-to-use-launch-configurations/23359 "2023-03-08T06:26:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![neoaggelos](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/neoaggelos/32/9019_2.png) [@neoaggelos](https://discuss.kubernetes.io/u/neoaggelos)\
**Post date:** [March 8, 2023, 6:26am UTC](https://discuss.kubernetes.io/t/how-to-use-launch-configurations/23359/1 "2023-03-08T06:26:02Z")

</div>

In this HowTo we present the three ways launch configurations can be applied on a local MicroK8s node. In this guide, we will use the following configuration file, which deploys a MicroK8s node and enables the `dns`, `ingress`, `rbac`, `hostpath-storage` and `registry` addons automatically. See the [launch configurations reference](https://discuss.kubernetes.io/t/launch-configurations-reference/23358) for a reference of all possible configuration options as well as examples.

```yaml
# microk8s-config.yaml
---
version: 0.1.0
addons:
  - name: dns
  - name: rbac
  - name: ingress
  - name: hostpath-storage
  - name: registry

# The extra arguments listed here are not required, as they would be set by the 'rbac' and the 'dns'
# addons respectively. However, we set them to save time by not having to restart the Kubernetes
# services a few times during cluster bootstrap.
extraKubeAPIServerArgs:
  --authorization-mode: RBAC,Node
extraKubeletArgs:
  --cluster-dns: 10.152.183.10
  --cluster-domain: cluster.local

```

### 1. When deploying a cluster

Starting with version 1.27, MicroK8s contains a [default launch configuration](https://github.com/canonical/microk8s/blob/master/microk8s-resources/microk8s.default.yaml) that automatically enables the `dns` addon for newly deployed clusters. It is possible to override the default launch configuration by creating `/var/snap/microk8s/common/.microk8s.yaml` like this:

```bash
sudo mkdir -p /var/snap/microk8s/common/
sudo cp microk8s-config.yaml /var/snap/microk8s/common/.microk8s.yaml

```

Similarly, to automatically sideload OCI images into the container runtime, add any `.tar` archives to `/var/snap/microk8s/common/sideload/<image>.tar`:

```bash
sudo mkdir -p /var/snap/microk8s/common/sideload
sudo cp *.tar /var/snap/microk8s/common/sideload/

```

The configuration file will be picked up automatically during the `snap install microk8s` command. After creating the launch configuration file, install MicroK8s as you normally would:

```bash
sudo snap install microk8s --classic --channel 1.27

```

And then wait for the cluster to come up. After a while, list the running pods with `sudo microk8s kubectl get pod -A` and you should see:

```bash
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system calico-node-wtjk2 1/1 Running 0 2m25s
kube-system coredns-f58c55f4c-xw87l 1/1 Running 0 2m37s
kube-system hostpath-provisioner-69cd9ff5b8-njtpc 1/1 Running 0 2m33s
kube-system calico-kube-controllers-57b57c56f-wcj57 1/1 Running 0 2m25s
container-registry registry-77c7575667-66kvf 1/1 Running 0 2m20s
ingress nginx-ingress-microk8s-controller-s9wft 1/1 Running 0 2m13s

```

> _NOTE_: When installing MicroK8s with an invalid launch configuration file, the `snap install microk8s` command will fail.

### 2. Using `snap set`

It is also possible to set a launch configuration on an existing cluster using the `snap set microk8s config=<contents>` command.

First, install MicroK8s:

```bash
sudo snap install microk8s --classic --channel 1.27

```

Then, apply the launch configuration by setting the `config` config option. The option value must be the file contents, not the path:

```bash
sudo snap set microk8s config="$(cat microk8s-config.yaml)"

```

After a while, the configuration is applied to the local node.

### 3. Using a content snap

This method is only supported when running MicroK8s with [strict-confinement](https://microk8s.io/docs/install-strict). This method makes sense in large scale deployments where the operator wants to control the launch configuration of a large fleet of machines, and requires the development and installation of an extra “content snap”. The content snap is built with the custom launch configuration of the operator, and the configuration is applied by connecting the content snap to MicroK8s.

See [microk8s-content-demo-snap](https://github.com/canonical/microk8s-content-demo-snap) for an example content snap. You can use it to scaffold your own content snaps. The [readme](https://github.com/canonical/microk8s-content-demo-snap#readme) contains instructions for editing and building the content snap.

When using a content snap, the installation process looks like this:

First, install the content snap on the host:

```bash
# install content snap from the store...
sudo snap install content-demo-microk8s

# ... or from a local file
sudo snap install ./content-demo-microk8s.snap --dangerous

```

Then, install MicroK8s with strict-confinement:

```bash
sudo snap install microk8s --channel 1.27-strict

```

Finally, connect the content snap (replace `content-demo-microk8s` with your own content snap name):

```bash
sudo snap connect content-demo-microk8s:configuration microk8s

```

After a while, the configuration is applied to the local node.
