Skip to content

Commit

Permalink
Merge branch 'master' into mitchzhu/kata-support
Browse files Browse the repository at this point in the history
  • Loading branch information
miz060 committed Sep 13, 2024
2 parents 52422cd + 3425fe5 commit 753cf29
Show file tree
Hide file tree
Showing 957 changed files with 142,707 additions and 26,168 deletions.
11 changes: 11 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@
],
"datasourceTemplate": "docker",
"registryUrlTemplate": "https://mcr.microsoft.com"
},
{
"customType": "regex",
"description": "update version line in any cse_*.sh",
"fileMatch": [
"^.*cse_.*\\.sh"
],
"matchStringsStrategy": "any",
"matchStrings": [
"#\\s*renovate:\\s*(datasource=(?<datasource>.*?) )?depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\s*.*?version.*\\\"(?<currentValue>.*)\\\""
]
}
]
}
5 changes: 5 additions & 0 deletions .pipelines/templates/.builder-release-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ steps:
-e BLOB_URL=${BLOB_URL} \
-e SEVERITY=${SEVERITY} \
-e MODULE_VERSION=${MODULE_VERSION} \
-e BUILD_REPOSITORY_NAME=$(Build.Repository.Name) \
-e BUILD_SOURCEVERSION=$(Build.SourceVersion) \
-e SYSTEM_COLLECTIONURI=$(System.CollectionUri) \
-e SYSTEM_TEAMPROJECT=$(System.TeamProject) \
-e BUILD_RUN_NUMBER=$(Build.BuildNumber) \
${CONTAINER_IMAGE} make -f packer.mk test-scan-and-cleanup
condition: always()
displayName: Test, Scan, and Cleanup
Expand Down
8 changes: 8 additions & 0 deletions e2e/config/vhd.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ var (
Arch: "amd64",
Version: "1.1704411049.2812",
}

// without kubelet, kubectl, credential-provider and wasm
VHDUbuntu2204Gen2ContainerdAirgapped = &Image{
Name: "2204gen2containerd",
OS: "ubuntu",
Arch: "amd64",
Version: "1.1725612526.29638",
}
)

