Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions config/k3s/activate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ ensure_authorized_key() {

ensure_authorized_key "$GALACTICA_AUTHORIZED_KEY"

if [ ! -f "$HOME/.config/k3s/config.yaml" ]; then
K3S_CONFIG_SOURCE="$HOME/.config/k3s/config.yaml"
KUBELET_CONFIG_SOURCE="$HOME/.config/k3s/kubelet.conf.d/10-kyber.conf"
KUBELET_CONFIG_TARGET="/var/lib/rancher/k3s/agent/etc/kubelet.conf.d/10-kyber.conf"

if [ ! -f "$K3S_CONFIG_SOURCE" ] || [ ! -f "$KUBELET_CONFIG_SOURCE" ]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Separate the existence checks to prevent breaking non-Kyber nodes.

Because KUBELET_CONFIG_SOURCE is deployed conditionally for Kyber nodes (lib.mkIf isKyber in default.nix), combining its check with K3S_CONFIG_SOURCE means this script could inadvertently skip or abort k3s activation entirely on non-Kyber nodes where the drop-in file is naturally absent.

Please consider separating the validation so the script can still configure k3s even if the Kyber-specific drop-in is not present.

🛠️ Proposed fix
-if [ ! -f "$K3S_CONFIG_SOURCE" ] || [ ! -f "$KUBELET_CONFIG_SOURCE" ]; then
+if [ ! -f "$K3S_CONFIG_SOURCE" ]; then

(You will also need to wrap the downstream diff/cp logic for KUBELET_CONFIG_SOURCE in a conditional if [ -f "$KUBELET_CONFIG_SOURCE" ]; then ... fi block.)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@config/k3s/activate.sh` at line 37, Separate the K3S_CONFIG_SOURCE and
KUBELET_CONFIG_SOURCE existence checks in the activation script so missing
Kyber-specific kubelet configuration does not prevent k3s setup on non-Kyber
nodes. Keep k3s validation and configuration unconditional, and wrap the
downstream KUBELET_CONFIG_SOURCE diff/copy logic in a file-existence
conditional.

exit 0
fi

Expand All @@ -48,10 +52,20 @@ if [ -z "$SUDO_CMD" ]; then
exit 0
fi

$SUDO_CMD mkdir -p /etc/rancher/k3s
$SUDO_CMD mkdir -p /etc/rancher/k3s "$(dirname "$KUBELET_CONFIG_TARGET")"

K3S_CONFIG_CHANGED=0
if ! $SUDO_CMD diff -q "$K3S_CONFIG_SOURCE" /etc/rancher/k3s/config.yaml >/dev/null 2>&1; then
$SUDO_CMD cp "$K3S_CONFIG_SOURCE" /etc/rancher/k3s/config.yaml
K3S_CONFIG_CHANGED=1
fi

if ! $SUDO_CMD diff -q "$KUBELET_CONFIG_SOURCE" "$KUBELET_CONFIG_TARGET" >/dev/null 2>&1; then
$SUDO_CMD cp "$KUBELET_CONFIG_SOURCE" "$KUBELET_CONFIG_TARGET"
K3S_CONFIG_CHANGED=1
fi

if ! diff -q "$HOME/.config/k3s/config.yaml" /etc/rancher/k3s/config.yaml >/dev/null 2>&1; then
$SUDO_CMD cp "$HOME/.config/k3s/config.yaml" /etc/rancher/k3s/config.yaml
if [ "$K3S_CONFIG_CHANGED" -eq 1 ]; then
if systemctl is-active --quiet k3s; then
$SUDO_CMD systemctl restart k3s
echo "k3s restarted to apply config changes"
Expand Down
5 changes: 5 additions & 0 deletions config/k3s/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ in
force = true;
};

home.file.".config/k3s/kubelet.conf.d/10-kyber.conf" = lib.mkIf isKyber {
source = ./kubelet.conf;
force = true;
};

home.file.".config/k3s/k3s.service" = lib.mkIf isKyber {
source = pkgs.replaceVars ./k3s.service {
inherit (pkgs) coreutils k3s;
Expand Down
6 changes: 6 additions & 0 deletions config/k3s/kubelet.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
# Keep limited parallelism for faster cold starts without allowing a full-node
# restart to saturate containerd, disk I/O, and CRI request deadlines.
serializeImagePulls: false
maxParallelImagePulls: 4
Comment thread
This conversation was marked as resolved.
Resolved
5 changes: 5 additions & 0 deletions spec/activate_k3s_spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ When run bash -c "grep 'config.yaml' '$SCRIPT'"
The output should include 'config.yaml'
End

It 'copies the kubelet configuration drop-in'
When run bash -c "grep 'KUBELET_CONFIG_TARGET' '$SCRIPT'"
The output should include 'kubelet.conf.d/10-kyber.conf'
End

It 'skips if config file missing'
When run bash -c "grep -A 1 '! -f' '$SCRIPT'"
The output should include 'exit 0'
Expand Down
Loading