nestybox / nestybox/sysbox

Sysbox 0.6.7 installation fails on RKE2 v1.32 ad later Kubernetes cluster due to incompatibility in get_runtime_kubelet_rke2() function of sysbox-pkgr/k8s/scripts /kubelet-config-helper.sh

Open
#974 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
3.9k
Forks
230
Avg merge
7h 48m
Merged PRs (30d)
3

Description

The function get_runtime_kubelet_rke2() in sysbox-pkgr/k8s/scripts /kubelet-config-helper.sh returns an empty string for RKE2 v1.32.9+rke2r1 instead the current runtime of kubelet:

https://github.com/nestybox/sysbox-pkgr/blob/f5b6eb90c212e97b64566efd7a1e974c9b0153d9/k8s/scripts/kubelet-config-helper.sh#L1256

runtime=$(ps -e -o command | egrep kubelet | egrep -o "container-runtime-endpoint=\S*" | cut -d '=' -f2)

The following function is bailing out due to $runtime being set to "unix:///var/run/dockershim.sock" durig sysbox install:

function do_config_kubelet_rke2() {
	echo "Detected RKE2's host-based kubelet deployment on host."

	# Obtain current runtime.
	get_runtime_kubelet_rke2
	if [[ ${runtime} =~ "crio" ]]; then
		echo "Kubelet is already using CRI-O; no action will be taken."
		return
	fi

	# No runtime other than containerd, and obviously crio, is expected in an
	# rke2 deployment.
	if [[ ! ${runtime} =~ "containerd" ]]; then
		echo "Unsupported runtime for RKE2 scenario: $runtime"
		return
	fi

In RKE2 v1.32 the config for the kubelet runtime is located in file /var/lib/rancher/rke2/agent/etc/kubelet.conf.d/00-rke2-defaults.conf in line

containerRuntimeEndpoint: unix:///run/k3s/containerd/containerd.sock

or

containerRuntimeEndpoint: unix:///var/run/crio/crio.sock

The proposed fix for the get_runtime_kubelet_rke2() function is:

function get_runtime_kubelet_rke2() {
    set +e
    
    # Try RKE2 v1.32+ config file first
    local rke2_config="/var/lib/rancher/rke2/agent/etc/kubelet.conf.d/00-rke2-defaults.conf"
    if [[ -f "$rke2_config" ]]; then
        runtime=$(grep "^containerRuntimeEndpoint:" "$rke2_config" | awk '{print $2}')
    fi
    
    # Fallback to legacy kubelet command line parameter for older versions
    if [[ -z "$runtime" ]]; then
        runtime=$(ps -e -o command | grep kubelet | grep -o "container-runtime-endpoint=\S*" | cut -d '=' -f2)
    fi
    
    # If runtime is still unknown, assume it's Docker
    if [[ -z "$runtime" ]]; then
        runtime="unix:///var/run/dockershim.sock"
    fi
    
    set -e
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in sysbox-pkgr/k8s/scripts/kubelet-config-helper.sh at get_runtime_kubelet_rke2() and inspect how do_config_kubelet_rke2() uses its runtime value. Check the RKE2 v1.32 kubelet configuration at /var/lib/rancher/rke2/agent/etc/kubelet.conf.d/00-rke2-defaults.conf alongside the legacy command-line lookup, then verify installation with containerd and CRI-O configurations.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, kubernetes, shell
Domain
devops, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.