var ErrNotFound = fmt.Errorf("not found")
Expand Down
4 changes: 3 additions & 1 deletion e2e/scenario_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ func executeScenario(ctx context.Context, t *testing.T, opts *scenarioRunOpts) {
t.Logf("vmss %s creation succeeded, proceeding with node readiness and pod checks...", vmssName)
nodeName := validateNodeHealth(ctx, t, opts.clusterConfig.Kube, vmssName)

if opts.nbc.AgentPoolProfile.WorkloadRuntime == datamodel.WasmWasi {
// skip when outbound type is block as the wasm will create pod from gcr, however, network isolated cluster scenario will block egress traffic of gcr.
// TODO(xinhl): add another way to validate
if opts.nbc.AgentPoolProfile.WorkloadRuntime == datamodel.WasmWasi && (opts.nbc.OutboundType != datamodel.OutboundTypeBlock && opts.nbc.OutboundType != datamodel.OutboundTypeNone) {
validateWasm(ctx, t, opts.clusterConfig.Kube, nodeName)
}

Expand Down
252 changes: 232 additions & 20 deletions e2e/scenario_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func Test_azurelinuxv2(t *testing.T) {
LiveVMValidators: []*LiveVMValidator{
containerdVersionValidator("1.6.26"),
runcVersionValidator("1.1.9"),
kubeletNodeIPValidator(),
},
},
})
Expand All @@ -44,7 +43,6 @@ func Test_azurelinuxv2AirGap(t *testing.T) {
nbc.ContainerService.Properties.AgentPoolProfiles[0].Distro = "aks-azurelinux-v2-gen2"
nbc.AgentPoolProfile.Distro = "aks-azurelinux-v2-gen2"

// TODO(xinhl): define below in the cluster config instead of mutate bootstrapConfig
nbc.OutboundType = datamodel.OutboundTypeBlock
nbc.ContainerService.Properties.SecurityProfile = &datamodel.SecurityProfile{
PrivateEgress: &datamodel.PrivateEgress{
Expand Down Expand Up @@ -95,7 +93,6 @@ func Test_azurelinuxv2ARM64AirGap(t *testing.T) {
nbc.AgentPoolProfile.Distro = "aks-azurelinux-v2-arm64-gen2"
nbc.IsARM64 = true

// TODO(xinhl): define below in the cluster config instead of mutate bootstrapConfig
nbc.OutboundType = datamodel.OutboundTypeBlock
nbc.ContainerService.Properties.SecurityProfile = &datamodel.SecurityProfile{
PrivateEgress: &datamodel.PrivateEgress{
Expand Down Expand Up @@ -123,9 +120,6 @@ func Test_azurelinuxv2_azurecni(t *testing.T) {
nbc.ContainerService.Properties.AgentPoolProfiles[0].Distro = "aks-azurelinux-v2-gen2"
nbc.AgentPoolProfile.Distro = "aks-azurelinux-v2-gen2"
},
LiveVMValidators: []*LiveVMValidator{
kubeletNodeIPValidator(),
},
},
})
}
Expand Down Expand Up @@ -295,7 +289,6 @@ func Test_marinerv2AirGap(t *testing.T) {
nbc.ContainerService.Properties.AgentPoolProfiles[0].Distro = "aks-cblmariner-v2-gen2"
nbc.AgentPoolProfile.Distro = "aks-cblmariner-v2-gen2"

// TODO(xinhl): define below in the cluster config instead of mutate bootstrapConfig
nbc.OutboundType = datamodel.OutboundTypeBlock
nbc.ContainerService.Properties.SecurityProfile = &datamodel.SecurityProfile{
PrivateEgress: &datamodel.PrivateEgress{
Expand Down Expand Up @@ -346,7 +339,6 @@ func Test_marinerv2ARM64AirGap(t *testing.T) {
nbc.AgentPoolProfile.Distro = "aks-cblmariner-v2-arm64-gen2"
nbc.IsARM64 = true

// TODO(xinhl): define below in the cluster config instead of mutate bootstrapConfig
nbc.OutboundType = datamodel.OutboundTypeBlock
nbc.ContainerService.Properties.SecurityProfile = &datamodel.SecurityProfile{
PrivateEgress: &datamodel.PrivateEgress{
Expand Down Expand Up @@ -375,9 +367,6 @@ func Test_marinerv2_azurecni(t *testing.T) {
nbc.ContainerService.Properties.AgentPoolProfiles[0].Distro = "aks-cblmariner-v2-gen2"
nbc.AgentPoolProfile.Distro = "aks-cblmariner-v2-gen2"
},
LiveVMValidators: []*LiveVMValidator{
kubeletNodeIPValidator(),
},
},
})
}
Expand Down Expand Up @@ -525,8 +514,7 @@ func Test_ubuntu1804(t *testing.T) {
VHD: config.VHDUbuntu1804Gen2Containerd,
LiveVMValidators: []*LiveVMValidator{
containerdVersionValidator("1.7.1+azure-1"),
runcVersionValidator("1.1.12-1"),
kubeletNodeIPValidator(),
runcVersionValidator("1.1.14-1"),
},
},
})
Expand All @@ -542,9 +530,6 @@ func Test_ubuntu1804_azurecni(t *testing.T) {
nbc.ContainerService.Properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin = string(armcontainerservice.NetworkPluginAzure)
nbc.AgentPoolProfile.KubernetesConfig.NetworkPlugin = string(armcontainerservice.NetworkPluginAzure)
},
LiveVMValidators: []*LiveVMValidator{
kubeletNodeIPValidator(),
},
},
})
}
Expand Down Expand Up @@ -637,8 +622,7 @@ func Test_ubuntu2204(t *testing.T) {
},
LiveVMValidators: []*LiveVMValidator{
containerdVersionValidator("1.7.20-1"),
runcVersionValidator("1.1.12-1"),
kubeletNodeIPValidator(),
runcVersionValidator("1.1.14-1"),
},
},
})
Expand All @@ -652,12 +636,36 @@ func Test_ubuntu2204AirGap(t *testing.T) {
},
Config: Config{
Cluster: ClusterKubenetAirgap,
VHD: config.VHDUbuntu2204Gen2Containerd,
VHD: config.VHDUbuntu2204Gen2ContainerdAirgapped,
BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) {
nbc.ContainerService.Properties.AgentPoolProfiles[0].Distro = "aks-ubuntu-containerd-22.04-gen2"
nbc.AgentPoolProfile.Distro = "aks-ubuntu-containerd-22.04-gen2"

nbc.OutboundType = datamodel.OutboundTypeBlock
nbc.ContainerService.Properties.SecurityProfile = &datamodel.SecurityProfile{
PrivateEgress: &datamodel.PrivateEgress{
Enabled: true,
ContainerRegistryServer: "mcr.microsoft.com",
},
}
},
},
})
}

