Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterize kubelet root directory (/var/lib/kubelet) #11988

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .gitlab-ci/packet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ packet_ubuntu20-crio:
packet_ubuntu22-calico-all-in-one:
extends: .packet_pr

packet_debian12-kubelet_root:
extends: .packet_pr

packet_ubuntu22-calico-all-in-one-upgrade:
extends: .packet_pr
variables:
Expand Down
1 change: 1 addition & 0 deletions roles/kubernetes/preinstall/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,4 @@ systemd_resolved_disable_stub_listener: "{{ ansible_os_family in ['Flatcar', 'Fl
# Used to disable File Access Policy Daemon service.
# If service is enabled, the CNI plugin installation will fail
disable_fapolicyd: true
kubelet_root_dir: /var/lib/kubelet
43 changes: 43 additions & 0 deletions roles/kubernetes/preinstall/tasks/0200-kubeletroot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
# mount bind the kubelet root to the default location.
# many csi and software in the ecosystem have this location hardcoded

- name: "Make sure /var/lib/kubelet exists"
ansible.builtin.file:
path: "/var/lib/kubelet"
state: directory
mode: '0750'
when:
- kubelet_root_dir != '/var/lib/kubelet'

- name: "Make sure kubelet_root_dir exists"
ansible.builtin.file:
path: "{{kubelet_root_dir}}"
state: directory
mode: '0750'
when:
- kubelet_root_dir != '/var/lib/kubelet'

- name: "Synchronize old /var/lib/kubelet to new location before mounting"
ansible.posix.synchronize:
src: /var/lib/kubelet/
dest: "{{kubelet_root_dir}}"
archive: true
rsync_opts:
- "--ignore-existing"
set_remote_user: false
delegate_to: "{{inventory_hostname}}"
when:
- kubelet_root_dir != '/var/lib/kubelet'


- name: "Mount bind kubelet-root to /var/lib/kubelet and add it to fstab"
ansible.posix.mount:
path: /var/lib/kubelet
src: "{{kubelet_root_dir}}"
opts: bind,nofail
state: mounted
boot: true
fstype: none
when:
- kubelet_root_dir != '/var/lib/kubelet'
9 changes: 9 additions & 0 deletions roles/kubernetes/preinstall/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,12 @@
when:
- kube_network_plugin == 'calico'
- not ignore_assert_errors


- name: Configure alternative kubelet root
import_tasks: 0200-kubeletroot.yml
tags:
- bootstrap-os
- kubelet-root
when:
- kubelet_root_dir != '/var/lib/kubelet'
1 change: 1 addition & 0 deletions roles/kubespray-defaults/defaults/main/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ kubelet_rotate_server_certificates: false
# If set to true, kubelet errors if any of kernel tunables is different than kubelet defaults
kubelet_protect_kernel_defaults: true

kubelet_root_dir: /var/lib/kubelet
# Set additional sysctl variables to modify Linux kernel variables, for example:
# additional_sysctl:
# - { name: kernel.pid_max, value: 131072 }
Expand Down
8 changes: 8 additions & 0 deletions tests/files/packet_debian12-kubelet_root.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Instance settings
cloud_image: debian-12
mode: default

# Kubespray settings

kubelet_root_dir: /data/kubelet