Skip to content

Commit

Permalink
refactor: containerd config registry host file to cse
Browse files Browse the repository at this point in the history
  • Loading branch information
bingosummer committed Jan 21, 2025
1 parent bcdc76b commit 6a8791f
Show file tree
Hide file tree
Showing 178 changed files with 1,434 additions and 110 deletions.
16 changes: 16 additions & 0 deletions parts/linux/cloud-init/artifacts/cse_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ EOF
echo "${CONTAINERD_CONFIG_CONTENT}" | base64 -d > /etc/containerd/config.toml || exit $ERR_FILE_WATCH_TIMEOUT
fi

if [[ -n "${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}" ]]; then
logs_to_events "AKS.CSE.ensureContainerd.configureContainerdRegistryHost" configureContainerdRegistryHost
fi

tee "/etc/sysctl.d/99-force-bridge-forward.conf" > /dev/null <<EOF
net.ipv4.ip_forward = 1
net.ipv4.conf.all.forwarding = 1
Expand All @@ -336,6 +340,18 @@ EOF
systemctlEnableAndStart containerd || exit $ERR_SYSTEMCTL_START_FAIL
}

configureContainerdRegistryHost() {
# TODO(binxi): need to update for sovereign cloud.
CONTAINERD_CONFIG_REGISTRY_HOST_MCR="/etc/containerd/certs.d/mcr.microsoft.com/hosts.toml"
mkdir -p "$(dirname "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}")"
touch "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}"
chmod 0644 "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}"
tee "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}" > /dev/null <<EOF
[host."https://${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}"]
capabilities = ["pull", "resolve"]
EOF
}

ensureNoDupOnPromiscuBridge() {
systemctlEnableAndStart ensure-no-dup || exit $ERR_SYSTEMCTL_START_FAIL
}
Expand Down
12 changes: 1 addition & 11 deletions parts/linux/cloud-init/nodecustomdata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -421,14 +421,4 @@ write_files:
encoding: gzip
owner: root
content: !!binary |
{{GetVariableProperty "cloudInitData" "customSearchDomainsScript"}}

{{- if (ne GetBootstrapProfileContainerRegistryServer "") }}
# TODO(binxi): need to update for sovereign cloud.
- path: /etc/containerd/certs.d/mcr.microsoft.com/hosts.toml
permissions: "0644"
owner: root
content: |
[host."https://{{GetBootstrapProfileContainerRegistryServer}}"]
capabilities = ["pull", "resolve"]
{{- end}}
{{GetVariableProperty "cloudInitData" "customSearchDomainsScript"}}
6 changes: 1 addition & 5 deletions pkg/agent/baker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1605,11 +1605,7 @@ oom_score = 0
ContainerRegistryServer: "testserver.azurecr.io",
},
}
}, func(o *nodeBootstrappingOutput) {
containerdConfigFileContent := o.files["/etc/containerd/certs.d/mcr.microsoft.com/hosts.toml"].value
Expect(strings.Contains(containerdConfigFileContent, "[host.\"https://testserver.azurecr.io\"]")).To(BeTrue())
Expect(strings.Contains(containerdConfigFileContent, "capabilities = [\"pull\", \"resolve\"]")).To(BeTrue())
}),
}, nil),
Entry("AKSUbuntu2204 IMDSRestriction with enable restriction and insert to mangle table", "AKSUbuntu2204+IMDSRestrictionOnWithMangleTable", "1.24.2",
func(config *datamodel.NodeBootstrappingConfiguration) {
config.EnableIMDSRestriction = true
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/testdata/AKSUbuntu1604+Containerd/CustomData

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions pkg/agent/testdata/AKSUbuntu1604+Containerd/line70.sh
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ EOF
echo "${CONTAINERD_CONFIG_CONTENT}" | base64 -d > /etc/containerd/config.toml || exit $ERR_FILE_WATCH_TIMEOUT
fi

if [[ -n "${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}" ]]; then
logs_to_events "AKS.CSE.ensureContainerd.configureContainerdRegistryHost" configureContainerdRegistryHost
fi

tee "/etc/sysctl.d/99-force-bridge-forward.conf" > /dev/null <<EOF
net.ipv4.ip_forward = 1
net.ipv4.conf.all.forwarding = 1
Expand All @@ -326,6 +330,17 @@ EOF
systemctlEnableAndStart containerd || exit $ERR_SYSTEMCTL_START_FAIL
}

configureContainerdRegistryHost() {
CONTAINERD_CONFIG_REGISTRY_HOST_MCR="/etc/containerd/certs.d/mcr.microsoft.com/hosts.toml"
mkdir -p "$(dirname "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}")"
touch "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}"
chmod 0644 "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}"
tee "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}" > /dev/null <<EOF
[host."https://${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}"]
capabilities = ["pull", "resolve"]
EOF
}

