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: Support for static AzureCNI without overlay networking via generating additional ip configurations #365

Open
wants to merge 62 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
9ef7fd4
feat: adding --network-plugin-mode flag to options
Bryce-Soghigian Apr 28, 2024
c666565
test: adding --network-plugin-mode to test env
Bryce-Soghigian Apr 28, 2024
a1f47c3
feat: conditionally setting labels based on network-policy and networ…
Bryce-Soghigian Apr 28, 2024
fbfcf55
test: validating that network plugin labels are not placed on nodes f…
Bryce-Soghigian Apr 28, 2024
5ec81ef
style: make presubmit golangci-lint
Bryce-Soghigian Apr 28, 2024
fec18f4
feat: adding network-plugin-mode to helm values
Bryce-Soghigian Apr 29, 2024
60d85ee
fix: modiying comment to specify network policy rather than network p…
Bryce-Soghigian Apr 30, 2024
8f49918
style: better comment for NetworkPluginMode
Bryce-Soghigian Apr 30, 2024
5421f1f
Merge branch 'main' into bsoghigian/overlay-plumbing
Bryce-Soghigian Apr 30, 2024
d13abc7
chore: removing ciliummm conditional logic
Bryce-Soghigian May 1, 2024
eed47a6
Merge branch 'main' into bsoghigian/overlay-plumbing
Bryce-Soghigian May 10, 2024
b5e0423
refactor: MaxPods into utils and adding a new consts package for shar…
Bryce-Soghigian May 10, 2024
d7f215c
feat: set secondary ipconfigs on the nic when podnetwork type is not …
Bryce-Soghigian May 10, 2024
ce0784e
test: adding new cluster create commands
Bryce-Soghigian May 12, 2024
e140d38
fix: do not allocate additional ips for host network addons
Bryce-Soghigian May 13, 2024
a277cd6
fix: properly counting max ips
Bryce-Soghigian May 14, 2024
06d94c6
test: running e2es on azure cni v1
Bryce-Soghigian May 14, 2024
bb26d2e
fix: az-configure-values should be aware of the network configuration…
Bryce-Soghigian May 18, 2024
db41576
fix: cleaning up tests and DefaultMaxPods calc
Bryce-Soghigian May 19, 2024
6356024
refactor: removing maxPods from launch template as we have no intenti…
Bryce-Soghigian May 19, 2024
6fd6759
test: validating nic configurations still valid for azurecni with ove…
Bryce-Soghigian May 19, 2024
8368a5e
style: grammar fixes after a read through
Bryce-Soghigian May 21, 2024
0152faf
test: adding ginkgo helper for checking kubelet flags
Bryce-Soghigian May 21, 2024
664da18
test: modifying instancetypes tests to use the ExpectKubeletFlags helper
Bryce-Soghigian May 21, 2024
84deccb
fix: resetting cluster state in instance provider suite test since we…
Bryce-Soghigian May 21, 2024
1631143
ci: running golangci-lint
Bryce-Soghigian May 21, 2024
124d6ab
Merge branch 'main' into bsoghigian/azurecni-v1-clean
Bryce-Soghigian May 21, 2024
3f7e27e
Merge branch 'bsoghigian/azurecni-v1-clean' of github.com:Bryce-Soghi…
Bryce-Soghigian May 21, 2024
9d21235
Update Makefile-az.mk
Bryce-Soghigian May 21, 2024
fd5d988
refactor: moving final case over to use new Assert helper
Bryce-Soghigian May 21, 2024
560c04a
ci: make ci-non-test
Bryce-Soghigian May 22, 2024
cba91f6
fix: removing the ip config deficit added for static addons
Bryce-Soghigian May 22, 2024
956896d
Update pkg/operator/options/options_validation.go
Bryce-Soghigian May 22, 2024
2b54188
Update Makefile-az.mk
Bryce-Soghigian May 22, 2024
b831dbd
Update Makefile-az.mk
Bryce-Soghigian May 22, 2024
e377fdb
refactor: moving consts
Bryce-Soghigian May 22, 2024
4a0b3cd
please
Bryce-Soghigian May 23, 2024
dc08667
refactor: renaming from Assert to Expect
Bryce-Soghigian May 24, 2024
7d56e80
note: concise comment
Bryce-Soghigian May 25, 2024
e7c8741
fix: comment
Bryce-Soghigian May 25, 2024
34c5290
Update pkg/providers/instance/instance.go
Bryce-Soghigian May 25, 2024
88e9622
refactor(style): changing name from PodNetworkType to NetworkPluginMo…
Bryce-Soghigian May 29, 2024
e93255a
refactor(style): aligning the make targets so we can easily see the d…
Bryce-Soghigian May 29, 2024
7b7f739
fix: updating tests
Bryce-Soghigian Jun 3, 2024
8c2bdee
Update pkg/providers/instance/instance.go
Bryce-Soghigian Jun 3, 2024
f9dc047
refactor: createNICOptions structure passing down some of the parameters
Bryce-Soghigian Jun 4, 2024
887064b
refactor: removing network plugin and all kubenet assumptions
Bryce-Soghigian Jun 11, 2024
36cc5a2
refactor: removing kubenet referencess
Bryce-Soghigian Jun 12, 2024
91964a7
Merge branch 'main' into bsoghigian/azurecni-v1-clean
Bryce-Soghigian Sep 12, 2024
7b35dca
fix: conflict
Bryce-Soghigian Sep 12, 2024
a31e10a
ci: lint
Bryce-Soghigian Sep 12, 2024
5d88685
fix: container runtime network not ready: NetworkReady=false reason:N…
Bryce-Soghigian Sep 19, 2024
965830f
refactor: removing network plugin from values
Bryce-Soghigian Sep 19, 2024
356491f
revert: progress
Bryce-Soghigian Sep 19, 2024
fd5b15e
Revert "fix: container runtime network not ready: NetworkReady=false …
Bryce-Soghigian Sep 19, 2024
a7fd642
....
Bryce-Soghigian Sep 19, 2024
19ae6e2
Revert "refactor: removing network plugin from values"
Bryce-Soghigian Sep 19, 2024
4752103
fix: test
Bryce-Soghigian Sep 19, 2024
bf1830c
Merge branch 'main' into bsoghigian/azurecni-v1-clean
Bryce-Soghigian Sep 19, 2024
2b83536
fix: ci...............
Bryce-Soghigian Sep 19, 2024
f5f5f9f
Merge branch 'bsoghigian/azurecni-v1-clean' of https://github.com/Bry…
Bryce-Soghigian Sep 19, 2024
31056e7
Merge branch 'main' into bsoghigian/azurecni-v1-clean
Bryce-Soghigian Sep 19, 2024
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: 1 addition & 1 deletion .github/actions/e2e/create-cluster/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ runs:
run: AZURE_RESOURCE_GROUP=${{ inputs.resource_group }} AZURE_LOCATION=${{ inputs.location }} make az-create-workload-msi
- name: create cluster
shell: bash
run: AZURE_CLUSTER_NAME=${{ inputs.cluster_name }} AZURE_RESOURCE_GROUP=${{ inputs.resource_group }} AZURE_ACR_NAME=${{ inputs.acr_name }} AZURE_LOCATION=${{ inputs.location }} make az-mkaks-cilium
run: AZURE_CLUSTER_NAME=${{ inputs.cluster_name }} AZURE_RESOURCE_GROUP=${{ inputs.resource_group }} AZURE_ACR_NAME=${{ inputs.acr_name }} AZURE_LOCATION=${{ inputs.location }} make az-mkaks-cniv1
Bryce-Soghigian marked this conversation as resolved.
Show resolved Hide resolved
Bryce-Soghigian marked this conversation as resolved.
Show resolved Hide resolved
- name: az login 2
uses: azure/login@6c251865b4e6290e7b78be643ea2d005bc51f69a # v2.1.1
with:
Expand Down
29 changes: 25 additions & 4 deletions Makefile-az.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ KARPENTER_FEDERATED_IDENTITY_CREDENTIAL_NAME ?= KARPENTER_FID
CUSTOM_VNET_NAME ?= $(AZURE_CLUSTER_NAME)-vnet
CUSTOM_SUBNET_NAME ?= nodesubnet

