Set kubelet parameters via a configuration file for RKE, RKE2 and K3s clusters
This document (000021322) is provided subject to the disclaimer at the end of this document.
Environment
Situation
A subset of the kubelet's configuration parameters may be set via an on-disk config file, as a substitute for command-line flags. Providing parameters via a config file is the recommended approach because it simplifies node deployment and configuration management. The examples below cover adding the shutdownGracePeriod
and shutdownGracePeriodCriticalPods
parameters via the kubelet configuration file to RKE, RKE2 and K3s clusters.
Resolution
Create the kubelet configuration file with the parameters on all the nodes of the cluster. For example, create the following file at /etc/kubernetes/kubeletconfig.yml
apiVersion: kubelet.config.k8s.io/v1beta1 kind: KubeletConfiguration shutdownGracePeriod: 30s shutdownGracePeriodCriticalPods: 10s
RKE Clusters
For RKE, in the cluster.yml file, add the extra_bind to mount the file into the kubelet and then provide the path to the configuration file as an extra_arg, per the snippet below:
services:
[...]
kubelet:
extra_args:
config: /etc/kubernetes/kubeletconfig.yml
extra_binds:
- "/etc/kubernetes/kubeletconfig.yml:/etc/kubernetes/kubeletconfig.yml"
[...]
Run rke up
for the configuration to be applied to the cluster.
RKE2/K3s Clusters
Add the configuration parameter under the kubelet args in the config file located at /etc/rancher/{rke2|k3s}/config.yaml
kubelet-arg:
- "--config=/etc/kubernetes/kubeletconfig.yml"
Restart the rke2/k3s service for the configuration to be applied.
NOTE
The kubelet configuration file needs to be created on all the nodes of the cluster.
Additional Information
https://kubernetes.io/docs/reference/config-api/kubelet-config.v1beta1/
Disclaimer
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.
- Document ID:000021322
- Creation Date: 14-Jan-2024
- Modified Date:02-Aug-2024
-
- SUSE Rancher
For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com