From be425bfa7a8c128374e6062a8456ae0215369b63 Mon Sep 17 00:00:00 2001 From: victor Date: Tue, 22 Oct 2024 13:06:53 +0200 Subject: [PATCH] Scripts for install dependecies are added --- base_scripts/install_kind.sh | 7 +++ base_scripts/install_kubectl.sh | 2 + init_cluster..sh | 88 +++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100755 base_scripts/install_kind.sh create mode 100755 base_scripts/install_kubectl.sh create mode 100755 init_cluster..sh diff --git a/base_scripts/install_kind.sh b/base_scripts/install_kind.sh new file mode 100755 index 0000000..03d99eb --- /dev/null +++ b/base_scripts/install_kind.sh @@ -0,0 +1,7 @@ +#!/bin/bash + # For AMD64 / x86_64 +[ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.24.0/kind-linux-amd64 +# For ARM64 +[ $(uname -m) = aarch64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.24.0/kind-linux-arm64 +chmod +x ./kind +sudo mv ./kind /usr/local/bin/kind \ No newline at end of file diff --git a/base_scripts/install_kubectl.sh b/base_scripts/install_kubectl.sh new file mode 100755 index 0000000..155a4f7 --- /dev/null +++ b/base_scripts/install_kubectl.sh @@ -0,0 +1,2 @@ +#!/bin/bash +curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" \ No newline at end of file diff --git a/init_cluster..sh b/init_cluster..sh new file mode 100755 index 0000000..42498ff --- /dev/null +++ b/init_cluster..sh @@ -0,0 +1,88 @@ +#!/bin/bash +SCRIPTS_DIR="base_scripts" +set -o errexit +#Install Kind +${SCRIPTS_DIR}/install_kind.sh +#Install kubectl +${SCRIPTS_DIR}/install_kubectl.sh + +# 1. Create registry container unless it already exists +reg_name='kind-registry' +reg_port='5001' +if [ "$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" != 'true' ]; then + docker run \ + -d --restart=always -p "127.0.0.1:${reg_port}:5000" --network bridge --name "${reg_name}" \ + registry:2 +fi + +# 2. Create kind cluster with containerd registry config dir enabled +# TODO: kind will eventually enable this by default and this patch will +# be unnecessary. +# +# See: +# https://github.com/kubernetes-sigs/kind/issues/2875 +# https://github.com/containerd/containerd/blob/main/docs/cri/config.md#registry-configuration +# See: https://github.com/containerd/containerd/blob/main/docs/hosts.md +kind create cluster --config manifests/kind-cluster-config.yaml +# cat <