← All posts

How to enable PodPreset in Microk8s

PodPreset lets you inject things like secrets, volume mounts, and environment variables into your pods automatically. If you want the full background, the Kubernetes docs cover it here: Pod Preset.

It’s off by default in Microk8s, so here’s how I turned it on.

Step 1 — Edit kube-apiserver

Open up the API server args file:

$ vim /var/snap/microk8s/current/args/kube-apiserver

Step 2 — Add the PodPreset settings

Find your way into the file:

...

And add these two lines:

--runtime-config=settings.k8s.io/v1alpha1=true
--enable-admission-plugins=PodPreset
...

Step 3 — Restart the Kubernetes API server

Give the API server a restart so it picks up the change:

$ sudo systemctl restart snap.microk8s.daemon-apiserver

Testing

Let’s make sure it worked. Ask for PodPresets:

$ kubectl get podpreset

You should get something like this:

No resources found in default namespace.

That’s the good news! No error means the feature is on, you just don’t have any PodPresets yet.

What’s next?

Now you can learn how to create a simple PodPreset and inject it into your pod: Inject Information into Pods Using a PodPreset.