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

feat: STLS bootstrap integration with linux CSE #4247

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
75e0a07
feat: STLS bootstrap integration with linux CSE
Apr 5, 2024
bc9d6fa
feat: impl
Apr 5, 2024
d78b2c1
Merge branch 'master' of https://github.com/Azure/AgentBaker into cam…
Apr 5, 2024
6fa54a2
chore: remove debug code
Apr 5, 2024
5f24b0f
Merge branch 'master' of https://github.com/Azure/AgentBaker into cam…
Apr 8, 2024
5c9ca22
refactor: download binary as separate unit, don't block on enable and…
Apr 8, 2024
2cfa54b
refactor: consolidate download into single unit
Apr 9, 2024
957efa5
chore: Before=kubelet.service
Apr 9, 2024
1f6c6d8
Merge branch 'master' of https://github.com/Azure/AgentBaker into cam…
Apr 9, 2024
607a090
chore: update version
Apr 9, 2024
a7d0c67
chore: remove dep on kubelet service
Apr 9, 2024
d5f1c31
chore: typo
Apr 9, 2024
782f779
fix: unbound var
Apr 10, 2024
319c54e
fix: bump client version for fixes
Apr 11, 2024
aaead67
fix: typos
Apr 11, 2024
80f990b
chore: generate
Apr 11, 2024
164ec41
fix: properly write SP file
Apr 11, 2024
475b644
chore: generate
Apr 11, 2024
e10dea1
chore: missing var
Apr 11, 2024
d114cd4
fix: apiserver fqdn, bump client version
Apr 11, 2024
18d9edb
fix: port
Apr 11, 2024
6359791
chore: resolve conflicts
Apr 12, 2024
97efab9
fix: only specify bootstrap-kubeconfig is valid kubeconfig does not e…
Apr 12, 2024
58cbac0
chore: bump client version and specify client cert/key file paths
Apr 12, 2024
0b91a35
chore: bump client version for bug
Apr 15, 2024
c568c8a
chore: conflicts
Apr 15, 2024
ce478fc
fix: guard client cert/key pair generation from RP
Apr 15, 2024
627b8dd
Merge branch 'master' of https://github.com/Azure/AgentBaker into cam…
Apr 18, 2024
b3a0cc5
chore: bump client version again for fixes
Apr 18, 2024
7b19852
chore: better logging
Apr 24, 2024
6f0b360
chore: log service status as event
Apr 24, 2024
5201760
feat: log bootstrap journal in events
Apr 24, 2024
ed1c29a
chore: fix event logging for errs
Apr 24, 2024
2ab182e
chore: cleanup
May 1, 2024
faf33f3
chore: tweak event logging
May 1, 2024
8ce2375
chore: resolve conflicts
May 6, 2024
3e5e7e1
Merge branch 'master' of https://github.com/Azure/AgentBaker into cam…
May 6, 2024
f18ed87
Merge branch 'master' of https://github.com/Azure/AgentBaker into cam…
May 8, 2024
2ce6dba
chore: conflicts
Feb 19, 2025
bca302b
chore: diff
Feb 19, 2025
261e2c8
chore: tweaks
Feb 19, 2025
5d5ca77
chore: changes
Feb 19, 2025
1cd869b
chore: changes
Feb 19, 2025
c28f412
Merge branch 'master' of https://github.com/Azure/AgentBaker into cam…
Feb 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 1 addition & 2 deletions parts/linux/cloud-init/artifacts/cse_cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ HTTP_PROXY_URLS="{{GetHTTPProxy}}"
HTTPS_PROXY_URLS="{{GetHTTPSProxy}}"
NO_PROXY_URLS="{{GetNoProxy}}"
PROXY_VARS="{{GetProxyVariables}}"
ENABLE_TLS_BOOTSTRAPPING="{{EnableTLSBootstrapping}}"
ENABLE_SECURE_TLS_BOOTSTRAPPING="{{EnableSecureTLSBootstrapping}}"
CUSTOM_SECURE_TLS_BOOTSTRAP_AAD_SERVER_APP_ID="{{GetCustomSecureTLSBootstrapAADServerAppID}}"
CUSTOM_SECURE_TLS_BOOTSTRAP_AAD_RESOURCE="{{GetCustomSecureTLSBootstrapAADResource}}"
ENABLE_KUBELET_SERVING_CERTIFICATE_ROTATION="{{EnableKubeletServingCertificateRotation}}"
DHCPV6_SERVICE_FILEPATH="{{GetDHCPv6ServiceCSEScriptFilepath}}"
DHCPV6_CONFIG_FILEPATH="{{GetDHCPv6ConfigCSEScriptFilepath}}"
Expand Down
185 changes: 110 additions & 75 deletions parts/linux/cloud-init/artifacts/cse_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Environment="KUBE_API_SERVER_NAME=${API_SERVER_NAME}"
EOF
systemctlEnableAndStart reconcile-private-hosts || exit $ERR_SYSTEMCTL_START_FAIL
}