func Test_Ubuntu2204Gen2ContainerdAirgapped_K8sNotCached(t *testing.T) {
RunScenario(t, &Scenario{
Description: "Tests that a node using the Ubuntu 2204 VHD without k8s binary and is airgap can be properly bootstrapped",
Tags: Tags{
Airgap: true,
},
Config: Config{
Cluster: ClusterKubenetAirgap,
VHD: config.VHDUbuntu2204Gen2ContainerdAirgapped,
BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) {
nbc.ContainerService.Properties.AgentPoolProfiles[0].Distro = "aks-ubuntu-containerd-22.04-gen2"
nbc.AgentPoolProfile.Distro = "aks-ubuntu-containerd-22.04-gen2"

// TODO(xinhl): define below in the cluster config instead of mutate bootstrapConfig
nbc.OutboundType = datamodel.OutboundTypeBlock
nbc.ContainerService.Properties.SecurityProfile = &datamodel.SecurityProfile{
PrivateEgress: &datamodel.PrivateEgress{
Expand Down Expand Up @@ -963,3 +971,207 @@ func Test_ubuntu2204Wasm(t *testing.T) {
},
})
}

func Test_Ubuntu2204DisableKubeletServingCertificateRotationWithTags(t *testing.T) {
RunScenario(t, &Scenario{
Tags: Tags{
ServerTLSBootstrapping: true,
},
Description: "tests that a node on ubuntu 2204 bootstrapped with kubelet serving certificate rotation enabled will disable certificate rotation due to nodepool tags",
Config: Config{
Cluster: ClusterKubenet,
VHD: config.VHDUbuntu2204Gen2Containerd,
BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) {
nbc.ContainerService.Properties.AgentPoolProfiles[0].Distro = "aks-ubuntu-containerd-22.04-gen2"
nbc.AgentPoolProfile.Distro = "aks-ubuntu-containerd-22.04-gen2"
if nbc.KubeletConfig == nil {
nbc.KubeletConfig = map[string]string{}
}
nbc.KubeletConfig["--rotate-server-certificates"] = "true"
},
VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) {
if vmss.Tags == nil {
vmss.Tags = map[string]*string{}
}
vmss.Tags["aks-disable-kubelet-serving-certificate-rotation"] = to.Ptr("true")
},
LiveVMValidators: []*LiveVMValidator{
FileExcludesContentsValidator("/etc/default/kubelet", "\\-\\-rotate-server-certificates=true", "\\-\\-rotate-server-certificates=true"),
FileExcludesContentsValidator("/etc/default/kubelet", "kubernetes.azure.com/kubelet-serving-ca=cluster", "kubernetes.azure.com/kubelet-serving-ca=cluster"),
FileHasContentsValidator("/etc/default/kubelet", "\\-\\-rotate-server-certificates=false"),
},
},
})
}

func Test_Ubuntu2204DisableKubeletServingCertificateRotationWithTags_CustomKubeletConfig(t *testing.T) {
RunScenario(t, &Scenario{
Tags: Tags{
ServerTLSBootstrapping: true,
},
Description: "tests that a node on ubuntu 2204 bootstrapped with custom kubelet config and kubelet serving certificate rotation enabled will disable certificate rotation due to nodepool tags",
Config: Config{
Cluster: ClusterKubenet,
VHD: config.VHDUbuntu2204Gen2Containerd,
BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) {
nbc.ContainerService.Properties.AgentPoolProfiles[0].Distro = "aks-ubuntu-containerd-22.04-gen2"
nbc.AgentPoolProfile.Distro = "aks-ubuntu-containerd-22.04-gen2"

// to force kubelet config file
customKubeletConfig := &datamodel.CustomKubeletConfig{
FailSwapOn: to.Ptr(true),
AllowedUnsafeSysctls: &[]string{"kernel.msg*", "net.ipv4.route.min_pmtu"},
}
nbc.AgentPoolProfile.CustomKubeletConfig = customKubeletConfig
nbc.ContainerService.Properties.AgentPoolProfiles[0].CustomKubeletConfig = customKubeletConfig

if nbc.KubeletConfig == nil {
nbc.KubeletConfig = map[string]string{}
}
nbc.KubeletConfig["--rotate-server-certificates"] = "true"
},
VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) {
if vmss.Tags == nil {
vmss.Tags = map[string]*string{}
}
vmss.Tags["aks-disable-kubelet-serving-certificate-rotation"] = to.Ptr("true")
},
LiveVMValidators: []*LiveVMValidator{
FileExcludesContentsValidator("/etc/default/kubelet", "\\-\\-rotate-server-certificates=true", "\\-\\-rotate-server-certificates=true"),
FileExcludesContentsValidator("/etc/default/kubelet", "kubernetes.azure.com/kubelet-serving-ca=cluster", "kubernetes.azure.com/kubelet-serving-ca=cluster"),
FileExcludesContentsValidator("/etc/default/kubeletconfig.json", "\"serverTLSBootstrap\": true", "serverTLSBootstrap: true"),
FileHasContentsValidator("/etc/default/kubeletconfig.json", "\"serverTLSBootstrap\": false"),
},
},
})
}

