From d720d8e02b939ef629181f2f52811b07ff3d0440 Mon Sep 17 00:00:00 2001 From: irbekrm Date: Thu, 21 Apr 2022 12:36:33 +0100 Subject: [PATCH] Fix kind cluster creation with kube 1.19 and 1.18 By specifying a different kind config that does not use an etcd flag that was only add in later etcd versions Signed-off-by: irbekrm --- make/cluster.sh | 7 ++++++- make/config/kind/config.yaml | 13 +++++++++++++ .../{v1beta2.yaml => config_etcd_no_fsync.yaml} | 0 make/e2e-setup.mk | 2 +- 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 make/config/kind/config.yaml rename make/config/kind/{v1beta2.yaml => config_etcd_no_fsync.yaml} (100%) diff --git a/make/cluster.sh b/make/cluster.sh index 3cbc3cf9b..c2b1fbdb8 100755 --- a/make/cluster.sh +++ b/make/cluster.sh @@ -163,7 +163,12 @@ setup_kind() { # (1) Does the kind cluster already exist? if ! kind get clusters -q | grep -q "^$kind_cluster_name\$"; then - trace kind create cluster --config make/config/kind/v1beta2.yaml \ + # Kind with Kubernetes v1.18 and v1.19 need different config files + config="config_etcd_no_fsync" + if [[ "$k8s_version" == 1.18 || "$k8s_version" == 1.19 ]]; then + config="config" + fi + trace kind create cluster --config "make/config/kind/${config}.yaml" \ --image "$image" \ --name "$kind_cluster_name" fi diff --git a/make/config/kind/config.yaml b/make/config/kind/config.yaml new file mode 100644 index 000000000..c59fa0856 --- /dev/null +++ b/make/config/kind/config.yaml @@ -0,0 +1,13 @@ +# Kind config for kind 1.18 and 1.19 node images. Use +# make/config/kind/config_etcd_no_fsync.yaml for newer versions of kind as they +# support --unsafe-no-fsync etcd flag, which improves test speed. +apiVersion: kind.x-k8s.io/v1alpha4 +kind: Cluster +kubeadmConfigPatches: + - | + apiVersion: kubeadm.k8s.io/v1beta2 + kind: ClusterConfiguration + metadata: + name: config +nodes: + - role: control-plane diff --git a/make/config/kind/v1beta2.yaml b/make/config/kind/config_etcd_no_fsync.yaml similarity index 100% rename from make/config/kind/v1beta2.yaml rename to make/config/kind/config_etcd_no_fsync.yaml diff --git a/make/e2e-setup.mk b/make/e2e-setup.mk index e7f199593..9ad915a2c 100644 --- a/make/e2e-setup.mk +++ b/make/e2e-setup.mk @@ -64,7 +64,7 @@ e2e-setup-kind: kind-exists # used as a prerequisite. If we were to use .PHONY, then the file's # timestamp would not be used to check whether targets should be rebuilt, # and they would get constantly rebuilt. -bin/scratch/kind-exists: make/config/kind/v1beta2.yaml preload-kind-image make/cluster.sh FORCE bin/tools/kind bin/tools/kubectl bin/tools/yq | bin/scratch +bin/scratch/kind-exists: make/config/kind/config.yaml make/config/kind/config_etcd_no_fsync.yaml preload-kind-image make/cluster.sh FORCE bin/tools/kind bin/tools/kubectl bin/tools/yq | bin/scratch @$(eval KIND_CLUSTER_NAME ?= kind) @make/cluster.sh --name $(KIND_CLUSTER_NAME) @if [ "$(shell cat $@ 2>/dev/null)" != kind ]; then echo kind > $@; else touch $@; fi