Skip to content

Commit 7bb6170

Browse files
authored
Merge pull request kubernetes-sigs#683 from chewong/machine-pool-azure-json
🐛 s/vm/vmss for MachinePool's azure.json
2 parents 3944724 + c5299b4 commit 7bb6170

File tree

8 files changed

+127
-143
lines changed

8 files changed

+127
-143
lines changed

hack/log/log-dump.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ dump_workload_cluster_logs() {
126126
}
127127

128128
cleanup() {
129-
kubectl delete -f "${REPO_ROOT}/hack/log/log-dump-daemonset.yaml"
129+
kubectl delete -f "${REPO_ROOT}/hack/log/log-dump-daemonset.yaml" || true
130130
source "${REPO_ROOT}/hack/log/redact.sh"
131131
}
132132

templates/test/cluster-template-prow-machine-pool-ci-version.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ spec:
149149
"resourceGroup": "${AZURE_RESOURCE_GROUP}",
150150
"securityGroupName": "${CLUSTER_NAME}-node-nsg",
151151
"location": "${AZURE_LOCATION}",
152-
"vmType": "standard",
152+
"vmType": "vmss",
153153
"vnetName": "${CLUSTER_NAME}-vnet",
154154
"vnetResourceGroup": "${CLUSTER_NAME}",
155155
"subnetName": "${CLUSTER_NAME}-node-subnet",

templates/test/patches/control-plane-ci-version.yaml

Lines changed: 0 additions & 123 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3
2+
kind: AzureMachineTemplate
3+
metadata:
4+
name: "${CLUSTER_NAME}-control-plane"
5+
spec:
6+
template:
7+
spec:
8+
image:
9+
# we use the 1.18.2 image as a workaround there is no published marketplace image for k8s CI versions.
10+
# 1.18.2 binaries and images will get replaced to the desired version by the script above.
11+
marketplace:
12+
publisher: cncf-upstream
13+
offer: capi
14+
sku: k8s-1dot18dot2-ubuntu-1804
15+
version: "2020.04.17"

templates/test/prow-ci-version/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ namespace: default
44
resources:
55
- ../prow
66
patchesStrategicMerge:
7-
- ../patches/control-plane-ci-version.yaml
7+
- ../patches/control-plane-image-ci-version.yaml
88
- patches/machine-deployment-ci-version.yaml

templates/test/prow-ci-version/patches/machine-deployment-ci-version.yaml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,6 @@ spec:
106106
"useInstanceMetadata": true
107107
}
108108
---
109-
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3
110-
kind: AzureMachineTemplate
111-
metadata:
112-
name: "${CLUSTER_NAME}-control-plane"
113-
spec:
114-
template:
115-
spec:
116-
image:
117-
# we use the 1.18.2 image as a workaround there is no published marketplace image for k8s CI versions.
118-
# 1.18.2 binaries and images will get replaced to the desired version by the script above.
119-
marketplace:
120-
publisher: cncf-upstream
121-
offer: capi
122-
sku: k8s-1dot18dot2-ubuntu-1804
123-
version: "2020.04.17"
124-
---
125109
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha3
126110
kind: KubeadmConfigTemplate
127111
metadata:

templates/test/prow-machine-pool-ci-version/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ namespace: default
44
resources:
55
- ../prow-machine-pool
66
patchesStrategicMerge:
7-
- ../patches/control-plane-ci-version.yaml
7+
- ../patches/control-plane-image-ci-version.yaml
88
- patches/machine-pool-ci-version.yaml