func Test_Ubuntu2204DisableKubeletServingCertificateRotationWithTags_AlreadyDisabled(t *testing.T) {
RunScenario(t, &Scenario{
Tags: Tags{
ServerTLSBootstrapping: true,
},
Description: "tests that a node on ubuntu 2204 bootstrapped with kubelet serving certificate rotation disabled will disable certificate rotation regardless of nodepool tags",
Config: Config{
Cluster: ClusterKubenet,
VHD: config.VHDUbuntu2204Gen2Containerd,
BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) {
nbc.ContainerService.Properties.AgentPoolProfiles[0].Distro = "aks-ubuntu-containerd-22.04-gen2"
nbc.AgentPoolProfile.Distro = "aks-ubuntu-containerd-22.04-gen2"
},
VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) {
if vmss.Tags == nil {
vmss.Tags = map[string]*string{}
}
vmss.Tags["aks-disable-kubelet-serving-certificate-rotation"] = to.Ptr("true")
},
LiveVMValidators: []*LiveVMValidator{
FileExcludesContentsValidator("/etc/default/kubelet", "\\-\\-rotate-server-certificates=true", "\\-\\-rotate-server-certificates=true"),
FileExcludesContentsValidator("/etc/default/kubelet", "kubernetes.azure.com/kubelet-serving-ca=cluster", "kubernetes.azure.com/kubelet-serving-ca=cluster"),
FileExcludesContentsValidator("/etc/default/kubeletconfig.json", "\"serverTLSBootstrap\": true", "serverTLSBootstrap: true"),
},
},
})
}

