mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
Merge pull request #93305 from alculquicondor/lssd-ephemeral
Mount kubelet and container runtime rootdir on LSSD
This commit is contained in:
commit
6b39cdf376
@ -40,6 +40,7 @@ NODE_DISK_SIZE=${NODE_DISK_SIZE:-100GB}
|
||||
NODE_LOCAL_SSDS=${NODE_LOCAL_SSDS:-0}
|
||||
NODE_LABELS="${KUBE_NODE_LABELS:-}"
|
||||
WINDOWS_NODE_LABELS="${WINDOWS_NODE_LABELS:-}"
|
||||
NODE_LOCAL_SSDS_EPHEMERAL=${NODE_LOCAL_SSDS_EPHEMERAL:-}
|
||||
|
||||
# KUBE_CREATE_NODES can be used to avoid creating nodes, while master will be sized for NUM_NODES nodes.
|
||||
# Firewalls and node templates are still created.
|
||||
|
@ -39,6 +39,7 @@ NODE_DISK_SIZE=${NODE_DISK_SIZE:-100GB}
|
||||
NODE_LOCAL_SSDS=${NODE_LOCAL_SSDS:-0}
|
||||
NODE_LABELS=${KUBE_NODE_LABELS:-}
|
||||
WINDOWS_NODE_LABELS=${WINDOWS_NODE_LABELS:-}
|
||||
NODE_LOCAL_SSDS_EPHEMERAL=${NODE_LOCAL_SSDS_EPHEMERAL:-}
|
||||
|
||||
# KUBE_CREATE_NODES can be used to avoid creating nodes, while master will be sized for NUM_NODES nodes.
|
||||
# Firewalls and node templates are still created.
|
||||
|
@ -385,6 +385,10 @@ function mount-ext(){
|
||||
# Local ssds, if present, are mounted or symlinked to their appropriate
|
||||
# locations
|
||||
function ensure-local-ssds() {
|
||||
if [ "${NODE_LOCAL_SSDS_EPHEMERAL:-false}" == "true" ]; then
|
||||
ensure-local-ssds-ephemeral-storage
|
||||
return
|
||||
fi
|
||||
get-local-disk-num "scsi" "block"
|
||||
local scsiblocknum="${localdisknum}"
|
||||
local i=0
|
||||
@ -436,6 +440,62 @@ function ensure-local-ssds() {
|
||||
done
|
||||
}
|
||||
|
||||
# Local SSDs, if present, are used in a single RAID 0 array and directories that
|
||||
# back ephemeral storage are mounted on them (kubelet root, container runtime
|
||||
# root and pod logs).
|
||||
function ensure-local-ssds-ephemeral-storage() {
|
||||
local devices=()
|
||||
# Get nvme devices
|
||||
for ssd in /dev/nvme*n*; do
|
||||
if [ -e "${ssd}" ]; then
|
||||
# This workaround to find if the NVMe device is a local SSD is required
|
||||
# because the existing Google images does not them in /dev/disk/by-id
|
||||
if [[ "$(lsblk -o MODEL -dn "${ssd}")" == "nvme_card" ]]; then
|
||||
devices+=("${ssd}")
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [ "${#devices[@]}" -eq 0 ]; then
|
||||
echo "No local NVMe SSD disks found."
|
||||
return
|
||||
fi
|
||||
|
||||
local device="${devices[0]}"
|
||||
if [ "${#devices[@]}" -ne 1 ]; then
|
||||
seen_arrays=(/dev/md/*)
|
||||
device=${seen_arrays[0]}
|
||||
echo "Setting RAID array with local SSDs on device ${device}"
|
||||
if [ ! -e "$device" ]; then
|
||||
device="/dev/md/0"
|
||||
echo "y" | mdadm --create "${device}" --level=0 --raid-devices=${#devices[@]} "${devices[@]}"
|
||||
fi
|
||||
fi
|
||||
|
||||
local ephemeral_mountpoint="/mnt/stateful_partition/kube-ephemeral-ssd"
|
||||
safe-format-and-mount "${device}" "${ephemeral_mountpoint}"
|
||||
|
||||
# mount container runtime root dir on SSD
|
||||
local container_runtime="${CONTAINER_RUNTIME:-docker}"
|
||||
systemctl stop "$container_runtime"
|
||||
# Some images remount the container runtime root dir.
|
||||
umount "/var/lib/${container_runtime}" || true
|
||||
# Move the container runtime's directory to the new location to preserve
|
||||
# preloaded images.
|
||||
if [ ! -d "${ephemeral_mountpoint}/${container_runtime}" ]; then
|
||||
mv "/var/lib/${container_runtime}" "${ephemeral_mountpoint}/${container_runtime}"
|
||||
fi
|
||||
safe-bind-mount "${ephemeral_mountpoint}/${container_runtime}" "/var/lib/${container_runtime}"
|
||||
systemctl start "$container_runtime"
|
||||
|
||||
# mount kubelet root dir on SSD
|
||||
mkdir -p "${ephemeral_mountpoint}/kubelet"
|
||||
safe-bind-mount "${ephemeral_mountpoint}/kubelet" "/var/lib/kubelet"
|
||||
|
||||
# mount pod logs root dir on SSD
|
||||
mkdir -p "${ephemeral_mountpoint}/log_pods"
|
||||
safe-bind-mount "${ephemeral_mountpoint}/log_pods" "/var/log/pods"
|
||||
}
|
||||
|
||||
# Installs logrotate configuration files
|
||||
function setup-logrotate() {
|
||||
mkdir -p /etc/logrotate.d/
|
||||
@ -2950,8 +3010,8 @@ function main() {
|
||||
setup-os-params
|
||||
config-ip-firewall
|
||||
create-dirs
|
||||
setup-kubelet-dir
|
||||
ensure-local-ssds
|
||||
setup-kubelet-dir
|
||||
setup-logrotate
|
||||
if [[ "${KUBERNETES_MASTER:-}" == "true" ]]; then
|
||||
mount-master-pd
|
||||
|
@ -1215,6 +1215,7 @@ CONTAINER_RUNTIME_TEST_HANDLER: $(yaml-quote "${CONTAINER_RUNTIME_TEST_HANDLER:-
|
||||
UBUNTU_INSTALL_CONTAINERD_VERSION: $(yaml-quote "${UBUNTU_INSTALL_CONTAINERD_VERSION:-}")
|
||||
UBUNTU_INSTALL_RUNC_VERSION: $(yaml-quote "${UBUNTU_INSTALL_RUNC_VERSION:-}")
|
||||
NODE_LOCAL_SSDS_EXT: $(yaml-quote "${NODE_LOCAL_SSDS_EXT:-}")
|
||||
NODE_LOCAL_SSDS_EPHEMERAL: "$(yaml-quote ${NODE_LOCAL_SSDS_EPHEMERAL:-})"
|
||||
LOAD_IMAGE_COMMAND: $(yaml-quote "${LOAD_IMAGE_COMMAND:-}")
|
||||
ZONE: $(yaml-quote "${ZONE}")
|
||||
REGION: $(yaml-quote "${REGION}")
|
||||
|
Loading…
Reference in New Issue
Block a user