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: Add support for setting a different CNI config on cilium clusters #5482

Open
wants to merge 15 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions parts/windows/kuberneteswindowssetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ $global:NetworkPlugin = "{{GetParameter "networkPlugin"}}"
$global:VNetCNIPluginsURL = "{{GetParameter "vnetCniWindowsPluginsURL"}}"
$global:IsDualStackEnabled = {{if IsIPv6DualStackFeatureEnabled}}$true{{else}}$false{{end}}
$global:IsAzureCNIOverlayEnabled = {{if IsAzureCNIOverlayFeatureEnabled}}$true{{else}}$false{{end}}
$global:EbpfDataplane = {{if EbpfDataplane}}$true{{else}}$false{{end}}

# Kubelet credential provider
$global:CredentialProviderURL = "{{GetParameter "windowsCredentialProviderURL"}}"
Expand Down Expand Up @@ -398,6 +399,7 @@ try
-VNetCIDR $global:VNetCIDR `
-IsDualStackEnabled $global:IsDualStackEnabled `
-IsAzureCNIOverlayEnabled $global:IsAzureCNIOverlayEnabled


if ($TargetEnvironment -ieq "AzureStackCloud") {
GenerateAzureStackCNIConfig `
Expand Down
3 changes: 3 additions & 0 deletions pkg/agent/baker.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,9 @@ func getContainerServiceFuncMap(config *datamodel.NodeBootstrappingConfiguration
"IsAzureCNIOverlayFeatureEnabled": func() bool {
return cs.Properties.OrchestratorProfile.KubernetesConfig.IsUsingNetworkPluginMode("overlay")
},
"EbpfDataplane": func() bool {
cameronmeissner marked this conversation as resolved.
Show resolved Hide resolved
return cs.Properties.OrchestratorProfile.KubernetesConfig.EbpfDataplane == datamodel.EbpfDataplane_cilium
},
"GetBase64EncodedEnvironmentJSON": func() string {
customEnvironmentJSON, _ := cs.Properties.GetCustomEnvironmentJSON(false)
return base64.StdEncoding.EncodeToString([]byte(customEnvironmentJSON))
Expand Down
17 changes: 17 additions & 0 deletions pkg/agent/datamodel/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,22 @@ type KubernetesAddon struct {
Data string `json:"data,omitempty"`
}

// EbpfDataplane controls the eBPF networking dataplane.
type EbpfDataplane int32

const (
// none means don't install an eBPF dataplane.
EbpfDataplane_none EbpfDataplane = 0
santhoshmprabhu marked this conversation as resolved.
Show resolved Hide resolved
// cilium means use Cilium as the eBPF dataplane.
EbpfDataplane_cilium EbpfDataplane = 1
// unspecified means the cx didn't provide a value.
// This is used only during validation / defaulting, never written to the database.
EbpfDataplane_unspecified EbpfDataplane = 3
// invalid means the cx provided a value that isn't an enum in the API version.
// This will always be rejected by validation (and therefore never written to the database).
EbpfDataplane_invalid EbpfDataplane = 4
)

// KubernetesConfig contains the Kubernetes config structure, containing Kubernetes specific configuration.
type KubernetesConfig struct {
KubernetesImageBase string `json:"kubernetesImageBase,omitempty"`
Expand Down Expand Up @@ -678,6 +694,7 @@ type KubernetesConfig struct {
MaximumLoadBalancerRuleCount int `json:"maximumLoadBalancerRuleCount,omitempty"`
PrivateAzureRegistryServer string `json:"privateAzureRegistryServer,omitempty"`
NetworkPluginMode string `json:"networkPluginMode,omitempty"`
EbpfDataplane EbpfDataplane `json:"ebpfDataplane,omitempty"`
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ $global:NetworkPlugin = "azure"
$global:VNetCNIPluginsURL = "https://acs-mirror.azureedge.net/azure-cni/v1.1.3/binaries/azure-vnet-cni-singletenancy-windows-amd64-v1.1.3.zip"
$global:IsDualStackEnabled = $false
$global:IsAzureCNIOverlayEnabled = $false
$global:EbpfDataplane = $false

# Kubelet credential provider
$global:CredentialProviderURL = "https://acs-mirror.azureedge.net/cloud-provider-azure/v1.29.0/binaries/azure-acr-credential-provider-windows-amd64-v1.29.0.tar.gz"
Expand Down Expand Up @@ -394,6 +395,7 @@ try
-VNetCIDR $global:VNetCIDR `
-IsDualStackEnabled $global:IsDualStackEnabled `
-IsAzureCNIOverlayEnabled $global:IsAzureCNIOverlayEnabled


if ($TargetEnvironment -ieq "AzureStackCloud") {
GenerateAzureStackCNIConfig `
Expand Down
2 changes: 2 additions & 0 deletions pkg/agent/testdata/AKSWindows2019+CustomCloud/CustomData
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ $global:NetworkPlugin = "azure"
$global:VNetCNIPluginsURL = "https://acs-mirror.azureedge.net/azure-cni/v1.1.3/binaries/azure-vnet-cni-singletenancy-windows-amd64-v1.1.3.zip"
$global:IsDualStackEnabled = $false
$global:IsAzureCNIOverlayEnabled = $false
$global:EbpfDataplane = $false

# Kubelet credential provider
$global:CredentialProviderURL = ""
Expand Down Expand Up @@ -394,6 +395,7 @@ try
-VNetCIDR $global:VNetCIDR `
-IsDualStackEnabled $global:IsDualStackEnabled `
-IsAzureCNIOverlayEnabled $global:IsAzureCNIOverlayEnabled


if ($TargetEnvironment -ieq "AzureStackCloud") {
GenerateAzureStackCNIConfig `
Expand Down
2 changes: 2 additions & 0 deletions pkg/agent/testdata/AKSWindows2019+CustomVnet/CustomData
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ $global:NetworkPlugin = "azure"
$global:VNetCNIPluginsURL = "https://acs-mirror.azureedge.net/azure-cni/v1.1.3/binaries/azure-vnet-cni-singletenancy-windows-amd64-v1.1.3.zip"
$global:IsDualStackEnabled = $false
$global:IsAzureCNIOverlayEnabled = $false
$global:EbpfDataplane = $false

# Kubelet credential provider
$global:CredentialProviderURL = ""
Expand Down Expand Up @@ -388,6 +389,7 @@ try
-VNetCIDR $global:VNetCIDR `
-IsDualStackEnabled $global:IsDualStackEnabled `
-IsAzureCNIOverlayEnabled $global:IsAzureCNIOverlayEnabled


if ($TargetEnvironment -ieq "AzureStackCloud") {
GenerateAzureStackCNIConfig `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ $global:NetworkPlugin = "azure"
$global:VNetCNIPluginsURL = "https://acs-mirror.azureedge.net/azure-cni/v1.1.3/binaries/azure-vnet-cni-singletenancy-windows-amd64-v1.1.3.zip"
$global:IsDualStackEnabled = $false
$global:IsAzureCNIOverlayEnabled = $false
$global:EbpfDataplane = $false

# Kubelet credential provider
$global:CredentialProviderURL = ""
Expand Down Expand Up @@ -388,6 +389,7 @@ try
-VNetCIDR $global:VNetCIDR `
-IsDualStackEnabled $global:IsDualStackEnabled `
-IsAzureCNIOverlayEnabled $global:IsAzureCNIOverlayEnabled


if ($TargetEnvironment -ieq "AzureStackCloud") {
GenerateAzureStackCNIConfig `
Expand Down
2 changes: 2 additions & 0 deletions pkg/agent/testdata/AKSWindows2019+K8S116/CustomData
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ $global:NetworkPlugin = "azure"
$global:VNetCNIPluginsURL = "https://acs-mirror.azureedge.net/azure-cni/v1.1.3/binaries/azure-vnet-cni-singletenancy-windows-amd64-v1.1.3.zip"
$global:IsDualStackEnabled = $false
$global:IsAzureCNIOverlayEnabled = $false
$global:EbpfDataplane = $false

# Kubelet credential provider
$global:CredentialProviderURL = ""
Expand Down Expand Up @@ -388,6 +389,7 @@ try
-VNetCIDR $global:VNetCIDR `
-IsDualStackEnabled $global:IsDualStackEnabled `
-IsAzureCNIOverlayEnabled $global:IsAzureCNIOverlayEnabled


if ($TargetEnvironment -ieq "AzureStackCloud") {
GenerateAzureStackCNIConfig `
Expand Down
2 changes: 2 additions & 0 deletions pkg/agent/testdata/AKSWindows2019+K8S117/CustomData
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ $global:NetworkPlugin = "azure"
$global:VNetCNIPluginsURL = "https://acs-mirror.azureedge.net/azure-cni/v1.1.3/binaries/azure-vnet-cni-singletenancy-windows-amd64-v1.1.3.zip"
$global:IsDualStackEnabled = $false
$global:IsAzureCNIOverlayEnabled = $false
$global:EbpfDataplane = $false

# Kubelet credential provider
$global:CredentialProviderURL = ""
Expand Down Expand Up @@ -388,6 +389,7 @@ try
-VNetCIDR $global:VNetCIDR `
-IsDualStackEnabled $global:IsDualStackEnabled `
-IsAzureCNIOverlayEnabled $global:IsAzureCNIOverlayEnabled


if ($TargetEnvironment -ieq "AzureStackCloud") {
GenerateAzureStackCNIConfig `
Expand Down
2 changes: 2 additions & 0 deletions pkg/agent/testdata/AKSWindows2019+K8S118/CustomData
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ $global:NetworkPlugin = "azure"
$global:VNetCNIPluginsURL = "https://acs-mirror.azureedge.net/azure-cni/v1.1.3/binaries/azure-vnet-cni-singletenancy-windows-amd64-v1.1.3.zip"
$global:IsDualStackEnabled = $false
$global:IsAzureCNIOverlayEnabled = $false
$global:EbpfDataplane = $false

# Kubelet credential provider
$global:CredentialProviderURL = ""
Expand Down Expand Up @@ -388,6 +389,7 @@ try
-VNetCIDR $global:VNetCIDR `
-IsDualStackEnabled $global:IsDualStackEnabled `
-IsAzureCNIOverlayEnabled $global:IsAzureCNIOverlayEnabled


if ($TargetEnvironment -ieq "AzureStackCloud") {
GenerateAzureStackCNIConfig `
Expand Down
2 changes: 2 additions & 0 deletions pkg/agent/testdata/AKSWindows2019+K8S119+CSI/CustomData
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ $global:NetworkPlugin = "azure"
$global:VNetCNIPluginsURL = "https://acs-mirror.azureedge.net/azure-cni/v1.1.3/binaries/azure-vnet-cni-singletenancy-windows-amd64-v1.1.3.zip"
$global:IsDualStackEnabled = $false
$global:IsAzureCNIOverlayEnabled = $false
$global:EbpfDataplane = $false

# Kubelet credential provider
$global:CredentialProviderURL = ""
Expand Down Expand Up @@ -388,6 +389,7 @@ try
-VNetCIDR $global:VNetCIDR `
-IsDualStackEnabled $global:IsDualStackEnabled `
-IsAzureCNIOverlayEnabled $global:IsAzureCNIOverlayEnabled


if ($TargetEnvironment -ieq "AzureStackCloud") {
GenerateAzureStackCNIConfig `
Expand Down
2 changes: 2 additions & 0 deletions pkg/agent/testdata/AKSWindows2019+K8S119+FIPS/CustomData
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ $global:NetworkPlugin = "azure"
$global:VNetCNIPluginsURL = "https://acs-mirror.azureedge.net/azure-cni/v1.1.3/binaries/azure-vnet-cni-singletenancy-windows-amd64-v1.1.3.zip"
$global:IsDualStackEnabled = $false
$global:IsAzureCNIOverlayEnabled = $false
$global:EbpfDataplane = $false

# Kubelet credential provider
$global:CredentialProviderURL = ""
Expand Down Expand Up @@ -388,6 +389,7 @@ try
-VNetCIDR $global:VNetCIDR `
-IsDualStackEnabled $global:IsDualStackEnabled `
-IsAzureCNIOverlayEnabled $global:IsAzureCNIOverlayEnabled


if ($TargetEnvironment -ieq "AzureStackCloud") {
GenerateAzureStackCNIConfig `
Expand Down
2 changes: 2 additions & 0 deletions pkg/agent/testdata/AKSWindows2019+K8S119/CustomData
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ $global:NetworkPlugin = "azure"
$global:VNetCNIPluginsURL = "https://acs-mirror.azureedge.net/azure-cni/v1.1.3/binaries/azure-vnet-cni-singletenancy-windows-amd64-v1.1.3.zip"
$global:IsDualStackEnabled = $false
$global:IsAzureCNIOverlayEnabled = $false
$global:EbpfDataplane = $false

# Kubelet credential provider
$global:CredentialProviderURL = ""
Expand Down Expand Up @@ -388,6 +389,7 @@ try
-VNetCIDR $global:VNetCIDR `
-IsDualStackEnabled $global:IsDualStackEnabled `
-IsAzureCNIOverlayEnabled $global:IsAzureCNIOverlayEnabled


if ($TargetEnvironment -ieq "AzureStackCloud") {
GenerateAzureStackCNIConfig `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ $global:NetworkPlugin = "azure"
$global:VNetCNIPluginsURL = "https://acs-mirror.azureedge.net/azure-cni/v1.1.3/binaries/azure-vnet-cni-singletenancy-windows-amd64-v1.1.3.zip"
$global:IsDualStackEnabled = $false
$global:IsAzureCNIOverlayEnabled = $false
$global:EbpfDataplane = $false

# Kubelet credential provider
$global:CredentialProviderURL = ""
Expand Down Expand Up @@ -388,6 +389,7 @@ try
-VNetCIDR $global:VNetCIDR `
-IsDualStackEnabled $global:IsDualStackEnabled `
-IsAzureCNIOverlayEnabled $global:IsAzureCNIOverlayEnabled


if ($TargetEnvironment -ieq "AzureStackCloud") {
GenerateAzureStackCNIConfig `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ $global:NetworkPlugin = "azure"
$global:VNetCNIPluginsURL = "https://acs-mirror.azureedge.net/azure-cni/v1.1.3/binaries/azure-vnet-cni-singletenancy-windows-amd64-v1.1.3.zip"
$global:IsDualStackEnabled = $false
$global:IsAzureCNIOverlayEnabled = $false
$global:EbpfDataplane = $false

# Kubelet credential provider
$global:CredentialProviderURL = "https://acs-mirror.azureedge.net/cloud-provider-azure/v1.29.7/binaries/azure-acr-credential-provider-windows-amd64-v1.29.7.tar.gz"
Expand Down Expand Up @@ -388,6 +389,7 @@ try
-VNetCIDR $global:VNetCIDR `
-IsDualStackEnabled $global:IsDualStackEnabled `
-IsAzureCNIOverlayEnabled $global:IsAzureCNIOverlayEnabled


if ($TargetEnvironment -ieq "AzureStackCloud") {
GenerateAzureStackCNIConfig `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ $global:NetworkPlugin = "azure"
$global:VNetCNIPluginsURL = "https://acs-mirror.azureedge.net/azure-cni/v1.1.3/binaries/azure-vnet-cni-singletenancy-windows-amd64-v1.1.3.zip"
$global:IsDualStackEnabled = $false
$global:IsAzureCNIOverlayEnabled = $false
$global:EbpfDataplane = $false

# Kubelet credential provider
$global:CredentialProviderURL = ""
Expand Down Expand Up @@ -388,6 +389,7 @@ try
-VNetCIDR $global:VNetCIDR `
-IsDualStackEnabled $global:IsDualStackEnabled `
-IsAzureCNIOverlayEnabled $global:IsAzureCNIOverlayEnabled


if ($TargetEnvironment -ieq "AzureStackCloud") {
GenerateAzureStackCNIConfig `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ $global:NetworkPlugin = "azure"
$global:VNetCNIPluginsURL = "https://acs-mirror.azureedge.net/azure-cni/v1.1.3/binaries/azure-vnet-cni-singletenancy-windows-amd64-v1.1.3.zip"
$global:IsDualStackEnabled = $false
$global:IsAzureCNIOverlayEnabled = $false
$global:EbpfDataplane = $false

# Kubelet credential provider
$global:CredentialProviderURL = ""
Expand Down Expand Up @@ -388,6 +389,7 @@ try
-VNetCIDR $global:VNetCIDR `
-IsDualStackEnabled $global:IsDualStackEnabled `
-IsAzureCNIOverlayEnabled $global:IsAzureCNIOverlayEnabled


if ($TargetEnvironment -ieq "AzureStackCloud") {
GenerateAzureStackCNIConfig `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ $global:NetworkPlugin = "azure"
$global:VNetCNIPluginsURL = "https://acs-mirror.azureedge.net/azure-cni/v1.1.3/binaries/azure-vnet-cni-singletenancy-windows-amd64-v1.1.3.zip"
$global:IsDualStackEnabled = $false
$global:IsAzureCNIOverlayEnabled = $false
$global:EbpfDataplane = $false

# Kubelet credential provider
$global:CredentialProviderURL = "https://acs-mirror.azureedge.net/cloud-provider-azure/v1.29.0/binaries/azure-acr-credential-provider-windows-amd64-v1.29.0.tar.gz"
Expand Down Expand Up @@ -388,6 +389,7 @@ try
-VNetCIDR $global:VNetCIDR `
-IsDualStackEnabled $global:IsDualStackEnabled `
-IsAzureCNIOverlayEnabled $global:IsAzureCNIOverlayEnabled


if ($TargetEnvironment -ieq "AzureStackCloud") {
GenerateAzureStackCNIConfig `
Expand Down
8 changes: 7 additions & 1 deletion staging/cse/windows/azurecnifunc.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,18 @@ function Set-AzureCNIConfig
[Parameter(Mandatory=$false)][bool]
$IsAzureCNIOverlayEnabled
)
Logs-To-Event -TaskName "AKS.WindowsCSE.SetAzureCNIConfig" -TaskMessage "Start to set Azure CNI config. IsDualStackEnabled: $global:IsDualStackEnabled, IsAzureCNIOverlayEnabled: $global:IsAzureCNIOverlayEnabled, IsDisableWindowsOutboundNat: $global:IsDisableWindowsOutboundNat"
Logs-To-Event -TaskName "AKS.WindowsCSE.SetAzureCNIConfig" -TaskMessage "Start to set Azure CNI config. IsDualStackEnabled: $global:IsDualStackEnabled, IsAzureCNIOverlayEnabled: $global:IsAzureCNIOverlayEnabled, IsDisableWindowsOutboundNat: $global:IsDisableWindowsOutboundNat, EbpfDataplane: $global:EbpfDataplane"

$fileName = [Io.path]::Combine("$AzureCNIConfDir", "10-azure.conflist")
$configJson = Get-Content $fileName | ConvertFrom-Json
$configJson.plugins.dns.Nameservers[0] = $KubeDnsServiceIp
$configJson.plugins.dns.Search[0] = $KubeDnsSearchPath

if (Test-Path variable:global:EbpfDataplane) {
if($global:EbpfDataplane) {
$configJson.plugins.ipam.type = "azure-cns"
}
}

if ($global:IsDisableWindowsOutboundNat) {
# Replace OutBoundNAT with LoopbackDSR for IMDS acess if AKS cluster disabled Windows OutBoundNAT.
Expand Down
24 changes: 22 additions & 2 deletions staging/cse/windows/azurecnifunc.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Describe 'Set-AzureCNIConfig' {
$isDualStackEnabled = $false
$KubeDnsServiceIp = "10.0.0.10"
$global:IsDisableWindowsOutboundNat = $false
$global:EbpfDataplane = $false
$global:KubeproxyFeatureGates = @("WinDSR=true")
$azureCNIConfigFile = [Io.path]::Combine($azureCNIConfDir, "10-azure.conflist")

Expand All @@ -55,8 +56,27 @@ Describe 'Set-AzureCNIConfig' {
}
}

Context 'WinDSR is enabled by default' {
It "Should remove ROUTE" {
Context 'Cilium (ebpf dataplane) is enabled' {
santhoshmprabhu marked this conversation as resolved.
Show resolved Hide resolved
It "Should use azure-cns as IPAM" {
Set-Default-AzureCNI "AzureCNI.Default.conflist"

$global:EbpfDataplane = $true
Set-AzureCNIConfig -AzureCNIConfDir $azureCNIConfDir `
-KubeDnsSearchPath $kubeDnsSearchPath `
-KubeClusterCIDR $kubeClusterCIDR `
-KubeServiceCIDR $kubeServiceCIDR `
-VNetCIDR $vNetCIDR `
-IsDualStackEnabled $isDualStackEnabled

$actualConfigJson = Read-Format-Json $azureCNIConfigFile
$expectedConfigJson = Read-Format-Json ([Io.path]::Combine($azureCNIConfDir, "AzureCNI.Expect.CiliumNodeSubnet.conflist"))
$difference = Compare-Object $actualConfigJson $expectedConfigJson
$difference | Should -Be $null
}
}

Context 'WinDSR is enabled, ebpf dataplane disabled by default' {
It "Should remove ROUTE and use azure-vnet-ipam for IPAM" {
Set-Default-AzureCNI "AzureCNI.Default.conflist"

Set-AzureCNIConfig -AzureCNIConfDir $azureCNIConfDir `
Expand Down
Loading
Loading