az-all: az-login az-create-workload-msi az-mkaks-cilium az-create-federated-cred az-perm az-perm-acr az-configure-values az-build az-run az-run-sample ## Provision the infra (ACR,AKS); build and deploy Karpenter; deploy sample Provisioner and workload
az-all-custom-vnet: az-login az-create-workload-msi az-mkaks-custom-vnet az-create-federated-cred az-perm-subnet-custom az-perm-acr az-configure-values-custom-vnet az-build az-run az-run-sample ## Provision the infra (ACR,AKS); build and deploy Karpenter; deploy sample Provisioner and workload
az-all-user: az-login az-mkaks-user az-configure-values az-helm-install-snapshot az-run-sample ## Provision the cluster and deploy Karpenter snapshot release
az-all: az-login az-create-workload-msi az-mkaks-cilium az-create-federated-cred az-perm az-perm-acr az-configure-values az-build az-run az-run-sample ## Provision the infra (ACR,AKS); build and deploy Karpenter; deploy sample Provisioner and workload

az-all-cniv1: az-login az-create-workload-msi az-mkaks-cniv1 az-create-federated-cred az-perm az-perm-acr az-configure-values az-build az-run az-run-sample ## Provision the infra (ACR,AKS); build and deploy Karpenter; deploy sample Provisioner and workload

