kubelet

systemd

  • service configure :

    • v1.12.3: /etc/systemd/system/kubelet.service.d/10-kubeadm.conf

    • v1.9.16: /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf

    • check via:

      $ sudo systemctl status kubelet.service
       kubelet.service - kubelet: The Kubernetes Node Agent
         Loaded: loaded (/usr/local/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)
        Drop-In: /usr/lib/systemd/system/kubelet.service.d
                 └─10-kubeadm.conf
         Active: active (running) since Fri 2023-06-23 17:04:07 PDT; 7min ago
  • environment file : /etc/sysconfig/kubelet

kubelet

  • kubeconfig, kubelet configuration file :

    • /etc/kubernetes/kubelet.conf

  • kubeConfig file to use for the TLS Bootstrap, (it is only used if /etc/kubernetes/kubelet.conf does not exist):

    • /etc/kubernetes/bootstrap-kubelet.conf

  • file containing the kubelet's ComponentConfig, workflow in kubelet init :

    • /var/lib/kubelet/config.yaml

  • dynamic environment file that contains KUBELET_KUBEADM_ARGS :

    • /var/lib/kubelet/kubeadm-flags.env

  • user-specified flag overrides with KUBELET_EXTRA_ARGS :

    • /etc/default/kubelet (for DEBs)

    • /etc/sysconfig/kubelet (for RPMs)

modfiy /var/lib/kubelet

  • KUBELET_EXTRA_ARGS

    $ sudo systemctl stop kubelet
    $ sudo echo 'KUBELET_EXTRA_ARGS=--root-dir=/mnt/kubelet' > /etc/sysconfig/kubelet
    $ sudo systemctl daemon-reload
    $ sudo systemctl start kubelet

kuabelet configration

[!TIP] references:

$ cat /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS=--root-dir=/path/to/extra/folder

$ grep EnvironmentFile /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
EnvironmentFile=-/etc/sysconfig/kubelet

$ systemctl daemon-reload
$ systemctl enable kubelet --now
$ systemctl start kubelet
  • because of

    $ grep '/etc/sysconfig/kubelet' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
    EnvironmentFile=-/etc/sysconfig/kubele
    
    $ ps auxfww | grep kubelet
    root        2262  2.5  0.0 6830176 143332 ?      Ssl  13:01   2:26 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --cgroup-driver=cgroupfs --network-plugin=cni --root-dir=/home/kubelet
  • or symolic link

    $ sudo systemctl stop kubelet
    $ mkdir -p /mnt/kubelet
    $ sudo cp -r /var/lib/kubelet/* /mnt/kubelet/
    $ sudo mv /var/lib/kubelet{,.backup}
    $ sudo ln -sf /mnt/kueblet /var/lib/kubelet
    $ sudo systemctl daemon-reload
    $ sudo systemctl start kubelet
  • or add KUBELET_EXTRA_ARGS :

    $ cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
    ...
    Environment="KUBELET_EXTRA_ARGS=$KUBELET_EXTRA_ARGS --root-dir=/path/to/extra/folder"
    ...

config files

/etc/systemd/system/kubelet.service.d/10-kubeadm.conf

[!TIP] This file specifies the default locations for all of the files managed by kubeadm for the kubelet.

  • The KubeConfig file to use for the TLS Bootstrap is /etc/kubernetes/bootstrap-kubelet.conf, but it is only used if /etc/kubernetes/kubelet.conf does not exist.

  • The KubeConfig file with the unique kubelet identity is /etc/kubernetes/kubelet.conf.

  • The file containing the kubelet's ComponentConfig is /var/lib/kubelet/config.yaml.

  • The dynamic environment file that contains KUBELET_KUBEADM_ARGS is sourced from /var/lib/kubelet/kubeadm-flags.env.

  • The file that can contain user-specified flag overrides with KUBELET_EXTRA_ARGS is sourced from /etc/default/kubelet (for DEBs), or /etc/sysconfig/kubelet (for RPMs). KUBELET_EXTRA_ARGS is last in the flag chain and has the highest priority in the event of conflicting settings.

$ cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
# Note: This dropin only works with kubeadm and kubelet v1.11+
[Service]
Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"
# This is a file that "kubeadm init" and "kubeadm join" generates at runtime, populating the KUBELET_KUBEADM_ARGS variable dynamically
EnvironmentFile=-/var/lib/kubelet/kubeadm-flags.env
# This is a file that the user can use for overrides of the kubelet args as a last resort. Preferably, the user should use
# the .NodeRegistration.KubeletExtraArgs object in the configuration files instead. KUBELET_EXTRA_ARGS should be sourced from this file.
EnvironmentFile=-/etc/sysconfig/kubelet
ExecStart=
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS

Last updated