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: --network-dataplane flag #318

Merged
merged 7 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 6 additions & 5 deletions pkg/operator/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ type Options struct {
ClusterEndpoint string // => APIServerName in bootstrap, except needs to be w/o https/port
VMMemoryOverheadPercent float64
ClusterID string
KubeletClientTLSBootstrapToken string // => TLSBootstrapToken in bootstrap (may need to be per node/nodepool)
SSHPublicKey string // ssh.publicKeys.keyData => VM SSH public key // TODO: move to v1alpha2.AKSNodeClass?
NetworkPlugin string // => NetworkPlugin in bootstrap
NetworkPolicy string // => NetworkPolicy in bootstrap
KubeletClientTLSBootstrapToken string // => TLSBootstrapToken in bootstrap (may need to be per node/nodepool)
SSHPublicKey string // ssh.publicKeys.keyData => VM SSH public key // TODO: move to v1alpha2.AKSNodeClass?
NetworkPlugin string // => NetworkPlugin in bootstrap
NetworkPolicy string // => NetworkPolicy in bootstrap
NetworkDataplane string
NodeIdentities []string // => Applied onto each VM

SubnetID string // => VnetSubnetID to use (for nodes in Azure CNI Overlay and Azure CNI + pod subnet; for for nodes and pods in Azure CNI), unless overridden via AKSNodeClass

setFlags map[string]bool
}

Expand All @@ -81,6 +81,7 @@ func (o *Options) AddFlags(fs *coreoptions.FlagSet) {
fs.StringVar(&o.SSHPublicKey, "ssh-public-key", env.WithDefaultString("SSH_PUBLIC_KEY", ""), "[REQUIRED] VM SSH public key.")
fs.StringVar(&o.NetworkPlugin, "network-plugin", env.WithDefaultString("NETWORK_PLUGIN", "azure"), "The network plugin used by the cluster.")
fs.StringVar(&o.NetworkPolicy, "network-policy", env.WithDefaultString("NETWORK_POLICY", ""), "The network policy used by the cluster.")
fs.StringVar(&o.NetworkDataplane, "network-dataplane", env.WithDefaultString("NETWORK_DATAPLANE", "cilium"), "The network dataplane used by the cluster.")
Bryce-Soghigian marked this conversation as resolved.
Show resolved Hide resolved
fs.StringVar(&o.SubnetID, "vnet-subnet-id", env.WithDefaultString("VNET_SUBNET_ID", ""), "The default subnet ID to use for new nodes. This must be a valid ARM resource ID for subnet that does not overlap with the service CIDR or the pod CIDR")
fs.Var(newNodeIdentitiesValue(env.WithDefaultString("NODE_IDENTITIES", ""), &o.NodeIdentities), "node-identities", "User assigned identities for nodes.")
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/operator/options/options_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func (o Options) Validate() error {
o.validateRequiredFields(),
o.validateEndpoint(),
o.validateVMMemoryOverheadPercent(),
o.validateNetworkDataplane(),
o.validateVnetSubnetID(),
validate.Struct(o),
)
Expand All @@ -44,6 +45,12 @@ func (o Options) validateVnetSubnetID() error {
return nil
}

func (o Options) validateNetworkDataplane() error {
if o.NetworkDataplane != "azure" && o.NetworkDataplane != "cilium" {
Bryce-Soghigian marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Errorf("network dataplane %s is not a valid network dataplane, valid dataplanes are ('azure', 'cilium')", o.NetworkDataplane)
}
return nil
}
func (o Options) validateEndpoint() error {
if o.ClusterEndpoint == "" {
return nil
Expand Down
12 changes: 11 additions & 1 deletion pkg/operator/options/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,18 @@ var _ = Describe("Options", func() {
}))
})
})

Context("Validation", func() {
It("should fail validation when networkDataplane is not invalid", func() {
err := opts.Parse(
fs,
"--cluster-endpoint", "https://karpenter-000000000000.hcp.westus2.staging.azmk8s.io",
"--kubelet-bootstrap-token", "flag-bootstrap-token",
"--ssh-public-key", "flag-ssh-public-key",
"--network-dataplane", "ciluum",
)
Expect(err).To(MatchError(ContainSubstring("network dataplane ciluum is not a valid network dataplane, valid dataplanes are ('azure', 'cilium')")))
})

It("should fail validation when clusterName not included", func() {
err := opts.Parse(
fs,
Expand Down
17 changes: 10 additions & 7 deletions pkg/providers/launchtemplate/launchtemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,16 @@ func (p *Provider) getStaticParameters(ctx context.Context, instanceType *cloudp
labels = lo.Assign(labels, vnetLabels)

// TODO: Make conditional on epbf dataplane
// This label is required for the cilium agent daemonset because
// we select the nodes for the daemonset based on this label
// - key: kubernetes.azure.com/ebpf-dataplane
// operator: In
// values:
// - cilium
labels[vnetDataPlaneLabel] = networkDataplaneCilium
if options.FromContext(ctx).NetworkDataplane == networkDataplaneCilium {
// This label is required for the cilium agent daemonset because
// we select the nodes for the daemonset based on this label
// - key: kubernetes.azure.com/ebpf-dataplane
// operator: In
// values:
// - cilium

labels[vnetDataPlaneLabel] = networkDataplaneCilium
}

return &parameters.StaticParameters{
ClusterName: options.FromContext(ctx).ClusterName,
Expand Down
2 changes: 2 additions & 0 deletions pkg/test/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type OptionsFields struct {
SSHPublicKey *string
NetworkPlugin *string
NetworkPolicy *string
NetworkDataplane *string
VMMemoryOverheadPercent *float64
NodeIdentities []string
SubnetID *string
Expand All @@ -53,6 +54,7 @@ func Options(overrides ...OptionsFields) *azoptions.Options {
SSHPublicKey: lo.FromPtrOr(options.SSHPublicKey, "test-ssh-public-key"),
NetworkPlugin: lo.FromPtrOr(options.NetworkPlugin, "azure"),
NetworkPolicy: lo.FromPtrOr(options.NetworkPolicy, "cilium"),
NetworkDataplane: lo.FromPtrOr(options.NetworkDataplane, "cilium"),
VMMemoryOverheadPercent: lo.FromPtrOr(options.VMMemoryOverheadPercent, 0.075),
NodeIdentities: options.NodeIdentities,
SubnetID: lo.FromPtrOr(options.SubnetID, "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sillygeese/providers/Microsoft.Network/virtualNetworks/karpentervnet/subnets/karpentersub"),
Expand Down