az-all-cni-overlay: az-login az-create-workload-msi az-mkaks-overlay az-create-federated-cred az-perm az-perm-acr az-configure-values az-build az-run az-run-sample ## Provision the infra (ACR,AKS); build and deploy Karpenter; deploy sample Provisioner and workload
Bryce-Soghigian marked this conversation as resolved.
Show resolved Hide resolved

az-all-custom-vnet: az-login az-create-workload-msi az-mkaks-custom-vnet az-create-federated-cred az-perm-subnet-custom az-perm-acr az-configure-values-custom-vnet az-build az-run az-run-sample ## Provision the infra (ACR,AKS); build and deploy Karpenter; deploy sample Provisioner and workload
az-all-user: az-login az-mkaks-user az-configure-values az-helm-install-snapshot az-run-sample ## Provision the cluster and deploy Karpenter snapshot release
# TODO: az-all-savm case is not currently built to support workload identity, need to re-evaluate
az-all-savm: az-login az-mkaks-savm az-perm-savm az-configure-values az-build az-run az-run-sample ## Provision the infra (ACR,AKS); build and deploy Karpenter; deploy sample Provisioner and workload - StandaloneVirtualMachines
az-all-savm: az-login az-mkaks-savm az-perm-savm az-configure-values az-build az-run az-run-sample ## Provision the infra (ACR,AKS); build and deploy Karpenter; deploy sample Provisioner and workload - StandaloneVirtualMachines

az-login: ## Login into Azure
az account show -o none || az login
Expand Down Expand Up @@ -53,13 +58,29 @@ az-mkaks: az-mkacr ## Create test AKS cluster (with --vm-set-type AvailabilitySe
az aks get-credentials --name $(AZURE_CLUSTER_NAME) --resource-group $(AZURE_RESOURCE_GROUP) --overwrite-existing
skaffold config set default-repo $(AZURE_ACR_NAME).azurecr.io/karpenter

az-mkaks-cniv1: az-mkacr ## Create test AKS cluster (with --network-plugin azure)
az aks create --name $(AZURE_CLUSTER_NAME) --resource-group $(AZURE_RESOURCE_GROUP) --attach-acr $(AZURE_ACR_NAME) \
--enable-managed-identity --node-count 3 --generate-ssh-keys -o none --network-plugin azure \
Bryce-Soghigian marked this conversation as resolved.
Show resolved Hide resolved
--enable-oidc-issuer --enable-workload-identity
az aks get-credentials --name $(AZURE_CLUSTER_NAME) --resource-group $(AZURE_RESOURCE_GROUP) --overwrite-existing
skaffold config set default-repo $(AZURE_ACR_NAME).azurecr.io/karpenter


az-mkaks-cilium: az-mkacr ## Create test AKS cluster (with --network-dataplane cilium, --network-plugin cilium, and --network-plugin-mode overlay)
az aks create --name $(AZURE_CLUSTER_NAME) --resource-group $(AZURE_RESOURCE_GROUP) --attach-acr $(AZURE_ACR_NAME) \
--enable-managed-identity --node-count 3 --generate-ssh-keys -o none --network-dataplane cilium --network-plugin azure --network-plugin-mode overlay \
Bryce-Soghigian marked this conversation as resolved.
Show resolved Hide resolved
--enable-oidc-issuer --enable-workload-identity
az aks get-credentials --name $(AZURE_CLUSTER_NAME) --resource-group $(AZURE_RESOURCE_GROUP) --overwrite-existing
skaffold config set default-repo $(AZURE_ACR_NAME).azurecr.io/karpenter

