Skip to content

Commit

Permalink
clean up more manifest.json dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshkumarashok committed Oct 29, 2024
1 parent 4736745 commit 042f15d
Show file tree
Hide file tree
Showing 1,971 changed files with 29,838 additions and 30,708 deletions.
1 change: 0 additions & 1 deletion parts/linux/cloud-init/artifacts/cse_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ TELEPORTD_PLUGIN_DOWNLOAD_DIR="/opt/teleportd/downloads"
CREDENTIAL_PROVIDER_DOWNLOAD_DIR="/opt/credentialprovider/downloads"
CREDENTIAL_PROVIDER_BIN_DIR="/var/lib/kubelet/credential-provider"
TELEPORTD_PLUGIN_BIN_DIR="/usr/local/bin"
MANIFEST_FILEPATH="/opt/azure/manifest.json"
COMPONENTS_FILEPATH="/opt/azure/components.json"
MAN_DB_AUTO_UPDATE_FLAG_FILEPATH="/var/lib/man-db/auto-update"
CURL_OUTPUT=/tmp/curl_verbose.out
Expand Down
7 changes: 0 additions & 7 deletions parts/linux/cloud-init/nodecustomdata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,6 @@ write_files:
content: !!binary |
{{GetVariableProperty "cloudInitData" "provisionConfigs"}}

- path: /opt/azure/manifest.json
permissions: "0644"
encoding: gzip
owner: root
content: !!binary |
{{GetVariableProperty "cloudInitData" "componentManifestFile"}}

- path: {{GetInitAKSCustomCloudFilepath}}
permissions: "0744"
encoding: gzip
Expand Down
9 changes: 1 addition & 8 deletions pkg/agent/testdata/AKSUbuntu1604+Containerd/CustomData

Large diffs are not rendered by default.

33 changes: 4 additions & 29 deletions pkg/agent/testdata/AKSUbuntu1604+Containerd/line105.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,10 @@
[Unit]
Description=Kubelet
ConditionPathExists=/usr/local/bin/kubelet
Wants=network-online.target containerd.service
After=network-online.target containerd.service
Description=Apply MIG configuration on Nvidia A100 GPU

[Service]
Restart=always
RestartSec=2
EnvironmentFile=/etc/default/kubelet
SuccessExitStatus=143
ExecStartPre=/bin/bash /opt/azure/containers/kubelet.sh
ExecStartPre=/bin/bash /opt/azure/containers/ensure_imds_restriction.sh
ExecStartPre=/bin/mkdir -p /var/lib/kubelet
ExecStartPre=/bin/mkdir -p /var/lib/cni
ExecStartPre=/bin/bash -c "if [ $(mount | grep \"/var/lib/kubelet\" | wc -l) -le 0 ] ; then /bin/mount --bind /var/lib/kubelet /var/lib/kubelet ; fi"
ExecStartPre=/bin/mount --make-shared /var/lib/kubelet

ExecStartPre=-/sbin/ebtables -t nat --list
ExecStartPre=-/sbin/iptables -t nat --numeric --list

ExecStart=/usr/local/bin/kubelet \
--enable-server \
--node-labels="${KUBELET_NODE_LABELS}" \
--v=2 \
--volume-plugin-dir=/etc/kubernetes/volumeplugins \
$KUBELET_TLS_BOOTSTRAP_FLAGS \
$KUBELET_CONFIG_FILE_FLAGS \
$KUBELET_CONTAINERD_FLAGS \
$KUBELET_CONTAINER_RUNTIME_FLAG \
$KUBELET_CGROUP_FLAGS \
$KUBELET_FLAGS
Restart=on-failure
ExecStartPre=/usr/bin/nvidia-smi -mig 1
ExecStart=/bin/bash /opt/azure/containers/mig-partition.sh ${GPU_INSTANCE_PROFILE}

[Install]
WantedBy=multi-user.target
35 changes: 26 additions & 9 deletions pkg/agent/testdata/AKSUbuntu1604+Containerd/line112.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
[Unit]
Description=Apply MIG configuration on Nvidia A100 GPU
#!/bin/bash

[Service]
Restart=on-failure
ExecStartPre=/usr/bin/nvidia-smi -mig 1
ExecStart=/bin/bash /opt/azure/containers/mig-partition.sh ${GPU_INSTANCE_PROFILE}

