@@ -52,19 +52,17 @@ presubmits:
5252
5353 # Additional features are not in kind.yaml, but they can be added at the end.
5454 for feature in ${features[@]}; do echo " ${feature}: true"; done
55-
56- # Append ClusterConfiguration which causes etcd to use /tmp
57- # (https://github.com/kubernetes-sigs/kind/issues/845#issuecomment-1261248420).
58- # There's no kubeadmConfigPatches in any kind.yaml, so we can append at the end.
59- cat <<EOF
60- kubeadmConfigPatches:
61- - |
62- kind: ClusterConfiguration
63- etcd:
64- local:
65- dataDir: /tmp/etcd
66- EOF
6755 ) >/tmp/kind.yaml
56+
57+ # Add or extend kubeadmConfigPatches with a ClusterConfiguration which causes etcd to use /tmp
58+ # (https://github.com/kubernetes-sigs/kind/issues/845#issuecomment-1261248420).
59+ # kind.yaml may or may not have a `kubeadmConfigPatches`, so we have to be
60+ # careful.
61+ if ! grep -q '^kubeadmConfigPatches:$' /tmp/kind.yaml; then
62+ echo "kubeadmConfigPatches:" >>/tmp/kind.yaml
63+ fi
64+ sed -i -e '/^kubeadmConfigPatches:$/a\' -e '- |\n kind: ClusterConfiguration\n etcd:\n local:\n dataDir: /tmp/etcd\n' /tmp/kind.yaml
65+
6866 cat /tmp/kind.yaml
6967 kind create cluster --retain --config /tmp/kind.yaml --image dra/node:latest
7068 atexit () {
@@ -138,19 +136,17 @@ presubmits:
138136
139137 # Additional features are not in kind.yaml, but they can be added at the end.
140138 for feature in ${features[@]}; do echo " ${feature}: true"; done
141-
142- # Append ClusterConfiguration which causes etcd to use /tmp
143- # (https://github.com/kubernetes-sigs/kind/issues/845#issuecomment-1261248420).
144- # There's no kubeadmConfigPatches in any kind.yaml, so we can append at the end.
145- cat <<EOF
146- kubeadmConfigPatches:
147- - |
148- kind: ClusterConfiguration
149- etcd:
150- local:
151- dataDir: /tmp/etcd
152- EOF
153139 ) >/tmp/kind.yaml
140+
141+ # Add or extend kubeadmConfigPatches with a ClusterConfiguration which causes etcd to use /tmp
142+ # (https://github.com/kubernetes-sigs/kind/issues/845#issuecomment-1261248420).
143+ # kind.yaml may or may not have a `kubeadmConfigPatches`, so we have to be
144+ # careful.
145+ if ! grep -q '^kubeadmConfigPatches:$' /tmp/kind.yaml; then
146+ echo "kubeadmConfigPatches:" >>/tmp/kind.yaml
147+ fi
148+ sed -i -e '/^kubeadmConfigPatches:$/a\' -e '- |\n kind: ClusterConfiguration\n etcd:\n local:\n dataDir: /tmp/etcd\n' /tmp/kind.yaml
149+
154150 cat /tmp/kind.yaml
155151 kind create cluster --retain --config /tmp/kind.yaml --image dra/node:latest
156152 atexit () {
@@ -224,19 +220,17 @@ presubmits:
224220
225221 # Additional features are not in kind.yaml, but they can be added at the end.
226222 for feature in ${features[@]}; do echo " ${feature}: true"; done
227-
228- # Append ClusterConfiguration which causes etcd to use /tmp
229- # (https://github.com/kubernetes-sigs/kind/issues/845#issuecomment-1261248420).
230- # There's no kubeadmConfigPatches in any kind.yaml, so we can append at the end.
231- cat <<EOF
232- kubeadmConfigPatches:
233- - |
234- kind: ClusterConfiguration
235- etcd:
236- local:
237- dataDir: /tmp/etcd
238- EOF
239223 ) >/tmp/kind.yaml
224+
225+ # Add or extend kubeadmConfigPatches with a ClusterConfiguration which causes etcd to use /tmp
226+ # (https://github.com/kubernetes-sigs/kind/issues/845#issuecomment-1261248420).
227+ # kind.yaml may or may not have a `kubeadmConfigPatches`, so we have to be
228+ # careful.
229+ if ! grep -q '^kubeadmConfigPatches:$' /tmp/kind.yaml; then
230+ echo "kubeadmConfigPatches:" >>/tmp/kind.yaml
231+ fi
232+ sed -i -e '/^kubeadmConfigPatches:$/a\' -e '- |\n kind: ClusterConfiguration\n etcd:\n local:\n dataDir: /tmp/etcd\n' /tmp/kind.yaml
233+
240234 cat /tmp/kind.yaml
241235 kind create cluster --retain --config /tmp/kind.yaml --image dra/node:latest
242236 atexit () {
@@ -308,19 +302,17 @@ presubmits:
308302
309303 # Additional features are not in kind.yaml, but they can be added at the end.
310304 for feature in ${features[@]}; do echo " ${feature}: true"; done
311-
312- # Append ClusterConfiguration which causes etcd to use /tmp
313- # (https://github.com/kubernetes-sigs/kind/issues/845#issuecomment-1261248420).
314- # There's no kubeadmConfigPatches in any kind.yaml, so we can append at the end.
315- cat <<EOF
316- kubeadmConfigPatches:
317- - |
318- kind: ClusterConfiguration
319- etcd:
320- local:
321- dataDir: /tmp/etcd
322- EOF
323305 ) >/tmp/kind.yaml
306+
307+ # Add or extend kubeadmConfigPatches with a ClusterConfiguration which causes etcd to use /tmp
308+ # (https://github.com/kubernetes-sigs/kind/issues/845#issuecomment-1261248420).
309+ # kind.yaml may or may not have a `kubeadmConfigPatches`, so we have to be
310+ # careful.
311+ if ! grep -q '^kubeadmConfigPatches:$' /tmp/kind.yaml; then
312+ echo "kubeadmConfigPatches:" >>/tmp/kind.yaml
313+ fi
314+ sed -i -e '/^kubeadmConfigPatches:$/a\' -e '- |\n kind: ClusterConfiguration\n etcd:\n local:\n dataDir: /tmp/etcd\n' /tmp/kind.yaml
315+
324316 cat /tmp/kind.yaml
325317 kind create cluster --retain --config /tmp/kind.yaml --image dra/node:latest
326318 atexit () {
@@ -437,19 +429,17 @@ presubmits:
437429
438430 # Additional features are not in kind.yaml, but they can be added at the end.
439431 for feature in ${features[@]}; do echo " ${feature}: true"; done
440-
441- # Append ClusterConfiguration which causes etcd to use /tmp
442- # (https://github.com/kubernetes-sigs/kind/issues/845#issuecomment-1261248420).
443- # There's no kubeadmConfigPatches in any kind.yaml, so we can append at the end.
444- cat <<EOF
445- kubeadmConfigPatches:
446- - |
447- kind: ClusterConfiguration
448- etcd:
449- local:
450- dataDir: /tmp/etcd
451- EOF
452432 ) >/tmp/kind.yaml
433+
434+ # Add or extend kubeadmConfigPatches with a ClusterConfiguration which causes etcd to use /tmp
435+ # (https://github.com/kubernetes-sigs/kind/issues/845#issuecomment-1261248420).
436+ # kind.yaml may or may not have a `kubeadmConfigPatches`, so we have to be
437+ # careful.
438+ if ! grep -q '^kubeadmConfigPatches:$' /tmp/kind.yaml; then
439+ echo "kubeadmConfigPatches:" >>/tmp/kind.yaml
440+ fi
441+ sed -i -e '/^kubeadmConfigPatches:$/a\' -e '- |\n kind: ClusterConfiguration\n etcd:\n local:\n dataDir: /tmp/etcd\n' /tmp/kind.yaml
442+
453443 cat /tmp/kind.yaml
454444 kind create cluster --retain --config /tmp/kind.yaml --image dra/node:latest
455445 atexit () {
@@ -566,19 +556,17 @@ presubmits:
566556
567557 # Additional features are not in kind.yaml, but they can be added at the end.
568558 for feature in ${features[@]}; do echo " ${feature}: true"; done
569-
570- # Append ClusterConfiguration which causes etcd to use /tmp
571- # (https://github.com/kubernetes-sigs/kind/issues/845#issuecomment-1261248420).
572- # There's no kubeadmConfigPatches in any kind.yaml, so we can append at the end.
573- cat <<EOF
574- kubeadmConfigPatches:
575- - |
576- kind: ClusterConfiguration
577- etcd:
578- local:
579- dataDir: /tmp/etcd
580- EOF
581559 ) >/tmp/kind.yaml
560+
561+ # Add or extend kubeadmConfigPatches with a ClusterConfiguration which causes etcd to use /tmp
562+ # (https://github.com/kubernetes-sigs/kind/issues/845#issuecomment-1261248420).
563+ # kind.yaml may or may not have a `kubeadmConfigPatches`, so we have to be
564+ # careful.
565+ if ! grep -q '^kubeadmConfigPatches:$' /tmp/kind.yaml; then
566+ echo "kubeadmConfigPatches:" >>/tmp/kind.yaml
567+ fi
568+ sed -i -e '/^kubeadmConfigPatches:$/a\' -e '- |\n kind: ClusterConfiguration\n etcd:\n local:\n dataDir: /tmp/etcd\n' /tmp/kind.yaml
569+
582570 cat /tmp/kind.yaml
583571 kind create cluster --retain --config /tmp/kind.yaml --image dra/node:latest
584572 atexit () {
0 commit comments