az-mkaks-overlay: az-mkacr ## Create test AKS cluster (with --network-plugin-mode overlay)
az aks create --name $(AZURE_CLUSTER_NAME) --resource-group $(AZURE_RESOURCE_GROUP) --attach-acr $(AZURE_ACR_NAME) \
--enable-managed-identity --node-count 3 --generate-ssh-keys -o none --network-plugin azure --network-plugin-mode overlay \
--enable-oidc-issuer --enable-workload-identity
az aks get-credentials --name $(AZURE_CLUSTER_NAME) --resource-group $(AZURE_RESOURCE_GROUP) --overwrite-existing
skaffold config set default-repo $(AZURE_ACR_NAME).azurecr.io/karpenter


az-mkvnet: ## Create a VNet with address range of 10.1.0.0/16
az network vnet create --name $(CUSTOM_VNET_NAME) --resource-group $(AZURE_RESOURCE_GROUP) --location $(AZURE_LOCATION) --address-prefixes "10.1.0.0/16"

Expand Down
9 changes: 7 additions & 2 deletions hack/deploy/configure-values.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,18 @@ if [[ ! -v VNET_SUBNET_ID ]]; then
VNET_SUBNET_ID=$(jq -r ".subnets[0].id" <<< "$VNET_JSON")
fi

# The // empty ensures that if the files is 'null' or not prsent jq will output nothing
# If the value returned is none, its from jq and not the aks api in this case we return ""
NETWORK_PLUGIN=$(jq -r ".networkProfile.networkPlugin // empty | if . == \"none\" then \"\" else . end" <<< "$AKS_JSON")
Bryce-Soghigian marked this conversation as resolved.
Show resolved Hide resolved
NETWORK_PLUGIN_MODE=$(jq -r ".networkProfile.networkPluginMode // empty | if . == \"none\" then \"\" else . end" <<< "$AKS_JSON")
NETWORK_POLICY=$(jq -r ".networkProfile.networkPolicy // empty | if . == \"none\" then \"\" else . end" <<< "$AKS_JSON")

Bryce-Soghigian marked this conversation as resolved.
Show resolved Hide resolved
NODE_IDENTITIES=$(jq -r ".identityProfile.kubeletidentity.resourceId" <<< "$AKS_JSON")

KARPENTER_USER_ASSIGNED_CLIENT_ID=$(az identity show --resource-group "${AZURE_RESOURCE_GROUP}" --name "${AZURE_KARPENTER_USER_ASSIGNED_IDENTITY_NAME}" --query 'clientId' -otsv)

export CLUSTER_NAME AZURE_LOCATION AZURE_RESOURCE_GROUP_MC KARPENTER_SERVICE_ACCOUNT_NAME \
CLUSTER_ENDPOINT BOOTSTRAP_TOKEN SSH_PUBLIC_KEY VNET_SUBNET_ID KARPENTER_USER_ASSIGNED_CLIENT_ID NODE_IDENTITIES

CLUSTER_ENDPOINT BOOTSTRAP_TOKEN SSH_PUBLIC_KEY VNET_SUBNET_ID KARPENTER_USER_ASSIGNED_CLIENT_ID NODE_IDENTITIES NETWORK_PLUGIN NETWORK_PLUGIN_MODE NETWORK_POLICY
# get karpenter-values-template.yaml, if not already present (e.g. outside of repo context)
if [ ! -f karpenter-values-template.yaml ]; then
curl -sO https://raw.githubusercontent.com/Azure/karpenter/main/karpenter-values-template.yaml
Expand Down
7 changes: 4 additions & 3 deletions karpenter-values-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ controller:
# with this in place write (and read) QPS can be increased too
#- name: GODEBUG
# value: http2client=0