templates/test/prow-machine-pool-ci-version/patches/machine-pool-ci-version.yaml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,111 @@
1+
apiVersion: controlplane.cluster.x-k8s.io/v1alpha3
2+
kind: KubeadmControlPlane
3+
metadata:
4+
name: "${CLUSTER_NAME}-control-plane"
5+
spec:
6+
kubeadmConfigSpec:
7+
useExperimentalRetryJoin: true
8+
clusterConfiguration:
9+
kubernetesVersion: "ci/${CI_VERSION}"
10+
preKubeadmCommands:
11+
- bash -c /tmp/kubeadm-bootstrap.sh
12+
files:
13+
- path: /tmp/kubeadm-bootstrap.sh
14+
owner: "root:root"
15+
permissions: "0744"
16+
content: |
17+
#!/bin/bash
18+
19+
set -o nounset
20+
set -o pipefail
21+
set -o errexit
22+
[[ $(id -u) != 0 ]] && SUDO="sudo" || SUDO=""
23+
GSUTIL=gsutil
24+
if ! command -v $${GSUTIL} > /dev/null; then
25+
curl -sSL https://sdk.cloud.google.com > /tmp/gcl && bash /tmp/gcl --install-dir=~/gcloud --disable-prompts > /dev/null 2>&1
26+
GSUTIL=~/gcloud/google-cloud-sdk/bin/gsutil
27+
# For faster downloads
28+
pip install --no-cache-dir -U crcmod
29+
fi
30+
$${GSUTIL} version
31+
# This test installs release packages or binaries that are a result of the CI and release builds.
32+
# It runs '... --version' commands to verify that the binaries are correctly installed
33+
# and finally uninstalls the packages.
34+
# For the release packages it tests all versions in the support skew.
35+
LINE_SEPARATOR="*************************************************"
36+
echo "$$LINE_SEPARATOR"
37+
CI_VERSION=${CI_VERSION}
38+
if [[ "$${CI_VERSION}" != "" ]]; then
39+
CI_DIR=/tmp/k8s-ci
40+
mkdir -p $$CI_DIR
41+
declare -a PACKAGES_TO_TEST=("kubectl" "kubelet" "kubeadm")
42+
declare -a CONTAINERS_TO_TEST=("kube-apiserver" "kube-controller-manager" "kube-proxy" "kube-scheduler")
43+
CONTAINER_EXT="tar"
44+
echo "* testing CI version $$CI_VERSION"
45+
# Check for semver
46+
if [[ "$${CI_VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
47+
CI_URL="gs://kubernetes-release/release/$$CI_VERSION/bin/linux/amd64"
48+
VERSION_WITHOUT_PREFIX="${CI_VERSION#v}"
49+
DEBIAN_FRONTEND=noninteractive apt-get install -y apt-transport-https curl
50+
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
51+
echo 'deb https://apt.kubernetes.io/ kubernetes-xenial main' > /etc/apt/sources.list.d/kubernetes.list
52+
apt-get update
53+
# replace . with \.
54+
VERSION_REGEX="${VERSION_WITHOUT_PREFIX//./\\.}"
55+
PACKAGE_VERSION="$(apt-cache madison kubelet|grep $${VERSION_REGEX}- | head -n1 | cut -d '|' -f 2 | tr -d '[:space:]')"
56+
for CI_PACKAGE in "$${PACKAGES_TO_TEST[@]}"; do
57+
echo "* installing package: $$CI_PACKAGE $${PACKAGE_VERSION}"
58+
DEBIAN_FRONTEND=noninteractive apt-get install -y $$CI_PACKAGE=$$PACKAGE_VERSION
59+
done
60+
else
61+
CI_URL="gs://kubernetes-release-dev/ci/$$CI_VERSION-bazel/bin/linux/amd64"
62+
for CI_PACKAGE in "$${PACKAGES_TO_TEST[@]}"; do
63+
echo "* downloading binary: $$CI_URL/$$CI_PACKAGE"
64+
$${GSUTIL} cp "$$CI_URL/$$CI_PACKAGE" "$$CI_DIR/$$CI_PACKAGE"
65+
chmod +x "$$CI_DIR/$$CI_PACKAGE"
66+
mv "$$CI_DIR/$$CI_PACKAGE" "/usr/bin/$$CI_PACKAGE"
67+
done
68+
systemctl restart kubelet
69+
fi
70+
for CI_CONTAINER in "$${CONTAINERS_TO_TEST[@]}"; do
71+
echo "* downloading package: $$CI_URL/$$CI_CONTAINER.$$CONTAINER_EXT"
72+
$${GSUTIL} cp "$$CI_URL/$$CI_CONTAINER.$$CONTAINER_EXT" "$$CI_DIR/$$CI_CONTAINER.$$CONTAINER_EXT"
73+
$${SUDO} ctr -n k8s.io images import "$$CI_DIR/$$CI_CONTAINER.$$CONTAINER_EXT" || echo "* ignoring expected 'ctr images import' result"
74+
$${SUDO} ctr -n k8s.io images tag k8s.gcr.io/$$CI_CONTAINER-amd64:"$${CI_VERSION//+/_}" k8s.gcr.io/$$CI_CONTAINER:"$${CI_VERSION//+/_}"
75+
$${SUDO} ctr -n k8s.io images tag k8s.gcr.io/$$CI_CONTAINER-amd64:"$${CI_VERSION//+/_}" gcr.io/kubernetes-ci-images/$$CI_CONTAINER:"$${CI_VERSION//+/_}"
76+
done
77+
fi
78+
echo "* checking binary versions"
79+
echo "ctr version: " $(ctr version)
80+
echo "kubeadm version: " $(kubeadm version -o=short)
81+
echo "kubectl version: " $(kubectl version --client=true --short=true)
82+
echo "kubelet version: " $(kubelet --version)
83+
echo "$$LINE_SEPARATOR"
84+
- path: /etc/kubernetes/azure.json
85+
owner: "root:root"
86+
permissions: "0644"
87+
content: |
88+
{
89+
"cloud": "AzurePublicCloud",
90+
"tenantId": "${AZURE_TENANT_ID}",
91+
"subscriptionId": "${AZURE_SUBSCRIPTION_ID}",
92+
"aadClientId": "${AZURE_CLIENT_ID}",
93+
"aadClientSecret": "${AZURE_CLIENT_SECRET}",
94+
"resourceGroup": "${AZURE_RESOURCE_GROUP}",
95+
"securityGroupName": "${CLUSTER_NAME}-node-nsg",
96+
"location": "${AZURE_LOCATION}",
97+
"vmType": "vmss",
98+
"vnetName": "${CLUSTER_NAME}-vnet",
99+
"vnetResourceGroup": "${CLUSTER_NAME}",
100+
"subnetName": "${CLUSTER_NAME}-node-subnet",
101+
"routeTableName": "${CLUSTER_NAME}-node-routetable",
102+
"userAssignedID": "${CLUSTER_NAME}",
103+
"loadBalancerSku": "standard",
104+
"maximumLoadBalancerRuleCount": 250,
105+
"useManagedIdentityExtension": false,
106+
"useInstanceMetadata": true
107+
}
108+
---
1109
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha3
2110
kind: KubeadmConfig
3111
metadata:

0 commit comments

Comments
 (0)