diff --git a/hack/ci/lib/cluster_create.sh b/hack/ci/lib/cluster_create.sh index c031a0197..6dbfacbdb 100755 --- a/hack/ci/lib/cluster_create.sh +++ b/hack/ci/lib/cluster_create.sh @@ -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 diff --git a/hack/ci/lib/lib.sh b/hack/ci/lib/lib.sh index 089ab968f..5f0f3d83d 100644 --- a/hack/ci/lib/lib.sh +++ b/hack/ci/lib/lib.sh @@ -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) +} diff --git a/test/fixtures/kind-config.yaml b/test/fixtures/kind/config-v1alpha2.yaml similarity index 100% rename from test/fixtures/kind-config.yaml rename to test/fixtures/kind/config-v1alpha2.yaml diff --git a/test/fixtures/kind/config-v1alpha3.yaml b/test/fixtures/kind/config-v1alpha3.yaml new file mode 100644 index 000000000..673c65e1d --- /dev/null +++ b/test/fixtures/kind/config-v1alpha3.yaml @@ -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