[Install]
WantedBy=multi-user.target
#NOTE: Currently, Nvidia library mig-parted (https://github.com/NVIDIA/mig-parted) cannot work properly because of the outdated GPU driver version
#TODO: Use mig-parted library to do the partition after the above issue is fixed
MIG_PROFILE=${1}
case ${MIG_PROFILE} in
"MIG1g")
nvidia-smi mig -cgi 19,19,19,19,19,19,19
;;
"MIG2g")
nvidia-smi mig -cgi 14,14,14
;;
"MIG3g")
nvidia-smi mig -cgi 9,9
;;
"MIG4g")
nvidia-smi mig -cgi 5
;;
"MIG7g")
nvidia-smi mig -cgi 0
;;
*)
echo "not a valid GPU instance profile"
exit 1
;;
esac
nvidia-smi mig -cci
27 changes: 0 additions & 27 deletions pkg/agent/testdata/AKSUbuntu1604+Containerd/line119.sh

This file was deleted.

99 changes: 99 additions & 0 deletions pkg/agent/testdata/AKSUbuntu1604+Containerd/line120.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/usr/bin/env bash

set -o nounset
set -e

source /opt/azure/containers/provision_source_distro.sh

unattended_upgrade() {
retries=10
for i in $(seq 1 $retries); do
unattended-upgrade -v && break
if [ $i -eq $retries ]; then
return 1
else sleep 5
fi
done
echo Executed unattended upgrade $i times
}

cfg_has_option() {
file=$1
option=$2
line=$(sed -n "/^$option:/ p" "$file")
[ -n "$line" ]
}

cfg_set_option() {
file=$1
option=$2
value=$3
if ! cfg_has_option "$file" "$option"; then
echo "$option: $value" >> "$file"
else
sed -i 's/'"$option"':.*$/'"$option: $value"'/g' "$file"
fi
}

KUBECTL="/usr/local/bin/kubectl --kubeconfig /var/lib/kubelet/kubeconfig"

source_list_path=/etc/apt/sources.list
source_list_backup_path=/etc/apt/sources.list.backup
cloud_cfg_path=/etc/cloud/cloud.cfg

while [ ! -f /var/lib/kubelet/kubeconfig ]; do
echo 'Waiting for TLS bootstrapping'
sleep 3
done

node_name=$(hostname)
if [ -z "${node_name}" ]; then
echo "cannot get node name"
exit 1
fi

node_name=$(echo "$node_name" | tr '[:upper:]' '[:lower:]')

golden_timestamp=$($KUBECTL get node ${node_name} -o jsonpath="{.metadata.annotations['kubernetes\.azure\.com/live-patching-golden-timestamp']}")
if [ -z "${golden_timestamp}" ]; then
echo "golden timestamp is not set, skip live patching"
exit 0
fi
echo "golden timestamp is: ${golden_timestamp}"

current_timestamp=$($KUBECTL get node ${node_name} -o jsonpath="{.metadata.annotations['kubernetes\.azure\.com/live-patching-current-timestamp']}")
if [ -n "${current_timestamp}" ]; then
echo "current timestamp is: ${current_timestamp}"

if [[ "${golden_timestamp}" == "${current_timestamp}" ]]; then
echo "golden and current timestamp is the same, nothing to patch"
exit 0
fi
fi

old_source_list=$(cat ${source_list_path})
sed -i 's/http:\/\/azure.archive.ubuntu.com\/ubuntu\//https:\/\/snapshot.ubuntu.com\/ubuntu\/'"${golden_timestamp}"'/g' ${source_list_path}
sed -i 's/https:\/\/snapshot.ubuntu.com\/ubuntu\/\([0-9]\{8\}T[0-9]\{6\}Z\)/https:\/\/snapshot.ubuntu.com\/ubuntu\/'"${golden_timestamp}"'/g' ${source_list_path}
option=apt_preserve_sources_list
option_value=true
cfg_set_option ${cloud_cfg_path} ${option} ${option_value}

new_source_list=$(cat ${source_list_path})
if [[ "${old_source_list}" != "${new_source_list}" ]]; then
echo "$old_source_list" > ${source_list_backup_path}
echo "/etc/apt/sources.list is updated:"
diff ${source_list_backup_path} ${source_list_path} || true
fi

if ! apt_get_update; then
echo "apt_get_update failed"
exit 1
fi
if ! unattended_upgrade; then
echo "unattended_upgrade failed"
exit 1
fi

$KUBECTL annotate --overwrite node ${node_name} kubernetes.azure.com/live-patching-current-timestamp=${golden_timestamp}

echo snapshot update completed successfully
103 changes: 5 additions & 98 deletions pkg/agent/testdata/AKSUbuntu1604+Containerd/line127.sh
Original file line number Diff line number Diff line change
@@ -1,99 +1,6 @@
#!/usr/bin/env bash
[Unit]
Description=Snapshot Update Service

set -o nounset
set -e

source /opt/azure/containers/provision_source_distro.sh

unattended_upgrade() {
retries=10
for i in $(seq 1 $retries); do
unattended-upgrade -v && break
if [ $i -eq $retries ]; then
return 1
else sleep 5
fi
done
echo Executed unattended upgrade $i times
}

