Manifest Deployer

To run k0s with your preferred extensions you have two options.

  1. Define your extensions as Helm charts as described in here.

  2. Use Manifest Deployer, which is included into k0s. This option is described on below.

Overview

k0s embeds Manifest Deployer, which runs on the controller nodes and provides an easy way to deploy manifests automatically at runtime.

By default, k0s reads all manifests under /var/lib/k0s/manifests and ensures that their state matches the cluster state. Moreover, when a manifest file is removed, k0s will automatically prune all the resources associated with it.

For the most part, Manifest Deployer can be used like the kubectl apply command. The main difference is that Manifest Deployer constantly monitors the directory for changes. Thus, users don’t need to manually apply the changes that are made to the manifest files.

Note
  • Each directory that is a direct descendant of /var/lib/k0s/manifests is considered as its own “stack”, but nested directories (further subfolders) will be excluded from the stack mechanism and thus, they are not automatically deployed by the Manifest Deployer.
  • k0s uses this mechanism for some of its internal in-cluster components and other resources. Make sure you only touch the manifests not managed by k0s.
  • Namespace must be explicitly defined in the manifests. There’s no default namespace used by Manifest Deployer.

Example

You can try Manifest Deployer by creating a new folder under /var/lib/k0s/manifests and then create a manifest file like nginx.yaml with the following content:

  1. apiVersion: v1
  2. kind: Namespace
  3. metadata:
  4. name: nginx
  5. ---
  6. apiVersion: apps/v1
  7. kind: Deployment
  8. metadata:
  9. name: nginx-deployment
  10. namespace: nginx
  11. spec:
  12. selector:
  13. matchLabels:
  14. app: nginx
  15. replicas: 3
  16. template:
  17. metadata:
  18. labels:
  19. app: nginx
  20. spec:
  21. containers:
  22. - name: nginx
  23. image: nginx:latest
  24. ports:
  25. - containerPort: 80

You should soon see the new pods appearing:

  1. $ sudo k0s kubectl get pods --namespace nginx
  2. NAME READY STATUS RESTARTS AGE
  3. nginx-deployment-66b6c48dd5-8zq7d 1/1 Running 0 10m
  4. nginx-deployment-66b6c48dd5-br4jv 1/1 Running 0 10m
  5. nginx-deployment-66b6c48dd5-sqvhb 1/1 Running 0 10m