Use appropriate kubeadm config version for kubernetes version

Signed-off-by: James Munnelly <james@munnelly.eu>
This commit is contained in:
James Munnelly 2018-11-13 17:37:50 +00:00
parent 78f1718b86
commit ed5ff98c9e
4 changed files with 36 additions and 1 deletions

View File

@ -27,11 +27,20 @@ KIND="$(bazel info bazel-genfiles)/hack/bin/kind"
# deploy_kind will deploy a kubernetes-in-docker cluster
deploy_kind() {
# default to v1alpha3, if 1.11.x then use v1alpha2
vers="$(kubeVersion)"
config="v1alpha3"
if [[ "$vers" =~ v1\.11\..+ ]]; then
config="v1alpha2"
fi
echo "Booting Kubernetes version: $vers"
echo "Using kubeadm config api version '$config'"
# create the kind cluster
"${KIND}" create cluster \
--name="${KIND_CLUSTER_NAME}" \
--image="${KIND_IMAGE}" \
--config "${REPO_ROOT}"/test/fixtures/kind-config.yaml
--config "${REPO_ROOT}"/test/fixtures/kind/config-"$config".yaml
}
deploy_kind

View File

@ -35,3 +35,10 @@ DOCKER_REPO="quay.io/jetstack"
# This defaults to 'build' so it doesn't conflict with images built for any
# other purpose
DOCKER_TAG="build"
function kubeVersion() {
echo $(docker run \
--entrypoint="cat" \
"${KIND_IMAGE}" \
/kind/version)
}

19
test/fixtures/kind/config-v1alpha3.yaml vendored Normal file
View File

@ -0,0 +1,19 @@
# this config file is similar to the default, except we set the cluster's
# service cidr range to be 10.0.0.0/16.
# we do this because we need a fixed/predictable clusterIP of 10.0.0.15 for the
# nginx-ingress service, in order to perform HTTP01 validations during tests.
apiVersion: kind.sigs.k8s.io/v1alpha1
kind: Config
# template for kubeadm config, "" -> the default template
kubeadmConfigPatches:
- |
# config generated by kind
apiVersion: kubeadm.k8s.io/v1alpha3
kind: MasterConfiguration
networking:
serviceSubnet: 10.0.0.0/16
kubeletConfiguration:
baseConfig:
clusterDNS:
- 10.0.0.10