Skip to content

Commit 86700a1

Browse files
authored
Merge pull request #3480 from jackfrancis/cherry-pick-3456-to-release-1.8
[release-1.8] Switch k8s custom build templates to out of tree
2 parents d751670 + 0e56745 commit 86700a1

File tree

10 files changed

+44
-72
lines changed

10 files changed

+44
-72
lines changed

hack/util.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ capz::util::should_build_ccm() {
4646
if [[ -n "${TEST_CCM:-}" ]]; then
4747
echo "true" && return
4848
fi
49-
# If conformance is being tested with CI artifacts, CCM should be built.
49+
# If testing a custom Kubernetes version, CCM should be built.
50+
if [[ "$(capz::util::should_build_kubernetes)" == "true" ]]; then
51+
echo "true" && return
52+
fi
53+
# If using Kubernetes CI artifacts, CCM should be built.
5054
if [[ "${E2E_ARGS:-}" == "-kubetest.use-ci-artifacts" ]]; then
5155
echo "true" && return
5256
fi

scripts/ci-build-azure-ccm.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ setup() {
4646

4747
# the azure-cloud-provider repo expects IMAGE_REGISTRY.
4848
export IMAGE_REGISTRY=${REGISTRY}
49-
pushd "${AZURE_CLOUD_PROVIDER_ROOT}" && TAG=$(git rev-parse --short=7 HEAD) &&
50-
IMAGE_TAG_CCM="${IMAGE_TAG_CCM:-${TAG}}" && IMAGE_TAG_CNM="${IMAGE_TAG_CNM:-${TAG}}" &&
49+
pushd "${AZURE_CLOUD_PROVIDER_ROOT}" && IMAGE_TAG=$(git rev-parse --short=7 HEAD) &&
50+
IMAGE_TAG_CCM="${IMAGE_TAG_CCM:-${IMAGE_TAG}}" && IMAGE_TAG_CNM="${IMAGE_TAG_CNM:-${IMAGE_TAG}}" &&
5151
export IMAGE_TAG_CCM && export IMAGE_TAG_CNM && popd
5252
echo "Image registry is ${REGISTRY}"
5353
echo "Image Tag CCM is ${IMAGE_TAG_CCM}"

scripts/ci-build-kubernetes.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ setup() {
7171

7272
# Docker tags cannot contain '+'
7373
# ref: https://github.com/kubernetes/kubernetes/blob/5491484aa91fd09a01a68042e7674bc24d42687a/build/lib/release.sh#L345-L346
74-
export IMAGE_TAG="${KUBE_GIT_VERSION/+/_}"
75-
echo "using K8s IMAGE_TAG=${IMAGE_TAG}"
74+
export KUBE_IMAGE_TAG="${KUBE_GIT_VERSION/+/_}"
75+
echo "using K8s KUBE_IMAGE_TAG=${KUBE_IMAGE_TAG}"
7676
}
7777

7878
main() {
@@ -85,7 +85,7 @@ main() {
8585
if [[ "${KUBE_BUILD_CONFORMANCE:-}" =~ [yY] ]]; then
8686
IMAGES+=("conformance")
8787
# consume by the conformance test suite
88-
export CONFORMANCE_IMAGE="${REGISTRY}/conformance:${IMAGE_TAG}"
88+
export CONFORMANCE_IMAGE="${REGISTRY}/conformance:${KUBE_IMAGE_TAG}"
8989
fi
9090

9191
if [[ "$(can_reuse_artifacts)" == "false" ]]; then
@@ -102,7 +102,7 @@ main() {
102102
for IMAGE_NAME in "${IMAGES[@]}"; do
103103
# extract docker image URL form `docker load` output
104104
OLD_IMAGE_URL="$(docker load --input "${KUBE_ROOT}/_output/release-images/amd64/${IMAGE_NAME}.tar" | ${GREP_BINARY} -oP '(?<=Loaded image: )[^ ]*' | head -n 1)"
105-
NEW_IMAGE_URL="${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}"
105+
NEW_IMAGE_URL="${REGISTRY}/${IMAGE_NAME}:${KUBE_IMAGE_TAG}"
106106
# retag and push images to ACR
107107
docker tag "${OLD_IMAGE_URL}" "${NEW_IMAGE_URL}" && docker push "${NEW_IMAGE_URL}"
108108
done
@@ -128,7 +128,7 @@ main() {
128128
# can_reuse_artifacts returns true if there exists Kubernetes artifacts built from a PR that we can reuse
129129
can_reuse_artifacts() {
130130
for IMAGE_NAME in "${IMAGES[@]}"; do
131-
if ! docker pull "${REGISTRY}/${IMAGE_NAME}:${IMAGE_TAG}"; then
131+
if ! docker pull "${REGISTRY}/${IMAGE_NAME}:${KUBE_IMAGE_TAG}"; then
132132
echo "false" && return
133133
fi
134134
done

templates/test/dev/cluster-template-custom-builds-machine-pool.yaml

Lines changed: 11 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/test/dev/cluster-template-custom-builds.yaml

Lines changed: 10 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace: default
22
resources:
3-
- ../../../test/ci/prow-intree-cloud-provider-machine-pool
3+
- ../../../test/ci/prow-machine-pool
44
patchesStrategicMerge:
55
- ../patches/control-plane-custom-builds.yaml
66
- patches/custom-builds.yaml

templates/test/dev/custom-builds/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace: default
22
resources:
3-
- ../../../test/ci/prow-intree-cloud-provider
3+
- ../../../test/ci/prow
44
- ../../../addons/metrics-server/metrics-server-resource-set.yaml
55
patchesStrategicMerge:
66
- patches/machine-deployment-pr-version.yaml

templates/test/dev/custom-builds/patches/kubeadm-controlplane-bootstrap.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@
4747
rm /tmp/yq_linux_amd64.tar.gz
4848
4949
export KUBECONFIG=/etc/kubernetes/admin.conf
50-
kubectl -n kube-system set image daemonset/kube-proxy kube-proxy="${REGISTRY}/kube-proxy:${IMAGE_TAG}"
50+
kubectl -n kube-system set image daemonset/kube-proxy kube-proxy="${REGISTRY}/kube-proxy:${KUBE_IMAGE_TAG}"
5151
systemctl stop kubelet
52-
yq e '.spec.containers[0].image = "${REGISTRY}/kube-apiserver:${IMAGE_TAG}"' -i /etc/kubernetes/manifests/kube-apiserver.yaml
53-
yq e '.spec.containers[0].image = "${REGISTRY}/kube-controller-manager:${IMAGE_TAG}"' -i /etc/kubernetes/manifests/kube-controller-manager.yaml
54-
yq e '.spec.containers[0].image = "${REGISTRY}/kube-scheduler:${IMAGE_TAG}"' -i /etc/kubernetes/manifests/kube-scheduler.yaml
52+
yq e '.spec.containers[0].image = "${REGISTRY}/kube-apiserver:${KUBE_IMAGE_TAG}"' -i /etc/kubernetes/manifests/kube-apiserver.yaml
53+
yq e '.spec.containers[0].image = "${REGISTRY}/kube-controller-manager:${KUBE_IMAGE_TAG}"' -i /etc/kubernetes/manifests/kube-controller-manager.yaml
54+
yq e '.spec.containers[0].image = "${REGISTRY}/kube-scheduler:${KUBE_IMAGE_TAG}"' -i /etc/kubernetes/manifests/kube-scheduler.yaml
5555
systemctl restart kubelet
5656
path: /tmp/replace-k8s-components.sh
5757
owner: "root:root"

templates/test/dev/patches/control-plane-custom-builds.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ spec:
6060
rm /tmp/yq_linux_amd64.tar.gz
6161
6262
export KUBECONFIG=/etc/kubernetes/admin.conf
63-
kubectl -n kube-system set image daemonset/kube-proxy kube-proxy="${REGISTRY}/kube-proxy:${IMAGE_TAG}"
63+
kubectl -n kube-system set image daemonset/kube-proxy kube-proxy="${REGISTRY}/kube-proxy:${KUBE_IMAGE_TAG}"
6464
systemctl stop kubelet
65-
yq e '.spec.containers[0].image = "${REGISTRY}/kube-apiserver:${IMAGE_TAG}"' -i /etc/kubernetes/manifests/kube-apiserver.yaml
66-
yq e '.spec.containers[0].image = "${REGISTRY}/kube-controller-manager:${IMAGE_TAG}"' -i /etc/kubernetes/manifests/kube-controller-manager.yaml
67-
yq e '.spec.containers[0].image = "${REGISTRY}/kube-scheduler:${IMAGE_TAG}"' -i /etc/kubernetes/manifests/kube-scheduler.yaml
65+
yq e '.spec.containers[0].image = "${REGISTRY}/kube-apiserver:${KUBE_IMAGE_TAG}"' -i /etc/kubernetes/manifests/kube-apiserver.yaml
66+
yq e '.spec.containers[0].image = "${REGISTRY}/kube-controller-manager:${KUBE_IMAGE_TAG}"' -i /etc/kubernetes/manifests/kube-controller-manager.yaml
67+
yq e '.spec.containers[0].image = "${REGISTRY}/kube-scheduler:${KUBE_IMAGE_TAG}"' -i /etc/kubernetes/manifests/kube-scheduler.yaml
6868
systemctl restart kubelet
6969
- path: /etc/kubernetes/azure.json
7070
owner: "root:root"

test/e2e/cloud-provider-azure.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func InstallCalicoAndCloudProviderAzureHelmChart(ctx context.Context, input clus
4949
StringValues: []string{fmt.Sprintf("cloudControllerManager.clusterCIDR=%s", strings.Join(cidrBlocks, `\,`))},
5050
}
5151
// If testing a CI version of Kubernetes, use CCM and CNM images built from source.
52-
if useCIArtifacts {
52+
if useCIArtifacts || usePRArtifacts {
5353
options.Values = append(options.Values, fmt.Sprintf("cloudControllerManager.imageName=%s", os.Getenv("CCM_IMAGE_NAME")))
5454
options.Values = append(options.Values, fmt.Sprintf("cloudNodeManager.imageName=%s", os.Getenv("CNM_IMAGE_NAME")))
5555
options.Values = append(options.Values, fmt.Sprintf("cloudControllerManager.imageRepository=%s", os.Getenv("IMAGE_REGISTRY")))

0 commit comments

Comments
 (0)