ensureNoDupOnPromiscuBridge() {
systemctlEnableAndStart ensure-no-dup || exit $ERR_SYSTEMCTL_START_FAIL
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ EOF
echo "${CONTAINERD_CONFIG_CONTENT}" | base64 -d > /etc/containerd/config.toml || exit $ERR_FILE_WATCH_TIMEOUT
fi

if [[ -n "${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}" ]]; then
logs_to_events "AKS.CSE.ensureContainerd.configureContainerdRegistryHost" configureContainerdRegistryHost
fi

tee "/etc/sysctl.d/99-force-bridge-forward.conf" > /dev/null <<EOF
net.ipv4.ip_forward = 1
net.ipv4.conf.all.forwarding = 1
Expand All @@ -326,6 +330,17 @@ EOF
systemctlEnableAndStart containerd || exit $ERR_SYSTEMCTL_START_FAIL
}

configureContainerdRegistryHost() {
CONTAINERD_CONFIG_REGISTRY_HOST_MCR="/etc/containerd/certs.d/mcr.microsoft.com/hosts.toml"
mkdir -p "$(dirname "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}")"
touch "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}"
chmod 0644 "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}"
tee "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}" > /dev/null <<EOF
[host."https://${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}"]
capabilities = ["pull", "resolve"]
EOF
}

ensureNoDupOnPromiscuBridge() {
systemctlEnableAndStart ensure-no-dup || exit $ERR_SYSTEMCTL_START_FAIL
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ EOF
echo "${CONTAINERD_CONFIG_CONTENT}" | base64 -d > /etc/containerd/config.toml || exit $ERR_FILE_WATCH_TIMEOUT
fi

if [[ -n "${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}" ]]; then
logs_to_events "AKS.CSE.ensureContainerd.configureContainerdRegistryHost" configureContainerdRegistryHost
fi

tee "/etc/sysctl.d/99-force-bridge-forward.conf" > /dev/null <<EOF
net.ipv4.ip_forward = 1
net.ipv4.conf.all.forwarding = 1
Expand All @@ -326,6 +330,17 @@ EOF
systemctlEnableAndStart containerd || exit $ERR_SYSTEMCTL_START_FAIL
}

configureContainerdRegistryHost() {
CONTAINERD_CONFIG_REGISTRY_HOST_MCR="/etc/containerd/certs.d/mcr.microsoft.com/hosts.toml"
mkdir -p "$(dirname "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}")"
touch "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}"
chmod 0644 "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}"
tee "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}" > /dev/null <<EOF
[host."https://${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}"]
capabilities = ["pull", "resolve"]
EOF
}

ensureNoDupOnPromiscuBridge() {
systemctlEnableAndStart ensure-no-dup || exit $ERR_SYSTEMCTL_START_FAIL
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ EOF
echo "${CONTAINERD_CONFIG_CONTENT}" | base64 -d > /etc/containerd/config.toml || exit $ERR_FILE_WATCH_TIMEOUT
fi

if [[ -n "${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}" ]]; then
logs_to_events "AKS.CSE.ensureContainerd.configureContainerdRegistryHost" configureContainerdRegistryHost
fi

tee "/etc/sysctl.d/99-force-bridge-forward.conf" > /dev/null <<EOF
net.ipv4.ip_forward = 1
net.ipv4.conf.all.forwarding = 1
Expand All @@ -326,6 +330,17 @@ EOF
systemctlEnableAndStart containerd || exit $ERR_SYSTEMCTL_START_FAIL
}