configureTransparentHugePage() {
ETC_SYSFS_CONF="/etc/sysfs.conf"
if [[ "${THP_ENABLED}" != "" ]]; then
Expand Down Expand Up @@ -164,36 +165,24 @@ EOF
systemctl restart containerd
}

configureK8s() {
mkdir -p "/etc/kubernetes/certs"

APISERVER_PUBLIC_KEY_PATH="/etc/kubernetes/certs/apiserver.crt"
touch "${APISERVER_PUBLIC_KEY_PATH}"
chmod 0644 "${APISERVER_PUBLIC_KEY_PATH}"
chown root:root "${APISERVER_PUBLIC_KEY_PATH}"
configureAzureJson() {
mkdir -p "/etc/kubernetes/"

AZURE_JSON_PATH="/etc/kubernetes/azure.json"
touch "${AZURE_JSON_PATH}"
chmod 0600 "${AZURE_JSON_PATH}"
chown root:root "${AZURE_JSON_PATH}"

set +x
if [ -n "${KUBELET_CLIENT_CONTENT}" ]; then
echo "${KUBELET_CLIENT_CONTENT}" | base64 -d > /etc/kubernetes/certs/client.key
fi
if [ -n "${KUBELET_CLIENT_CERT_CONTENT}" ]; then
echo "${KUBELET_CLIENT_CERT_CONTENT}" | base64 -d > /etc/kubernetes/certs/client.crt
fi
if [ -n "${SERVICE_PRINCIPAL_FILE_CONTENT}" ]; then
echo "${SERVICE_PRINCIPAL_FILE_CONTENT}" | base64 -d > /etc/kubernetes/sp.txt
SP_FILE="/etc/kubernetes/sp.txt"
echo "${SERVICE_PRINCIPAL_FILE_CONTENT}" | base64 -d > "$SP_FILE"
SERVICE_PRINCIPAL_CLIENT_SECRET="$(cat "$SP_FILE")"
SERVICE_PRINCIPAL_CLIENT_SECRET=${SERVICE_PRINCIPAL_CLIENT_SECRET//\\/\\\\}
SERVICE_PRINCIPAL_CLIENT_SECRET=${SERVICE_PRINCIPAL_CLIENT_SECRET//\"/\\\"}
rm "$SP_FILE"
fi

echo "${APISERVER_PUBLIC_KEY}" | base64 --decode > "${APISERVER_PUBLIC_KEY_PATH}"
SP_FILE="/etc/kubernetes/sp.txt"
SERVICE_PRINCIPAL_CLIENT_SECRET="$(cat "$SP_FILE")"
SERVICE_PRINCIPAL_CLIENT_SECRET=${SERVICE_PRINCIPAL_CLIENT_SECRET//\\/\\\\}
SERVICE_PRINCIPAL_CLIENT_SECRET=${SERVICE_PRINCIPAL_CLIENT_SECRET//\"/\\\"}
rm "$SP_FILE"

cat << EOF > "${AZURE_JSON_PATH}"
{
"cloud": "${TARGET_CLOUD}",
Expand Down Expand Up @@ -235,6 +224,42 @@ configureK8s() {
}
EOF
set -x
}

ensureKubeCAFile() {
KUBE_CA_FILE="/etc/kubernetes/certs/ca.crt"
mkdir -p "$(dirname "${KUBE_CA_FILE}")"
echo "${KUBE_CA_CRT}" | base64 -d > "${KUBE_CA_FILE}"
chmod 0644 "${KUBE_CA_FILE}"
}

configureK8s() {
mkdir -p "/etc/kubernetes/certs"

APISERVER_PUBLIC_KEY_PATH="/etc/kubernetes/certs/apiserver.crt"
touch "${APISERVER_PUBLIC_KEY_PATH}"
chmod 0644 "${APISERVER_PUBLIC_KEY_PATH}"
chown root:root "${APISERVER_PUBLIC_KEY_PATH}"

if [ -n "${APISERVER_PUBLIC_KEY}" ]; then
set +x
echo "${APISERVER_PUBLIC_KEY}" | base64 --decode > "${APISERVER_PUBLIC_KEY_PATH}"
set -x
fi

if [ "$ENABLE_SECURE_TLS_BOOTSTRAPPING" == "false" ] && [ -z "$TLS_BOOTSTRAP_TOKEN" ]; then
# we guard the following cert creation logic since it seems RP always gives agentbaker a kubelet client cert/key pair
# regardless of whether the node is being bootstrapped with some flavor of TLS bootstrapping
set +x
if [ -n "${KUBELET_CLIENT_CONTENT}" ]; then
echo "${KUBELET_CLIENT_CONTENT}" | base64 -d > /etc/kubernetes/certs/client.key
fi
if [ -n "${KUBELET_CLIENT_CERT_CONTENT}" ]; then
echo "${KUBELET_CLIENT_CERT_CONTENT}" | base64 -d > /etc/kubernetes/certs/client.crt
fi
set -x
fi

if [[ "${CLOUDPROVIDER_BACKOFF_MODE}" = "v2" ]]; then
sed -i "/cloudProviderBackoffExponent/d" /etc/kubernetes/azure.json
sed -i "/cloudProviderBackoffJitter/d" /etc/kubernetes/azure.json
Expand Down Expand Up @@ -421,6 +446,47 @@ getPrimaryNicIP() {
echo "$ip"
}

configureSecureTLSBootstrap() {
# default AAD resource here so we can minimze bootstrap contract surface
AAD_RESOURCE="6dae42f8-4368-4678-94ff-3960e28e3630"
if [ -n "$CUSTOM_SECURE_TLS_BOOTSTRAP_AAD_RESOURCE" ]; then
AAD_RESOURCE="$CUSTOM_SECURE_TLS_BOOTSTRAP_AAD_RESOURCE"
fi

SECURE_TLS_BOOTSTRAPPING_DROP_IN="/etc/systemd/system/secure-tls-bootstrap.service.d/10-securetlsbootstrap.conf"
touch "${SECURE_TLS_BOOTSTRAPPING_DROP_IN}"
chmod 0600 "${SECURE_TLS_BOOTSTRAPPING_DROP_IN}"

cat > "${SECURE_TLS_BOOTSTRAPPING_DROP_IN}" <<EOF
[Service]
Environment="API_SERVER_NAME=${API_SERVER_NAME}"
Environment="AAD_RESOURCE=${AAD_RESOURCE}"
EOF
}

ensureSecureTLSBootstrap() {
KUBECONFIG_FILE=/var/lib/kubelet/kubeconfig

SECURE_TLS_BOOTSTRAP_STATUS="$(systemctl is-active secure-tls-bootstrap)"
while [ "$SECURE_TLS_BOOTSTRAP_STATUS" == "activating" ]; do
echo "secure TLS bootstrapping is in-progress, waiting for terminal state..."
sleep 0.5
SECURE_TLS_BOOTSTRAP_STATUS="$(systemctl is-active secure-tls-bootstrap)"
done

if [ "$SECURE_TLS_BOOTSTRAP_STATUS" == "failed" ] || [ "$SECURE_TLS_BOOTSTRAP_STATUS" == "is-failed" ]; then
systemctl status secure-tls-bootstrap --no-pager -l
journalctl -u secure-tls-bootstrap
exit $ERR_SECURE_TLS_BOOTSTRAP_CLIENT_FAIL # exit hard here until ready for preview
fi

if [ ! -f "$KUBECONFIG_FILE" ]; then
systemctl status secure-tls-bootstrap --no-pager -l
journalctl -u secure-tls-bootstrap
exit $ERR_SECURE_TLS_BOOTSTRAP_MISSING_KUBECONFIG # exit hard here until ready for preview
fi
}

generateSelfSignedKubeletServingCertificate() {
mkdir -p "/etc/kubernetes/certs"

Expand Down Expand Up @@ -512,66 +578,28 @@ ensureKubelet() {
if [ -n "${AZURE_ENVIRONMENT_FILEPATH}" ]; then
echo "AZURE_ENVIRONMENT_FILEPATH=${AZURE_ENVIRONMENT_FILEPATH}" >> "${KUBELET_DEFAULT_FILE}"
fi
chmod 0600 "${KUBELET_DEFAULT_FILE}"

KUBE_CA_FILE="/etc/kubernetes/certs/ca.crt"
mkdir -p "$(dirname "${KUBE_CA_FILE}")"
echo "${KUBE_CA_CRT}" | base64 -d > "${KUBE_CA_FILE}"
chmod 0600 "${KUBE_CA_FILE}"

if [ "${ENABLE_SECURE_TLS_BOOTSTRAPPING}" == "true" ] || [ "${ENABLE_TLS_BOOTSTRAPPING}" == "true" ]; then
KUBECONFIG_FILE=/var/lib/kubelet/kubeconfig

if [ "${ENABLE_SECURE_TLS_BOOTSTRAPPING}" == "true" ] || [ -n "$TLS_BOOTSTRAP_TOKEN" ]; then
KUBELET_TLS_DROP_IN="/etc/systemd/system/kubelet.service.d/10-tlsbootstrap.conf"
mkdir -p "$(dirname "${KUBELET_TLS_DROP_IN}")"
touch "${KUBELET_TLS_DROP_IN}"
chmod 0600 "${KUBELET_TLS_DROP_IN}"
tee "${KUBELET_TLS_DROP_IN}" > /dev/null <<EOF

if [ ! -f "$KUBECONFIG_FILE" ]; then
# if we don't have a kubelet config file, meaning that we are either bootstrapping with vanilla TLS bootstrapping
# or with secure TLS bootstrapping but the bootstrapping process failed, then specify the bootstrap-kubeconfig file
# so kubelet can request its own certificate
tee "${KUBELET_TLS_DROP_IN}" > /dev/null <<EOF
[Service]
Environment="KUBELET_TLS_BOOTSTRAP_FLAGS=--kubeconfig /var/lib/kubelet/kubeconfig --bootstrap-kubeconfig /var/lib/kubelet/bootstrap-kubeconfig"
EOF
fi

if [ "${ENABLE_SECURE_TLS_BOOTSTRAPPING}" == "true" ]; then
AAD_RESOURCE="6dae42f8-4368-4678-94ff-3960e28e3630"
if [ -n "$CUSTOM_SECURE_TLS_BOOTSTRAP_AAD_SERVER_APP_ID" ]; then
AAD_RESOURCE=$CUSTOM_SECURE_TLS_BOOTSTRAP_AAD_SERVER_APP_ID
fi
SECURE_BOOTSTRAP_KUBECONFIG_FILE=/var/lib/kubelet/bootstrap-kubeconfig
mkdir -p "$(dirname "${SECURE_BOOTSTRAP_KUBECONFIG_FILE}")"
touch "${SECURE_BOOTSTRAP_KUBECONFIG_FILE}"
chmod 0644 "${SECURE_BOOTSTRAP_KUBECONFIG_FILE}"
tee "${SECURE_BOOTSTRAP_KUBECONFIG_FILE}" > /dev/null <<EOF
apiVersion: v1
kind: Config
clusters:
- name: localcluster
cluster:
certificate-authority: /etc/kubernetes/certs/ca.crt
server: https://${API_SERVER_NAME}:443
users:
- name: kubelet-bootstrap
user:
exec:
apiVersion: client.authentication.k8s.io/v1
command: /opt/azure/tlsbootstrap/tls-bootstrap-client
args:
- bootstrap
- --next-proto=aks-tls-bootstrap
- --aad-resource=${AAD_RESOURCE}
interactiveMode: Never
provideClusterInfo: true
contexts:
- context:
cluster: localcluster
user: kubelet-bootstrap
name: bootstrap-context
current-context: bootstrap-context
EOF
elif [ "${ENABLE_TLS_BOOTSTRAPPING}" == "true" ]; then
BOOTSTRAP_KUBECONFIG_FILE=/var/lib/kubelet/bootstrap-kubeconfig
mkdir -p "$(dirname "${BOOTSTRAP_KUBECONFIG_FILE}")"
touch "${BOOTSTRAP_KUBECONFIG_FILE}"
chmod 0644 "${BOOTSTRAP_KUBECONFIG_FILE}"
tee "${BOOTSTRAP_KUBECONFIG_FILE}" > /dev/null <<EOF
BOOTSTRAP_KUBECONFIG_FILE=/var/lib/kubelet/bootstrap-kubeconfig
mkdir -p "$(dirname "${BOOTSTRAP_KUBECONFIG_FILE}")"
touch "${BOOTSTRAP_KUBECONFIG_FILE}"
chmod 0644 "${BOOTSTRAP_KUBECONFIG_FILE}"
tee "${BOOTSTRAP_KUBECONFIG_FILE}" > /dev/null <<EOF
apiVersion: v1
kind: Config
clusters:
Expand All @@ -590,8 +618,15 @@ contexts:
name: bootstrap-context
current-context: bootstrap-context
EOF
else
# otherwise, if we already have a kubeconfig we can use, omit the bootstrap-kubeconfig flag
# so kubelet doesn't try to request its own certificate
tee "${KUBELET_TLS_DROP_IN}" > /dev/null <<EOF
[Service]
Environment="KUBELET_TLS_BOOTSTRAP_FLAGS=--kubeconfig /var/lib/kubelet/kubeconfig"
EOF
fi
else
KUBECONFIG_FILE=/var/lib/kubelet/kubeconfig
mkdir -p "$(dirname "${KUBECONFIG_FILE}")"
touch "${KUBECONFIG_FILE}"
chmod 0644 "${KUBECONFIG_FILE}"
Expand Down
32 changes: 31 additions & 1 deletion parts/linux/cloud-init/artifacts/cse_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ ERR_ARTIFACT_STREAMING_INSTALL=153 # Error installing mirror proxy and overlaybd

ERR_HTTP_PROXY_CA_CONVERT=160 # Error converting http proxy ca cert from pem to crt format
ERR_UPDATE_CA_CERTS=161 # Error updating ca certs to include user-provided certificates
ERR_DOWNLOAD_SECURE_TLS_BOOTSTRAP_KUBELET_EXEC_PLUGIN_TIMEOUT=169 # Timeout waiting for secure TLS bootrstrap kubelet exec plugin download
ERR_SECURE_TLS_BOOTSTRAP_CLIENT_FAIL=167 # Error generating kubelet client credential via the secure TLS bootstrap client
ERR_SECURE_TLS_BOOTSTRAP_MISSING_KUBECONFIG=168 # Unable to find kubeconfig after completion of secure TLS bootstrapping
ERR_DOWNLOAD_SECURE_TLS_BOOTSTRAP_CLIENT=169 # Error downloading the secure TLS bootstrapping client

ERR_DISBALE_IPTABLES=170 # Error disabling iptables service

Expand Down Expand Up @@ -372,6 +374,20 @@ systemctl_restart() {
fi
done
}
systemctl_restart_noblock() {
retries=$1; wait_sleep=$2; timeout=$3 svcname=$4
for i in $(seq 1 $retries); do
timeout $timeout systemctl daemon-reload
timeout $timeout systemctl restart $svcname --no-block && break || \
if [ $i -eq $retries ]; then
return 1
else
systemctl status $svcname --no-pager -l
journalctl -u $svcname
sleep $wait_sleep
fi
done
}
systemctl_stop() {
retries=$1; wait_sleep=$2; timeout=$3 svcname=$4
for i in $(seq 1 $retries); do
Expand Down Expand Up @@ -425,6 +441,20 @@ systemctlEnableAndStart() {
fi
}

systemctlEnableAndStartNoBlock() {
systemctl_restart_noblock 100 5 30 $1
RESTART_STATUS=$?
systemctl status $1 --no-pager -l > /var/log/azure/$1-status.log
if [ $RESTART_STATUS -ne 0 ]; then
echo "$1 could not be started"
return 1
fi
if ! retrycmd_if_failure 120 5 25 systemctl enable --no-block $1; then
echo "$1 could not be enabled by systemctl"
return 1
fi
}

systemctlDisableAndStop() {
if systemctl list-units --full --all | grep -q "$1.service"; then
systemctl_stop 20 5 25 $1 || echo "$1 could not be stopped"
Expand Down
23 changes: 10 additions & 13 deletions parts/linux/cloud-init/artifacts/cse_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ K8S_REGISTRY_REPO="oss/binaries/kubernetes"
UBUNTU_RELEASE=$(lsb_release -r -s)
# For Mariner 2.0, this returns "MARINER" and for AzureLinux 3.0, this returns "AZURELINUX"
OS=$(if ls /etc/*-release 1> /dev/null 2>&1; then sort -r /etc/*-release | gawk 'match($0, /^(ID_LIKE=(coreos)|ID=(.*))$/, a) { print toupper(a[2] a[3]); exit }'; fi)
SECURE_TLS_BOOTSTRAP_KUBELET_EXEC_PLUGIN_DOWNLOAD_DIR="/opt/azure/tlsbootstrap"
SECURE_TLS_BOOTSTRAP_KUBELET_EXEC_PLUGIN_VERSION="v0.1.0-alpha.2"
SECURE_TLS_BOOTSTRAP_CLIENT_BIN_DIR="/opt/azure/containers/aks-secure-tls-bootstrap-client"
TELEPORTD_PLUGIN_DOWNLOAD_DIR="/opt/teleportd/downloads"
CREDENTIAL_PROVIDER_DOWNLOAD_DIR="/opt/credentialprovider/downloads"
CREDENTIAL_PROVIDER_BIN_DIR="/var/lib/kubelet/credential-provider"
Expand Down Expand Up @@ -193,19 +192,17 @@ installCredentialProvider() {
rm -rf ${CREDENTIAL_PROVIDER_DOWNLOAD_DIR}
}

downloadSecureTLSBootstrapKubeletExecPlugin() {
local plugin_url="https://k8sreleases.blob.core.windows.net/aks-tls-bootstrap-client/${SECURE_TLS_BOOTSTRAP_KUBELET_EXEC_PLUGIN_VERSION}/linux/amd64/tls-bootstrap-client"
downloadSecureTLSBootstrapClient() {
# TODO(cameissner): move to components.json
local client_version="v0.1.0-alpha.5"
local client_download_url="https://stlsbootstrap.z22.web.core.windows.net/client/linux/amd64/${client_version}"
if [[ $(isARM64) == 1 ]]; then
plugin_url="https://k8sreleases.blob.core.windows.net/aks-tls-bootstrap-client/${SECURE_TLS_BOOTSTRAP_KUBELET_EXEC_PLUGIN_VERSION}/linux/arm64/tls-bootstrap-client"
client_download_url="https://stlsbootstrap.z22.web.core.windows.net/client/linux/arm64/${client_version}"
fi

mkdir -p $SECURE_TLS_BOOTSTRAP_KUBELET_EXEC_PLUGIN_DOWNLOAD_DIR
plugin_download_path="${SECURE_TLS_BOOTSTRAP_KUBELET_EXEC_PLUGIN_DOWNLOAD_DIR}/tls-bootstrap-client"

if [ ! -f "$plugin_download_path" ]; then
retrycmd_if_failure 30 5 60 curl -fSL -o "$plugin_download_path" "$plugin_url" || exit $ERR_DOWNLOAD_SECURE_TLS_BOOTSTRAP_KUBELET_EXEC_PLUGIN_TIMEOUT
chown -R root:root "$SECURE_TLS_BOOTSTRAP_KUBELET_EXEC_PLUGIN_DOWNLOAD_DIR"
chmod -R 755 "$SECURE_TLS_BOOTSTRAP_KUBELET_EXEC_PLUGIN_DOWNLOAD_DIR"

mkdir -p "/opt/azure/containers"
if ! retrycmd_if_failure 30 5 60 curl -fSL -o "$SECURE_TLS_BOOTSTRAP_CLIENT_BIN_DIR" "$client_download_url"; then
exit $ERR_DOWNLOAD_SECURE_TLS_BOOTSTRAP_CLIENT
fi
}

Expand Down
20 changes: 16 additions & 4 deletions parts/linux/cloud-init/artifacts/cse_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ source "${CSE_INSTALL_FILEPATH}"
source "${CSE_DISTRO_INSTALL_FILEPATH}"
source "${CSE_CONFIG_FILEPATH}"

logs_to_events "AKS.CSE.ensureKubeCAFile" ensureKubeCAFile

logs_to_events "AKS.CSE.configureAzureJson" configureAzureJson

if [ "${ENABLE_SECURE_TLS_BOOTSTRAPPING}" == "true" ]; then
# for now we download it so we don't have to cache it on the VHD, once it's always cached we won't need this step
logs_to_events "AKS.CSE.downloadSecureTLSBootstrapClient" downloadSecureTLSBootstrapClient
logs_to_events "AKS.CSE.configureSecureTLSBootstrap" configureSecureTLSBootstrap
logs_to_events "AKS.CSE.start.SecureTLSBootstrap" systemctlEnableAndStartNoBlock secure-tls-bootstrap
fi

if [[ "${DISABLE_SSH}" == "true" ]]; then
disableSSH || exit $ERR_DISABLE_SSH
fi
Expand Down Expand Up @@ -149,10 +160,6 @@ if [ "${IS_KRUSTLET}" == "true" ]; then
logs_to_events "AKS.CSE.installSpinKube" installSpinKube "$downloadURSpinKube" "$downloadLocationSpinKube" "$versionsSpinKube"
fi

if [ "${ENABLE_SECURE_TLS_BOOTSTRAPPING}" == "true" ]; then
logs_to_events "AKS.CSE.downloadSecureTLSBootstrapKubeletExecPlugin" downloadSecureTLSBootstrapKubeletExecPlugin
fi

# By default, never reboot new nodes.
REBOOTREQUIRED=false

Expand Down Expand Up @@ -329,7 +336,12 @@ if [ "${NEEDS_CONTAINERD}" == "true" ] && [ "${SHOULD_CONFIG_CONTAINERD_ULIMITS
logs_to_events "AKS.CSE.setContainerdUlimits" configureContainerdUlimits
fi

if [ "${ENABLE_SECURE_TLS_BOOTSTRAPPING}" == "true" ]; then
logs_to_events "AKS.CSE.ensureSecureTLSBootstrap" ensureSecureTLSBootstrap
fi

logs_to_events "AKS.CSE.ensureKubelet" ensureKubelet

if [ "${ENSURE_NO_DUPE_PROMISCUOUS_BRIDGE}" == "true" ]; then
logs_to_events "AKS.CSE.ensureNoDupOnPromiscuBridge" ensureNoDupOnPromiscuBridge
fi
Expand Down
10 changes: 10 additions & 0 deletions parts/linux/cloud-init/artifacts/secure-tls-bootstrap.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Runs the secure TLS bootstrapping client binary to generate a kubelet client credential
Wants=network-online.target
After=network-online.target
Before=kubelet.service

[Service]
Type=oneshot
ExecStart=/opt/azure/containers/secure-tls-bootstrap.sh
RemainAfterExit=No
Loading
Loading