Repository navigation
CKS: pin the autoscaler and CCM in the binaries ISO builder - #14649
Open
bhouse-nexthop wants to merge 1 commit into
Open
bhouse-nexthop wants to merge 1 commit into
bhouse-nexthop wants to merge 1 commit into
Conversation
create-kubernetes-binaries-iso.sh downloaded the cluster-autoscaler manifest from kubernetes/autoscaler master and the CCM manifest from cloudstack-kubernetes-provider main, and bundled whatever images those named. The autoscaler image was apache/cloudstack-kubernetes-autoscaler :latest, a 2022 development build, for every Kubernetes version, and the CCM was whatever main held on the day of the build (v1.1.0 for a long time, which never initialises nodes). Nothing recorded what went in. - Autoscaler: use the newest cluster-autoscaler release for the ISO's Kubernetes minor version (or AUTOSCALER_VERSION), take the CloudStack example manifest from that release tag, and bundle the upstream registry.k8s.io image of the same release, which includes the CloudStack provider. Add a ClusterRole for the VolumeAttachment and DRA read access that newer releases need and the example lacks. - CCM: pin to v1.2.0 (or CCM_VERSION) and set the manifest's image to that tag. - Write versions.txt into the ISO with every version, URL and image digest. - Download with curl -f, one file per call, so a failed download stops the build instead of bundling an error page. Build in a fresh mktemp directory, and remove pulled images with --sync so containerd's garbage collection can't delete layers the next pull shares. - Upgrade: the autoscaler image now changes with the Kubernetes version, so once every node is upgraded, redeploy the autoscaler of a cluster with autoscaling enabled from the new ISO, with the cluster's min, max and id. A failure is logged and doesn't fail the upgrade. Signed-off-by: Brad House <bhouse@nexthop.ai>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.22 #14649 +/- ##
=========================================
Coverage 18.32% 18.32%
- Complexity 16644 16646 +2
=========================================
Files 5939 5939
Lines 537768 537787 +19
Branches 65929 65931 +2
=========================================
+ Hits 98551 98560 +9
- Misses 428008 428018 +10
Partials 11209 11209
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR pins the cluster autoscaler and the cloud controller manager (CCM) that
scripts/util/create-kubernetes-binaries-iso.shbundles into the CKS binaries ISO, and writes a list of the ISO's contents into the ISO. Because the autoscaler now changes with the Kubernetes version, a cluster upgrade also redeploys the autoscaler from the new ISO.Fixes #14648
Related: #14598 fixes the same download problems in the node-side scripts (
deploy-provider,autoscale-kube-cluster,deploy-csi-driver). This PR doesn't touch those scripts, so the two don't conflict.What was wrong
kubernetes/autoscalermaster, and its image isapache/cloudstack-kubernetes-autoscaler:latest.cloudstack-kubernetes-providermain, with whatever imagemainnamed on the day of the build.curlwithout-f, so a 404 page was saved and bundled as a manifest or binary.What changed
Autoscaler (ISO builder)
cluster-autoscaler-<minor>.<patch>release tag for the ISO's Kubernetes minor version.git ls-remote, so no API token is needed.AUTOSCALER_VERSION=1.33.4picks an exact release instead.cloudprovider/cloudstack/examples/cluster-autoscaler-standard.yaml) exists at the latest tag of every minor from 1.20 to 1.37, so no fallback manifest is needed.registry.k8s.io/autoscaling/cluster-autoscaler:v<version>.apache/cloudstack-kubernetes-autoscaler:latestat every tag, so it can't be used as is../cluster-autoscalerfrom/, as the manifest expects.cluster-autoscaler-extraClusterRole and binding with that read access. At 1.36.2 that makes the CloudStack example's permissions match the AWS example's.CCM (ISO builder)
CCM_VERSION=v1.3.0-rc1picks another release tag.apache/cloudstack-kubernetes-provider:<tag>. This is needed because a tag's manifest doesn't always name its own image:v1.3.0-rc1's names v1.2.0.versions.txtin the ISO.yamlfile, so the node scripts that copy*.yamlfrom the ISO ignore it.Download and build robustness (ISO builder)
curl -fsSL --retry 3, one file per call, so a failed download stops the build. A multi-URLcurlwould only report the last file's status.curl | sedpipelines forkubelet.serviceand10-kubeadm.confnow download first and then edit, so a failed download is no longer hidden by the pipe.wgetto the same helper.mktemp -ddirectory, removed on exit, instead of a fixed/tmp/iso. Files left behind by a failed build no longer end up in the next ISO.ctr image rm --sync.--sync, containerd's asynchronous garbage collection could delete a layer that the next image shares, between that image's pull and its export.ctr: failed to get reader: content digest ...: not found.Upgrade (
KubernetesClusterUpgradeWorker)upgrade-kubernetes.shalready copies the new ISO'sautoscaler.yamlto the control node, but the running autoscaler was never touched. With:latesteverywhere, that didn't matter.autoscale-kube-cluster -ewith the cluster's id, min and max from the database, the same command as enabling autoscaling.Upgrading, so autoscaling can't be changed through the API in the meantime.Not changed here:
autoscale-kube-clusteranddeploy-providerstill download frommaster/mainwhen the ISO doesn't have the manifests. CKS: fix the add-on scripts' download and option handling #14598 changes those same lines, so pinning them is left until it is merged.kubelet.serviceand10-kubeadm.confstill come fromshapeblue/cloudstack-nonossmain. Their URLs are now recorded inversions.txt.:latestautoscaler. That is the same autoscaler a cluster created from that ISO would get.Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
ISO builds. I built ISOs with the modified script on an Ubuntu x86_64 host with containerd 2.x. I then extracted
versions.txt,autoscaler.yaml,provider.yamland the image tarballs from each ISO withisoinfo.registry.k8s.io/autoscaling/cluster-autoscaler:v1.31.5apache/cloudstack-kubernetes-provider:v1.2.0...cluster-autoscaler:v1.33.6...:v1.2.0AUTOSCALER_VERSION=v1.33.4 CCM_VERSION=1.3.0-rc1...cluster-autoscaler:v1.33.4...:v1.3.0-rc1(the tag's manifest named v1.2.0)The 1.31 build was done with Calico 3.29.3 and Dashboard 2.7.0. Later builds used flannel and Headlamp manifests, because Docker Hub's anonymous pull limit stopped the Calico/Dashboard builds partway.
For each ISO I checked the following:
autoscaler.yamlandprovider.yamlname exactly those images, withimagePullPolicy: IfNotPresent.<min>:<max>:<cluster-id>placeholders are intact.docker/holdscluster-autoscaler:v<version>.tarandcloudstack-kubernetes-provider:<tag>.tar, and the image name inside each tarball matches the manifest.versions.txthas the right versions and URLs.Failure cases. Each of these stops the build with
curl: (22) ... 404and a non-zero exit:CCM_VERSION=v9.9.9AUTOSCALER_VERSION=1.33.99Builder pieces tested on their own:
AUTOSCALER_VERSION.AUTOSCALER_VERSION=1.32.7on 1.33 prints the mismatch warning.cni-plugins-amd64-<ver>.tgzname.Unit tests. New tests in
KubernetesClusterUpgradeWorkerTestcoverupdateAutoscaler:autoscale-kube-cluster -i <uuid> -e -M <max> -m <min>;All 82 tests in the
kubernetes-servicemodule pass, and checkstyle is clean.Not tested:
How did you try to break this feature and the system with this change?
autoscaler.yaml,provider.yaml,docker/*.tar).master/main.AUTOSCALER_VERSIONoverrides it.image:line and fails otherwise, instead of silently bundling the wrong image.---can't join the last line.