How to add tolerations to k0smotron workloads

Hello.

I am new to k0smotron. Using k0smotron would solve the problem of how to effectively provision Kubernetes control planes.

As I setup my test k0s cluster that should run k0smotron, I added taints to the nodes and now I can’t figure out a way to add the required tolerations to the k0smotron workloads. I have read the documentation and I have tried throwing both Copilot and Claude at the problem but no luck.

I am trying to use Cluster.spec.patches to do it. I get no errors when applying my Cluster custom resource but no tolerations are added to the stateful set that is created. Has anyone managed to successfuly add tolerations?

I would probably not have to add custom taints as the management cluster will only run k0smotron and any dependencies. Still, it would be nice to understand how it works.

Cheers,

A

Turns out i had confused the app.kubernetes.io/component with the component label at some point of my troubleshooting and retries. It works as documented.

If anyone else is looking for this, here is an example

apiVersion: k0smotron.io/v1beta2
kind: Cluster
metadata:
  name: k0smotron-test
spec:
  replicas: 1
  service:
    type: NodePort
    apiPort: 30443
    konnectivityPort: 30132
  storage:
    type: nats
  persistence:
    type: emptyDir
  patches:
      - patch:
          content: |
            - op: add
              path: /spec/template/spec/tolerations
              value:
                - operator: "Exists"
          type: json
        target:
          kind: StatefulSet
          component: cluster

Hi @anbo-1, welcome to the community – and thanks for circling back to share your fix. Posting the working example is exactly the kind of thing that helps the next person, so it’s much appreciated. Glad you got it working!

Here is another extended example, if anyone needs one.

I have a “mothership” cluster consisting of 3 controller+worker nodes, which is why the tolerations are needed. I use PVCs to persist ETCD data. As you can work out form the storage class name, I use TopoLVM as the CSI.

I use both CPLB and NLLB and k0s managed calico . This combination seems to work quite well.

apiVersion: k0smotron.io/v1beta2
kind: Cluster
metadata:
  name: test-cluster
  namespace: k0smotron
spec:
  replicas: 3
  version: v1.36.2-k0s.0
  externalAddress: 10.0.10.10  # CPLB VIP
  service:
    type: NodePort
    apiPort: 30443
    konnectivityPort: 30132
  persistence:
    type: pvc
    persistentVolumeClaim:
      spec:
        storageClassName: topolvm-provisioner
        resources:
          requests:
            storage: 5Gi
  storage:
    type: etcd
    etcd:
      persistence:
        storageClass: topolvm-provisioner
  patches:
    - patch:
        content: |
          - op: add
            path: /spec/template/spec/tolerations
            value:
              - operator: "Exists"
        type: json
      target:
        kind: StatefulSet
        component: etcd