# options
- name: CLUSTER_NAME
value: ${CLUSTER_NAME}
Expand All @@ -21,9 +20,11 @@ controller:
- name: SSH_PUBLIC_KEY
value: "${SSH_PUBLIC_KEY}"
- name: NETWORK_PLUGIN
value: "azure"
value: ${NETWORK_PLUGIN}
- name: NETWORK_PLUGIN_MODE
value: ${NETWORK_PLUGIN_MODE}
- name: NETWORK_POLICY
value: ""
value: ${NETWORK_POLICY}
- name: VNET_SUBNET_ID
value: ${VNET_SUBNET_ID}
- name: NODE_IDENTITIES
Expand Down
29 changes: 29 additions & 0 deletions pkg/consts/consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Portions Copyright (c) Microsoft Corporation.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package consts

const (
NetworkPluginAzure = "azure"

NetworkPluginModeOverlay = "overlay"
NetworkPluginModeNone = ""

NetworkDataplaneCilium = "cilium"

// DefaultKubernetesMaxPodsAzure is the maximum number of pods to run on a node for Azure CNI.
DefaultKubernetesMaxPodsAzure = 250
)
13 changes: 8 additions & 5 deletions pkg/operator/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"os"
"strings"

"github.com/Azure/karpenter-provider-azure/pkg/consts"
"k8s.io/apimachinery/pkg/util/sets"
coreoptions "sigs.k8s.io/karpenter/pkg/operator/options"
"sigs.k8s.io/karpenter/pkg/utils/env"
Expand Down Expand Up @@ -62,11 +63,13 @@ 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
Bryce-Soghigian marked this conversation as resolved.
Show resolved Hide resolved
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?
NetworkPolicy string // => NetworkPolicy in bootstrap
NetworkPluginMode string // => Network Plugin Mode is used to control the mode the network plugin should operate in. For example, "overlay" used with --network-plugin=azure will use an overlay network (non-VNET IPs) for pods in the cluster. Learn more about overlay networking here: https://learn.microsoft.com/en-us/azure/aks/azure-cni-overlay?tabs=kubectl#overview-of-overlay-networking
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
Expand All @@ -79,7 +82,7 @@ func (o *Options) AddFlags(fs *coreoptions.FlagSet) {
fs.Float64Var(&o.VMMemoryOverheadPercent, "vm-memory-overhead-percent", env.WithDefaultFloat64("VM_MEMORY_OVERHEAD_PERCENT", 0.075), "The VM memory overhead as a percent that will be subtracted from the total memory for all instance types.")
fs.StringVar(&o.KubeletClientTLSBootstrapToken, "kubelet-bootstrap-token", env.WithDefaultString("KUBELET_BOOTSTRAP_TOKEN", ""), "[REQUIRED] The bootstrap token for new nodes to join the cluster.")
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.NetworkPluginMode, "network-plugin-mode", env.WithDefaultString("NETWORK_PLUGIN_MODE", consts.NetworkPluginModeOverlay), "[REQUIRED] network plugin mode of 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.")
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")
Expand Down
9 changes: 9 additions & 0 deletions pkg/operator/options/options_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"net/url"

"github.com/Azure/karpenter-provider-azure/pkg/consts"
"github.com/Azure/karpenter-provider-azure/pkg/utils"
"github.com/go-playground/validator/v10"
"go.uber.org/multierr"
Expand All @@ -31,12 +32,20 @@ func (o Options) Validate() error {
o.validateRequiredFields(),
o.validateEndpoint(),
o.validateVMMemoryOverheadPercent(),
o.validateNetworkPluginMode(),
o.validateNetworkDataplane(),
o.validateVnetSubnetID(),
validate.Struct(o),
)
}

func (o Options) validateNetworkPluginMode() error {
if o.NetworkPluginMode != consts.NetworkPluginModeOverlay && o.NetworkPluginMode != consts.NetworkPluginModeNone {
return fmt.Errorf("network-plugin-mode %v is invalid. network-plugin-mode must equal 'overlay' or ''", o.NetworkPluginMode)
}
return nil
}

