2 # ============LICENSE_START=======================================================
3 # Copyright (C) 2023 Nordix Foundation.
4 # ================================================================================
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # SPDX-License-Identifier: Apache-2.0
18 # ============LICENSE_END=========================================================
20 # Script copied from https://hub.docker.com/r/devopps/kind-cluster-buster
26 # Startup Docker daemon and wait for it to be ready.
27 echo "Running entrypoint-original.sh .."
28 /entrypoint-original.sh bash -c "touch /dockerd-ready && sleep infinity" &
29 while [ ! -f /dockerd-ready ]; do sleep 10; done
31 echo "Setting up KIND cluster"
33 # Startup a KIND cluster.
34 API_SERVER_ADDRESS=${API_SERVER_ADDRESS:-$(hostname -i)}
35 echo "hostname: ${API_SERVER_ADDRESS}"
36 sed -ri "s/^(\s*)(apiServerAddress\s*:\s*apiServerAddress\s*$)/\1apiServerAddress: ${API_SERVER_ADDRESS}/" kind-config.yaml
38 CERT_SANS=(${CERT_SANS:-""})
39 CERT_SANS+=(${API_SERVER_ADDRESS})
40 CERT_SANS+=($(hostname -i))
41 CERT_SANS+=(localhost)
42 CERT_SANS+=(127.0.0.1)
44 for node in $(kubectl get nodes -o wide --no-headers | awk '{print $6}'); do
49 UNIQUE_CERT_SANS=($(echo "${CERT_SANS[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
51 for hostname in "${UNIQUE_CERT_SANS[@]}"; do
52 cat <<EOF >> kind-config.yaml
53 - group: kubeadm.k8s.io
55 kind: ClusterConfiguration
58 path: /apiServer/certSANs/-
63 kind create cluster --config=kind-config.yaml --image=${KIND_NODE_IMAGE-"devopps/kind-node:v1.21.1"} --wait=900s
68 done < "$HOME/.kube/config"
70 CONFIG_ADDRESS=$HOME/.kube/config
72 echo "Finished Setting up KIND cluster $CONFIG_ADDRESS"