I'm trying to change the command executed when launching my rke2-server.
I currently use systemctl to start rke2-server.service, which automatically create kubelet and containerd process.
I need to change containerd command line arguments to set a specific socket path.
CGroup: /system.slice/rke2-server.service
├─ 704919 /var/lib/rancher/rke2/data/v1.21.6-rke2r1-fd8a733b61b5/bin/containerd-shim-runc-v2 -namespace k8s.io -id 89473940793c2d4f4371fd0294b55c52750ef2b84bdeff6ed5deff3f947d9018 -address /run/k3s/containerd/containerd.sock
├─ 704999 /var/lib/rancher/rke2/data/v1.21.6-rke2r1-fd8a733b61b5/bin/containerd-shim-runc-v2 -namespace k8s.io -id 536f6c8c2fd4ce677848ac5f630b25a9bf04038feeaf22d13245782043e701d0 -address /run/k3s/containerd/containerd.sock
├─ 705094 /var/lib/rancher/rke2/data/v1.21.6-rke2r1-fd8a733b61b5/bin/containerd-shim-runc-v2 -namespace k8s.io -id fc1875e999ed218880ffc223d4dc4f6f9230511663974e1bdf96d71831543e79 -address /run/k3s/containerd/containerd.sock
├─ 705096 /var/lib/rancher/rke2/data/v1.21.6-rke2r1-fd8a733b61b5/bin/containerd-shim-runc-v2 -namespace k8s.io -id b1c69c1a29ce27e78ea2139fd7827fd7c3e199b979f752389bb309985c41662a -address /run/k3s/containerd/containerd.sock
├─ 705466 /var/lib/rancher/rke2/data/v1.21.6-rke2r1-fd8a733b61b5/bin/containerd-shim-runc-v2 -namespace k8s.io -id 86041dea524461becfa2c5bd0fe5c4fb193c223bff4a647033bf7cdb9454d3aa -address /run/k3s/containerd/containerd.sock
├─ 705504 /var/lib/rancher/rke2/data/v1.21.6-rke2r1-fd8a733b61b5/bin/containerd-shim-runc-v2 -namespace k8s.io -id 04e76c6081c8f83ac0e77c5bf504506f01b679a96f0588a4e1f374e6b2d2a0cc -address /run/k3s/containerd/containerd.sock
├─ 705563 /var/lib/rancher/rke2/data/v1.21.6-rke2r1-fd8a733b61b5/bin/containerd-shim-runc-v2 -namespace k8s.io -id 9841a4cb99b0e5105bc8dffd6d67a6cc302b51fb81e7dd908b8f2a55795fa375 -address /run/k3s/containerd/containerd.sock
├─1389568 /var/lib/rancher/rke2/data/v1.21.6-rke2r1-fd8a733b61b5/bin/containerd-shim-runc-v2 -namespace k8s.io -id ca221b0cd19464e954d82f15340c45c24e6e3639de77ed9dd51a62c9ece32b44 -address /run/k3s/containerd/containerd.sock
├─1390455 /usr/local/bin/rke2 server
├─1390465 containerd -c /var/lib/rancher/rke2/agent/etc/containerd/config.toml -a /run/k3s/containerd/containerd.sock --state /run/k3s/containerd --root /var/lib/rancher/rke2/agent/containerd
└─1390476 kubelet --volume-plugin-dir=/var/lib/kubelet/volumeplugins --file-check-frequency=5s --sync-frequency=30s --address=0.0.0.0 --alsologtostderr=false --anonymous-auth=false --authentication-token-webhook=true
As you can see, containerd command is :
containerd -c /var/lib/rancher/rke2/agent/etc/containerd/config.toml -a /run/k3s/containerd/containerd.sock --state /run/k3s/containerd --root
I want to change the socket path "-a" parameter to lets say /tmp/containerd.sock
I tried to create a config.toml.tmpl to change the grpc address but command still unchanged...
Do you have any tips ?
https://docs.rke2.io/advanced/#configuring-containerd
Configuring containerd RKE2 will generate the config.toml for containerd in /var/lib/rancher/rke2/agent/etc/containerd/config.toml.
For advanced customization of this file you can create another file called config.toml.tmpl in the same directory and it will be used instead.
The config.toml.tmpl will be treated as a Go template file, and the config.Node structure is being passed to the template. See this template for an example of how to use the structure to customize the configuration file.