configureContainerdRegistryHost() {
CONTAINERD_CONFIG_REGISTRY_HOST_MCR="/etc/containerd/certs.d/mcr.microsoft.com/hosts.toml"
mkdir -p "$(dirname "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}")"
touch "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}"
chmod 0644 "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}"
tee "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}" > /dev/null <<EOF
[host."https://${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}"]
capabilities = ["pull", "resolve"]
EOF
}

ensureNoDupOnPromiscuBridge() {
systemctlEnableAndStart ensure-no-dup || exit $ERR_SYSTEMCTL_START_FAIL
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ EOF
echo "${CONTAINERD_CONFIG_CONTENT}" | base64 -d > /etc/containerd/config.toml || exit $ERR_FILE_WATCH_TIMEOUT
fi

if [[ -n "${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}" ]]; then
logs_to_events "AKS.CSE.ensureContainerd.configureContainerdRegistryHost" configureContainerdRegistryHost
fi

tee "/etc/sysctl.d/99-force-bridge-forward.conf" > /dev/null <<EOF
net.ipv4.ip_forward = 1
net.ipv4.conf.all.forwarding = 1
Expand All @@ -326,6 +330,17 @@ EOF
systemctlEnableAndStart containerd || exit $ERR_SYSTEMCTL_START_FAIL
}

configureContainerdRegistryHost() {
CONTAINERD_CONFIG_REGISTRY_HOST_MCR="/etc/containerd/certs.d/mcr.microsoft.com/hosts.toml"
mkdir -p "$(dirname "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}")"
touch "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}"
chmod 0644 "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}"
tee "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}" > /dev/null <<EOF
[host."https://${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}"]
capabilities = ["pull", "resolve"]
EOF
}

ensureNoDupOnPromiscuBridge() {
systemctlEnableAndStart ensure-no-dup || exit $ERR_SYSTEMCTL_START_FAIL
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/testdata/AKSUbuntu1604+Docker/CustomData

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions pkg/agent/testdata/AKSUbuntu1604+Docker/line70.sh
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ EOF
echo "${CONTAINERD_CONFIG_CONTENT}" | base64 -d > /etc/containerd/config.toml || exit $ERR_FILE_WATCH_TIMEOUT
fi

if [[ -n "${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}" ]]; then
logs_to_events "AKS.CSE.ensureContainerd.configureContainerdRegistryHost" configureContainerdRegistryHost
fi

tee "/etc/sysctl.d/99-force-bridge-forward.conf" > /dev/null <<EOF
net.ipv4.ip_forward = 1
net.ipv4.conf.all.forwarding = 1
Expand All @@ -326,6 +330,17 @@ EOF
systemctlEnableAndStart containerd || exit $ERR_SYSTEMCTL_START_FAIL
}

configureContainerdRegistryHost() {
CONTAINERD_CONFIG_REGISTRY_HOST_MCR="/etc/containerd/certs.d/mcr.microsoft.com/hosts.toml"
mkdir -p "$(dirname "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}")"
touch "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}"
chmod 0644 "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}"
tee "${CONTAINERD_CONFIG_REGISTRY_HOST_MCR}" > /dev/null <<EOF
[host."https://${BOOTSTRAP_PROFILE_CONTAINER_REGISTRY_SERVER}"]
capabilities = ["pull", "resolve"]
EOF
}

ensureNoDupOnPromiscuBridge() {
systemctlEnableAndStart ensure-no-dup || exit $ERR_SYSTEMCTL_START_FAIL
}
Expand Down
Loading

0 comments on commit 6a8791f

Please sign in to comment.