Skip to content

Commit

Permalink
feat: supporting 1.30 bootstrap via removing kubelet flag --azure-con…
Browse files Browse the repository at this point in the history
…tainer-registry-config for 1.30 onwards
  • Loading branch information
Bryce-Soghigian committed May 24, 2024
1 parent 4ec1d97 commit cb6e094
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
k8sVersion: ["1.25.x", "1.26.x", "1.27.x", "1.28.x", "1.29.x"]
k8sVersion: ["1.25.x", "1.26.x", "1.27.x", "1.28.x", "1.29.x", "1.30.x"]
env:
K8S_VERSION: ${{ matrix.k8sVersion }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require (
github.com/Azure/skewer v0.0.19
github.com/Pallinder/go-randomdata v1.2.0
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137
github.com/blang/semver/v4 v4.0.0
github.com/go-logr/logr v1.4.1
github.com/go-logr/zapr v1.3.0
github.com/go-playground/validator/v10 v10.19.0
Expand Down Expand Up @@ -66,7 +67,6 @@ require (
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
github.com/avast/retry-go v3.0.0+incompatible // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/blendle/zapdriver v1.3.1 // indirect
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
Expand Down
8 changes: 7 additions & 1 deletion pkg/providers/imagefamily/bootstrap/aksbootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"text/template"

"github.com/Azure/karpenter-provider-azure/pkg/utils"
"github.com/blang/semver/v4"
"github.com/samber/lo"
v1 "k8s.io/api/core/v1"
"knative.dev/pkg/ptr"
Expand Down Expand Up @@ -238,12 +239,12 @@ var (
// source note: unique per nodepool. partially user-specified, static, and RP-generated
// removed --image-pull-progress-deadline=30m (not in 1.24?)
// removed --network-plugin=cni (not in 1.24?)
// removed "--azure-container-registry-config" (not in 1.30)
kubeletFlagsBase = map[string]string{
"--address": "0.0.0.0",
"--anonymous-auth": "false",
"--authentication-token-webhook": "true",
"--authorization-mode": "Webhook",
"--azure-container-registry-config": "/etc/kubernetes/azure.json",
"--cgroups-per-qos": "true",
"--client-ca-file": "/etc/kubernetes/certs/ca.crt",
"--cloud-config": "/etc/kubernetes/azure.json",
Expand Down Expand Up @@ -449,6 +450,11 @@ func (a AKS) applyOptions(nbv *NodeBootstrapVariables) {
nbv.GPUDriverVersion = a.GPUDriverVersion
nbv.GPUImageSHA = a.GPUImageSHA
}

if semver.MustParse(a.KubernetesVersion).Minor < 30 {
kubeletFlagsBase["--azure-container-registry-config"] = "/etc/kubernetes/azure.json"
}

// merge and stringify labels
kubeletLabels := lo.Assign(kubeletNodeLabelsBase, a.Labels)
getAgentbakerGeneratedLabels(a.ResourceGroup, kubeletLabels)
Expand Down
27 changes: 27 additions & 0 deletions pkg/providers/instancetype/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,33 @@ var _ = Describe("InstanceType Provider", func() {
})
})

Context("Bootstrap", func() {
It("should gate kubelet flags that are dependent on kubelet version", func() {
ExpectApplied(ctx, env.Client, nodePool, nodeClass)
pod := coretest.UnschedulablePod()
ExpectProvisioned(ctx, env.Client, cluster, cloudProvider, coreProvisioner, pod)
ExpectScheduled(ctx, env.Client, pod)

Expect(azureEnv.VirtualMachinesAPI.VirtualMachineCreateOrUpdateBehavior.CalledWithInput.Len()).To(Equal(1))
vm := azureEnv.VirtualMachinesAPI.VirtualMachineCreateOrUpdateBehavior.CalledWithInput.Pop().VM
customData := *vm.Properties.OSProfile.CustomData
Expect(customData).ToNot(BeNil())
decodedBytes, err := base64.StdEncoding.DecodeString(customData)
Expect(err).To(Succeed())
decodedString := string(decodedBytes[:])
kubeletFlags := decodedString[strings.Index(decodedString, "KUBELET_FLAGS=")+len("KUBELET_FLAGS="):]
if env.Version.Minor() < 30 {
Expect(kubeletFlags).To(
ContainSubstring("--azure-container-registry-config"),
)
} else {
Expect(kubeletFlags).To(Not(
ContainSubstring("--azure-container-registry-config"),
))
}
})
})

Context("LoadBalancer", func() {
resourceGroup := "test-resourceGroup"

Expand Down

0 comments on commit cb6e094

Please sign in to comment.