Skip to content

Commit

Permalink
feat: supporting cilium + nodesubnet case
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryce-Soghigian committed Feb 18, 2025
1 parent e8d6943 commit 5dea29b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
5 changes: 1 addition & 4 deletions pkg/providers/imagefamily/bootstrap/aksbootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"strings"
"text/template"

"github.com/Azure/karpenter-provider-azure/pkg/consts"
"github.com/Azure/karpenter-provider-azure/pkg/utils"
"github.com/blang/semver/v4"
"github.com/samber/lo"
Expand All @@ -47,7 +46,6 @@ type AKS struct {
APIServerName string
KubeletClientTLSBootstrapToken string
NetworkPlugin string
NetworkPluginMode string
NetworkPolicy string
KubernetesVersion string
}
Expand Down Expand Up @@ -455,8 +453,7 @@ func (a AKS) applyOptions(nbv *NodeBootstrapVariables) {
nbv.ResourceGroup = a.ResourceGroup
nbv.UserAssignedIdentityID = a.KubeletIdentityClientID

// In some cases we don't need the node to do anything with CNI so tell it NetworkPlugin is 'none'
nbv.NetworkPlugin = lo.Ternary(a.NetworkPluginMode == consts.NetworkPluginModeOverlay, consts.NetworkPluginNone, a.NetworkPlugin)
nbv.NetworkPlugin = a.NetworkPlugin

nbv.NetworkPolicy = a.NetworkPolicy
nbv.KubernetesVersion = a.KubernetesVersion
Expand Down
1 change: 0 additions & 1 deletion pkg/providers/imagefamily/ubuntu_2204.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ func (u Ubuntu2204) ScriptlessCustomData(kubeletConfig *bootstrap.KubeletConfigu
APIServerName: u.Options.APIServerName,
KubeletClientTLSBootstrapToken: u.Options.KubeletClientTLSBootstrapToken,
NetworkPlugin: u.Options.NetworkPlugin,
NetworkPluginMode: u.Options.NetworkPluginMode,
NetworkPolicy: u.Options.NetworkPolicy,
KubernetesVersion: u.Options.KubernetesVersion,
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/providers/instancetype/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,10 @@ var _ = Describe("InstanceType Provider", func() {
"kubernetes.azure.com/podnetwork-type=overlay",
"kubernetes.azure.com/ebpf-dataplane=cilium",
)),
Entry("Cilium w feature flag Microsoft.ContainerService/EnableCiliumNodeSubnet",
"azure", "", "cilium",
"none",
sets.New("kubernetes.azure.com/ebpf-dataplane=cilium")),
)

Context("LoadBalancer", func() {
Expand Down
15 changes: 13 additions & 2 deletions pkg/providers/launchtemplate/launchtemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,28 @@ func (p *Provider) getStaticParameters(ctx context.Context, instanceType *cloudp
ClusterID: options.FromContext(ctx).ClusterID,
APIServerName: options.FromContext(ctx).GetAPIServerName(),
KubeletClientTLSBootstrapToken: options.FromContext(ctx).KubeletClientTLSBootstrapToken,
NetworkPlugin: options.FromContext(ctx).NetworkPlugin,
NetworkPlugin: getAgentbakerNetworkPlugin(ctx),
NetworkPolicy: options.FromContext(ctx).NetworkPolicy,
NetworkPluginMode: options.FromContext(ctx).NetworkPluginMode,
SubnetID: subnetID,
ClusterResourceGroup: p.clusterResourceGroup,
}, nil
}

func getAgentbakerNetworkPlugin(ctx context.Context) string {
if isAzureCNIOverlay(ctx) || isCiliumNodeSubnet(ctx) {
return consts.NetworkPluginNone
}
return consts.NetworkPluginAzure
}

func isCiliumNodeSubnet(ctx context.Context) bool {
return options.FromContext(ctx).NetworkPlugin == consts.NetworkPluginAzure && options.FromContext(ctx).NetworkPluginMode == consts.NetworkPluginModeNone && options.FromContext(ctx).NetworkDataplane == consts.NetworkDataplaneCilium
}

func isAzureCNIOverlay(ctx context.Context) bool {
return options.FromContext(ctx).NetworkPlugin == consts.NetworkPluginAzure && options.FromContext(ctx).NetworkPluginMode == consts.NetworkPluginModeOverlay
}

func (p *Provider) createLaunchTemplate(ctx context.Context, params *parameters.Parameters) (*Template, error) {
// merge and convert to ARM tags
azureTags := mergeTags(params.Tags, map[string]string{karpenterManagedTagKey: params.ClusterName})
Expand Down
1 change: 0 additions & 1 deletion pkg/providers/launchtemplate/parameters/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ type StaticParameters struct {
APIServerName string
KubeletClientTLSBootstrapToken string
NetworkPlugin string
NetworkPluginMode string
NetworkPolicy string
KubernetesVersion string
SubnetID string
Expand Down

0 comments on commit 5dea29b

Please sign in to comment.