cfg_has_option() {
file=$1
option=$2
line=$(sed -n "/^$option:/ p" "$file")
[ -n "$line" ]
}

cfg_set_option() {
file=$1
option=$2
value=$3
if ! cfg_has_option "$file" "$option"; then
echo "$option: $value" >> "$file"
else
sed -i 's/'"$option"':.*$/'"$option: $value"'/g' "$file"
fi
}

KUBECTL="/usr/local/bin/kubectl --kubeconfig /var/lib/kubelet/kubeconfig"

source_list_path=/etc/apt/sources.list
source_list_backup_path=/etc/apt/sources.list.backup
cloud_cfg_path=/etc/cloud/cloud.cfg

while [ ! -f /var/lib/kubelet/kubeconfig ]; do
echo 'Waiting for TLS bootstrapping'
sleep 3
done

node_name=$(hostname)
if [ -z "${node_name}" ]; then
echo "cannot get node name"
exit 1
fi

node_name=$(echo "$node_name" | tr '[:upper:]' '[:lower:]')

golden_timestamp=$($KUBECTL get node ${node_name} -o jsonpath="{.metadata.annotations['kubernetes\.azure\.com/live-patching-golden-timestamp']}")
if [ -z "${golden_timestamp}" ]; then
echo "golden timestamp is not set, skip live patching"
exit 0
fi
echo "golden timestamp is: ${golden_timestamp}"

current_timestamp=$($KUBECTL get node ${node_name} -o jsonpath="{.metadata.annotations['kubernetes\.azure\.com/live-patching-current-timestamp']}")
if [ -n "${current_timestamp}" ]; then
echo "current timestamp is: ${current_timestamp}"

if [[ "${golden_timestamp}" == "${current_timestamp}" ]]; then
echo "golden and current timestamp is the same, nothing to patch"
exit 0
fi
fi

old_source_list=$(cat ${source_list_path})
sed -i 's/http:\/\/azure.archive.ubuntu.com\/ubuntu\//https:\/\/snapshot.ubuntu.com\/ubuntu\/'"${golden_timestamp}"'/g' ${source_list_path}
sed -i 's/https:\/\/snapshot.ubuntu.com\/ubuntu\/\([0-9]\{8\}T[0-9]\{6\}Z\)/https:\/\/snapshot.ubuntu.com\/ubuntu\/'"${golden_timestamp}"'/g' ${source_list_path}
option=apt_preserve_sources_list
option_value=true
cfg_set_option ${cloud_cfg_path} ${option} ${option_value}

new_source_list=$(cat ${source_list_path})
if [[ "${old_source_list}" != "${new_source_list}" ]]; then
echo "$old_source_list" > ${source_list_backup_path}
echo "/etc/apt/sources.list is updated:"
diff ${source_list_backup_path} ${source_list_path} || true
fi

if ! apt_get_update; then
echo "apt_get_update failed"
exit 1
fi
if ! unattended_upgrade; then
echo "unattended_upgrade failed"
exit 1
fi

$KUBECTL annotate --overwrite node ${node_name} kubernetes.azure.com/live-patching-current-timestamp=${golden_timestamp}

echo snapshot update completed successfully
[Service]
Type=oneshot
ExecStart=/opt/azure/containers/ubuntu-snapshot-update.sh
11 changes: 7 additions & 4 deletions pkg/agent/testdata/AKSUbuntu1604+Containerd/line134.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[Unit]
Description=Snapshot Update Service
Description=Runs snapshot update script periodically

[Service]
Type=oneshot
ExecStart=/opt/azure/containers/ubuntu-snapshot-update.sh
[Timer]
OnBootSec=10min
OnUnitActiveSec=10min

[Install]
WantedBy=multi-user.target
9 changes: 0 additions & 9 deletions pkg/agent/testdata/AKSUbuntu1604+Containerd/line141.sh

This file was deleted.

24 changes: 24 additions & 0 deletions pkg/agent/testdata/AKSUbuntu1604+Containerd/line142.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
set -x

#

MOUNT_POINT="/mnt/aks"

KUBELET_MOUNT_POINT="${MOUNT_POINT}/kubelet"
KUBELET_DIR="/var/lib/kubelet"

mkdir -p "${MOUNT_POINT}"

SENTINEL_FILE="/opt/azure/containers/bind-sentinel"
if [ ! -e "$SENTINEL_FILE" ]; then
mv "$KUBELET_DIR" "$MOUNT_POINT"
touch "$SENTINEL_FILE"
fi

mkdir -p "${KUBELET_DIR}"
mount --bind "${KUBELET_MOUNT_POINT}" "${KUBELET_DIR}"
chmod a+w "${KUBELET_DIR}"
Loading

0 comments on commit 042f15d

Please sign in to comment.