func Test_Ubuntu2204DisableKubeletServingCertificateRotationWithTags_AlreadyDisabled_CustomKubeletConfig(t *testing.T) {
RunScenario(t, &Scenario{
Tags: Tags{
ServerTLSBootstrapping: true,
},
Description: "tests that a node on ubuntu 2204 bootstrapped with kubelet serving certificate rotation disabled and custom kubelet config will disable certificate rotation regardless of nodepool tags",
Config: Config{
Cluster: ClusterKubenet,
VHD: config.VHDUbuntu2204Gen2Containerd,
BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) {
nbc.ContainerService.Properties.AgentPoolProfiles[0].Distro = "aks-ubuntu-containerd-22.04-gen2"
nbc.AgentPoolProfile.Distro = "aks-ubuntu-containerd-22.04-gen2"

// to force kubelet config file
customKubeletConfig := &datamodel.CustomKubeletConfig{
FailSwapOn: to.Ptr(true),
AllowedUnsafeSysctls: &[]string{"kernel.msg*", "net.ipv4.route.min_pmtu"},
}
nbc.AgentPoolProfile.CustomKubeletConfig = customKubeletConfig
nbc.ContainerService.Properties.AgentPoolProfiles[0].CustomKubeletConfig = customKubeletConfig
},
VMConfigMutator: func(vmss *armcompute.VirtualMachineScaleSet) {
if vmss.Tags == nil {
vmss.Tags = map[string]*string{}
}
vmss.Tags["aks-disable-kubelet-serving-certificate-rotation"] = to.Ptr("true")
},
LiveVMValidators: []*LiveVMValidator{
FileExcludesContentsValidator("/etc/default/kubelet", "\\-\\-rotate-server-certificates=true", "\\-\\-rotate-server-certificates=true"),
FileExcludesContentsValidator("/etc/default/kubelet", "kubernetes.azure.com/kubelet-serving-ca=cluster", "kubernetes.azure.com/kubelet-serving-ca=cluster"),
FileExcludesContentsValidator("/etc/default/kubeletconfig.json", "\"serverTLSBootstrap\": true", "serverTLSBootstrap: true"),
},
},
})
}

func Test_ubuntu2204WasmAirGap(t *testing.T) {
RunScenario(t, &Scenario{
Description: "tests that a new ubuntu 2204 node using krustlet can be properly bootstrapepd when it is network isolated cluster",
Tags: Tags{
Airgap: true,
},
Config: Config{
Cluster: ClusterKubenetAirgap,
VHD: config.VHDUbuntu2204Gen2ContainerdAirgapped,
BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) {
nbc.ContainerService.Properties.AgentPoolProfiles[0].WorkloadRuntime = datamodel.WasmWasi
nbc.ContainerService.Properties.AgentPoolProfiles[0].Distro = "aks-ubuntu-containerd-22.04-gen2"
nbc.AgentPoolProfile.WorkloadRuntime = datamodel.WasmWasi
nbc.AgentPoolProfile.Distro = "aks-ubuntu-containerd-22.04-gen2"

nbc.OutboundType = datamodel.OutboundTypeBlock
nbc.ContainerService.Properties.SecurityProfile = &datamodel.SecurityProfile{
PrivateEgress: &datamodel.PrivateEgress{
Enabled: true,
// TODO(xinhl): create one private acr instead of mcr.microsoft.com
ContainerRegistryServer: "mcr.microsoft.com",
},
}
},
},
})
}

func Test_ubuntu2204imdsrestriction_filtertable(t *testing.T) {
RunScenario(t, &Scenario{
Description: "tests that the imds restriction filter table is properly set",
Config: Config{
Cluster: ClusterKubenet,
VHD: config.VHDUbuntu2204Gen2Containerd,
BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) {
nbc.ContainerService.Properties.AgentPoolProfiles[0].Distro = "aks-ubuntu-containerd-22.04-gen2"
nbc.AgentPoolProfile.Distro = "aks-ubuntu-containerd-22.04-gen2"
nbc.EnableIMDSRestriction = true
nbc.InsertIMDSRestrictionRuleToMangleTable = false
},
LiveVMValidators: []*LiveVMValidator{
imdsRestrictionRuleValidator("filter"),
},
},
})
}

func Test_ubuntu1804imdsrestriction_mangletable(t *testing.T) {
RunScenario(t, &Scenario{
Description: "tests that the imds restriction mangle table is properly set",
Config: Config{
Cluster: ClusterAzureNetwork,
VHD: config.VHDUbuntu1804Gen2Containerd,
BootstrapConfigMutator: func(nbc *datamodel.NodeBootstrappingConfiguration) {
nbc.ContainerService.Properties.OrchestratorProfile.KubernetesConfig.NetworkPlugin = string(armcontainerservice.NetworkPluginAzure)
nbc.AgentPoolProfile.KubernetesConfig.NetworkPlugin = string(armcontainerservice.NetworkPluginAzure)
nbc.EnableIMDSRestriction = true
nbc.InsertIMDSRestrictionRuleToMangleTable = true
},
LiveVMValidators: []*LiveVMValidator{
imdsRestrictionRuleValidator("mangle"),
},
},
})
}
Loading

0 comments on commit 753cf29

Please sign in to comment.