func (o Options) validateVnetSubnetID() error {
_, err := utils.GetVnetSubnetIDComponents(o.SubnetID)
if err != nil {
Expand Down
23 changes: 17 additions & 6 deletions pkg/operator/options/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package options_test
import (
"context"
"flag"
"fmt"
"os"
"testing"

Expand Down Expand Up @@ -49,7 +50,6 @@ var _ = Describe("Options", func() {
"CLUSTER_ID",
"KUBELET_BOOTSTRAP_TOKEN",
"SSH_PUBLIC_KEY",
"NETWORK_PLUGIN",
"NETWORK_POLICY",
"NODE_IDENTITIES",
}
Expand Down Expand Up @@ -89,7 +89,6 @@ var _ = Describe("Options", func() {
os.Setenv("VM_MEMORY_OVERHEAD_PERCENT", "0.3")
os.Setenv("KUBELET_BOOTSTRAP_TOKEN", "env-bootstrap-token")
os.Setenv("SSH_PUBLIC_KEY", "env-ssh-public-key")
os.Setenv("NETWORK_PLUGIN", "env-network-plugin")
os.Setenv("NETWORK_POLICY", "env-network-policy")
os.Setenv("NODE_IDENTITIES", "/subscriptions/1234/resourceGroups/mcrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/envid1,/subscriptions/1234/resourceGroups/mcrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/envid2")
os.Setenv("VNET_SUBNET_ID", "/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sillygeese/providers/Microsoft.Network/virtualNetworks/karpentervnet/subnets/karpentersub")
Expand All @@ -106,15 +105,29 @@ var _ = Describe("Options", func() {
ClusterID: lo.ToPtr("46593302"),
KubeletClientTLSBootstrapToken: lo.ToPtr("env-bootstrap-token"),
SSHPublicKey: lo.ToPtr("env-ssh-public-key"),
NetworkPlugin: lo.ToPtr("env-network-plugin"),
NetworkPolicy: lo.ToPtr("env-network-policy"),
SubnetID: lo.ToPtr("/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/sillygeese/providers/Microsoft.Network/virtualNetworks/karpentervnet/subnets/karpentersub"),
NodeIdentities: []string{"/subscriptions/1234/resourceGroups/mcrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/envid1", "/subscriptions/1234/resourceGroups/mcrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/envid2"},
}))
})
})
Context("Validation", func() {
It("should fail validation when networkDataplane is not invalid", func() {
It("should fail when network-plugin-mode is invalid", func() {
typo := "overlaay"
errMsg := fmt.Sprintf("network-plugin-mode %v is invalid. network-plugin-mode must equal 'overlay' or ''", typo)
Bryce-Soghigian marked this conversation as resolved.
Show resolved Hide resolved

err := opts.Parse(
fs,
"--cluster-name", "my-name",
"--cluster-endpoint", "https://karpenter-000000000000.hcp.westus2.staging.azmk8s.io",
"--kubelet-bootstrap-token", "flag-bootstrap-token",
"--ssh-public-key", "flag-ssh-public-key",
"--vm-memory-overhead-percent", "-0.01",
"--network-plugin-mode", typo,
)
Expect(err).To(MatchError(ContainSubstring(errMsg)))
})
It("should fail validation when networkDataplane is not valid", func() {
err := opts.Parse(
fs,
"--cluster-endpoint", "https://karpenter-000000000000.hcp.westus2.staging.azmk8s.io",
Expand All @@ -124,7 +137,6 @@ var _ = Describe("Options", func() {
)
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 Expand Up @@ -215,7 +227,6 @@ func expectOptionsEqual(optsA *options.Options, optsB *options.Options) {
Expect(optsA.ClusterID).To(Equal(optsB.ClusterID))
Expect(optsA.KubeletClientTLSBootstrapToken).To(Equal(optsB.KubeletClientTLSBootstrapToken))
Expect(optsA.SSHPublicKey).To(Equal(optsB.SSHPublicKey))
Expect(optsA.NetworkPlugin).To(Equal(optsB.NetworkPlugin))
Expect(optsA.NetworkPolicy).To(Equal(optsB.NetworkPolicy))
Expect(optsA.NodeIdentities).To(Equal(optsB.NodeIdentities))
}
1 change: 0 additions & 1 deletion pkg/providers/imagefamily/azlinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ func (u AzureLinux) UserData(kubeletConfig *corev1beta1.KubeletConfiguration, ta
ClusterID: u.Options.ClusterID,
APIServerName: u.Options.APIServerName,
KubeletClientTLSBootstrapToken: u.Options.KubeletClientTLSBootstrapToken,
NetworkPlugin: u.Options.NetworkPlugin,
Bryce-Soghigian marked this conversation as resolved.
Show resolved Hide resolved
NetworkPolicy: u.Options.NetworkPolicy,
KubernetesVersion: u.Options.KubernetesVersion,
}
Expand Down
Loading
Loading