Skip to content

Commit

Permalink
feat: add EnableSecureTLSBootstrapping to bootstrap config (#3653)
Browse files Browse the repository at this point in the history
Co-authored-by: Cameron Meissner <[email protected]>
  • Loading branch information
cameronmeissner and Cameron Meissner authored Sep 28, 2023
1 parent c32a4b6 commit 1ad396c
Show file tree
Hide file tree
Showing 229 changed files with 3,282 additions and 221 deletions.
3 changes: 2 additions & 1 deletion parts/linux/cloud-init/artifacts/cse_cmd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ HTTP_PROXY_URLS="{{GetHTTPProxy}}"
HTTPS_PROXY_URLS="{{GetHTTPSProxy}}"
NO_PROXY_URLS="{{GetNoProxy}}"
PROXY_VARS="{{GetProxyVariables}}"
CLIENT_TLS_BOOTSTRAPPING_ENABLED="{{IsKubeletClientTLSBootstrappingEnabled}}"
ENABLE_TLS_BOOTSTRAPPING="{{EnableTLSBootstrapping}}"
ENABLE_SECURE_TLS_BOOTSTRAPPING="{{EnableSecureTLSBootstrapping}}"
DHCPV6_SERVICE_FILEPATH="{{GetDHCPv6ServiceCSEScriptFilepath}}"
DHCPV6_CONFIG_FILEPATH="{{GetDHCPv6ConfigCSEScriptFilepath}}"
THP_ENABLED="{{GetTransparentHugePageEnabled}}"
Expand Down
2 changes: 1 addition & 1 deletion parts/linux/cloud-init/artifacts/cse_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ ensureKubelet() {
echo "${KUBE_CA_CRT}" | base64 -d > "${KUBE_CA_FILE}"
chmod 0600 "${KUBE_CA_FILE}"

if [ "${CLIENT_TLS_BOOTSTRAPPING_ENABLED}" == "true" ]; then
if [ "${ENABLE_TLS_BOOTSTRAPPING}" == "true" ]; 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}"
Expand Down
2 changes: 1 addition & 1 deletion parts/linux/cloud-init/nodecustomdata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ write_files:
AZURE_ENVIRONMENT_FILEPATH=/etc/kubernetes/{{GetTargetEnvironment}}.json
{{- end}}

{{ if IsKubeletClientTLSBootstrappingEnabled -}}
{{ if EnableTLSBootstrapping -}}
- path: /var/lib/kubelet/bootstrap-kubeconfig
permissions: "0644"
owner: root
Expand Down
11 changes: 8 additions & 3 deletions pkg/agent/baker.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func validateAndSetLinuxNodeBootstrappingConfiguration(config *datamodel.NodeBoo
}

func validateAndSetWindowsNodeBootstrappingConfiguration(config *datamodel.NodeBootstrappingConfiguration) {
if IsKubeletClientTLSBootstrappingEnabled(config.KubeletClientTLSBootstrapToken) {
if IsTLSBootstrappingEnabledWithHardCodedToken(config.KubeletClientTLSBootstrapToken) {
// backfill proper flags for Windows agent node TLS bootstrapping
if config.KubeletConfig == nil {
config.KubeletConfig = make(map[string]string)
Expand Down Expand Up @@ -378,8 +378,13 @@ func getContainerServiceFuncMap(config *datamodel.NodeBootstrappingConfiguration
"IsKubeletConfigFileEnabled": func() bool {
return IsKubeletConfigFileEnabled(cs, profile, config.EnableKubeletConfigFile)
},
"IsKubeletClientTLSBootstrappingEnabled": func() bool {
return IsKubeletClientTLSBootstrappingEnabled(config.KubeletClientTLSBootstrapToken)
"EnableTLSBootstrapping": func() bool {
// this will be true when we get a hard-coded TLS bootstrap token in the NodeBootstrappingConfiguration to use for performing TLS bootstrapping.
return IsTLSBootstrappingEnabledWithHardCodedToken(config.KubeletClientTLSBootstrapToken)
},
"EnableSecureTLSBootstrapping": func() bool {
// this will be true when we can perform TLS bootstrapping without the use of a hard-coded bootstrap token.
return config.EnableSecureTLSBootstrapping
},
"GetTLSBootstrapTokenForKubeConfig": func() string {
return GetTLSBootstrapTokenForKubeConfig(config.KubeletClientTLSBootstrapToken)
Expand Down
7 changes: 7 additions & 0 deletions pkg/agent/baker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,13 @@ var _ = Describe("Assert generated customData and cseCmd", func() {
Expect(caCRT).NotTo(BeEmpty())
}),

Entry("AKSUbuntu2204 with secure TLS bootstrapping enabled", "AKSUbuntu2204+SecureTLSBoostrapping", "1.25.6",
func(config *datamodel.NodeBootstrappingConfiguration) {
config.EnableSecureTLSBootstrapping = true
}, func(o *nodeBootstrappingOutput) {
Expect(o.vars["ENABLE_SECURE_TLS_BOOTSTRAPPING"]).To(Equal("true"))
}),

Entry("AKSUbuntu1804 with DisableCustomData = true", "AKSUbuntu1804+DisableCustomData", "1.19.0",
func(config *datamodel.NodeBootstrappingConfiguration) {
config.ContainerService.Properties.AgentPoolProfiles[0].KubernetesConfig = &datamodel.KubernetesConfig{
Expand Down
30 changes: 17 additions & 13 deletions pkg/agent/datamodel/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1645,19 +1645,23 @@ type NodeBootstrappingConfiguration struct {
kubeconfig. */
// ref: https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet-tls-bootstrapping.
KubeletClientTLSBootstrapToken *string
FIPSEnabled bool
HTTPProxyConfig *HTTPProxyConfig
KubeletConfig map[string]string
KubeproxyConfig map[string]string
EnableRuncShimV2 bool
GPUInstanceProfile string
PrimaryScaleSetName string
SIGConfig SIGConfig
IsARM64 bool
CustomCATrustConfig *CustomCATrustConfig
DisableUnattendedUpgrades bool
SSHStatus SSHStatus
DisableCustomData bool
// EnableSecureTLSBootstraping - when this feature is enabled we don't hard-code TLS bootstrap tokens at all,
// instead we create a modified bootstrap kubeconfig which points towards the STLS bootstrap client-go
// credential plugin installed on the VHD, which will be responsible for generating TLS bootstrap tokens on the fly
EnableSecureTLSBootstrapping bool
FIPSEnabled bool
HTTPProxyConfig *HTTPProxyConfig
KubeletConfig map[string]string
KubeproxyConfig map[string]string
EnableRuncShimV2 bool
GPUInstanceProfile string
PrimaryScaleSetName string
SIGConfig SIGConfig
IsARM64 bool
CustomCATrustConfig *CustomCATrustConfig
DisableUnattendedUpgrades bool
SSHStatus SSHStatus
DisableCustomData bool
}

type SSHStatus int
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/testdata/AKSUbuntu1604+Containerd/CSECommand

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/agent/testdata/AKSUbuntu1604+Containerd/CustomData

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/agent/testdata/AKSUbuntu1604+Containerd/line70.sh
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ ensureKubelet() {
echo "${KUBE_CA_CRT}" | base64 -d > "${KUBE_CA_FILE}"
chmod 0600 "${KUBE_CA_FILE}"

if [ "${CLIENT_TLS_BOOTSTRAPPING_ENABLED}" == "true" ]; then
if [ "${ENABLE_TLS_BOOTSTRAPPING}" == "true" ]; 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}"
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ ensureKubelet() {
echo "${KUBE_CA_CRT}" | base64 -d > "${KUBE_CA_FILE}"
chmod 0600 "${KUBE_CA_FILE}"

if [ "${CLIENT_TLS_BOOTSTRAPPING_ENABLED}" == "true" ]; then
if [ "${ENABLE_TLS_BOOTSTRAPPING}" == "true" ]; 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}"
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ ensureKubelet() {
echo "${KUBE_CA_CRT}" | base64 -d > "${KUBE_CA_FILE}"
chmod 0600 "${KUBE_CA_FILE}"

if [ "${CLIENT_TLS_BOOTSTRAPPING_ENABLED}" == "true" ]; then
if [ "${ENABLE_TLS_BOOTSTRAPPING}" == "true" ]; 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}"
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ ensureKubelet() {
echo "${KUBE_CA_CRT}" | base64 -d > "${KUBE_CA_FILE}"
chmod 0600 "${KUBE_CA_FILE}"

if [ "${CLIENT_TLS_BOOTSTRAPPING_ENABLED}" == "true" ]; then
if [ "${ENABLE_TLS_BOOTSTRAPPING}" == "true" ]; 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}"
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ ensureKubelet() {
echo "${KUBE_CA_CRT}" | base64 -d > "${KUBE_CA_FILE}"
chmod 0600 "${KUBE_CA_FILE}"

if [ "${CLIENT_TLS_BOOTSTRAPPING_ENABLED}" == "true" ]; then
if [ "${ENABLE_TLS_BOOTSTRAPPING}" == "true" ]; 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}"
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/testdata/AKSUbuntu1604+Docker/CSECommand

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/agent/testdata/AKSUbuntu1604+Docker/CustomData

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/agent/testdata/AKSUbuntu1604+Docker/line70.sh
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ ensureKubelet() {
echo "${KUBE_CA_CRT}" | base64 -d > "${KUBE_CA_FILE}"
chmod 0600 "${KUBE_CA_FILE}"

if [ "${CLIENT_TLS_BOOTSTRAPPING_ENABLED}" == "true" ]; then
if [ "${ENABLE_TLS_BOOTSTRAPPING}" == "true" ]; 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}"
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ ensureKubelet() {
echo "${KUBE_CA_CRT}" | base64 -d > "${KUBE_CA_FILE}"
chmod 0600 "${KUBE_CA_FILE}"

if [ "${CLIENT_TLS_BOOTSTRAPPING_ENABLED}" == "true" ]; then
if [ "${ENABLE_TLS_BOOTSTRAPPING}" == "true" ]; 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}"
Expand Down
Loading

0 comments on commit 1ad396c

Please sign in to comment.