-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathinstall_KinD_create_KinD_cluster_install_kustomize.sh
More file actions
executable file
·121 lines (103 loc) · 4.04 KB
/
install_KinD_create_KinD_cluster_install_kustomize.sh
File metadata and controls
executable file
·121 lines (103 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
set -euxo pipefail
KIND_VERSION="v0.31.0"
KIND_NODE_IMAGE="kindest/node:v1.35.0@sha256:452d707d4862f52530247495d180205e029056831160e22870e37e3f6c1ac31f"
KUSTOMIZE_VERSION="v5.8.1"
USER_BINARY_DIRECTORY="$HOME/.local/bin"
if [[ "${GITHUB_ACTIONS:-false}" == "true" ]]; then
USER_BINARY_DIRECTORY="/tmp/usr/local/bin"
fi
mkdir -p "${USER_BINARY_DIRECTORY}"
export PATH="${USER_BINARY_DIRECTORY}:${PATH}"
echo "Install KinD..."
# https://github.com/nektos/act
# This conditional helps running GitHub Workflows through
if [[ "${GITHUB_ACTIONS:-false}" == "true" ]]; then
echo "Running in GitHub Actions: Optimizing environment..."
sudo swapoff -a
if [ -e /swapfile ]; then
sudo rm -f /swapfile
sudo mkdir -p /tmp/etcd
sudo mount -t tmpfs tmpfs /tmp/etcd
fi
fi
{
curl -Lo ./kind-linux-amd64 https://kind.sigs.k8s.io/dl/$KIND_VERSION/kind-linux-amd64
curl -Lo ./kind-linux-amd64.sha256sum https://kind.sigs.k8s.io/dl/$KIND_VERSION/kind-linux-amd64.sha256sum
if ! sha256sum --check kind-linux-amd64.sha256sum; then
echo "Failed to verify KinD checksums"
exit 1
fi
chmod +x ./kind-linux-amd64
mv kind-linux-amd64 "${USER_BINARY_DIRECTORY}/kind"
} || { echo "Failed to install KinD"; exit 1; }
echo "Creating KinD cluster ..."
echo "
apiVersion: kind.x-k8s.io/v1alpha4
kind: Cluster
# This is needed in order to support projected volumes with service account tokens.
# See: https://kubernetes.slack.com/archives/CEKK1KTN2/p1600268272383600
kubeadmConfigPatches:
- |
apiVersion: kubeadm.k8s.io/v1beta3
kind: ClusterConfiguration
metadata:
name: config
apiServer:
extraArgs:
\"service-account-issuer\": \"https://kubernetes.default.svc\"
\"service-account-signing-key-file\": \"/etc/kubernetes/pki/sa.key\"
nodes:
- role: control-plane
image: ${KIND_NODE_IMAGE}
- role: worker
image: ${KIND_NODE_IMAGE}
- role: worker
image: ${KIND_NODE_IMAGE}
" | kind create cluster --name kubeflow --config - --wait 120s
echo "Install kubectl ..."
{
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x ./kubectl
mv kubectl "${USER_BINARY_DIRECTORY}/kubectl"
} || { echo "Failed to install kubectl"; exit 1; }
kubectl cluster-info
echo "Install Kustomize ..."
{
KUSTOMIZE_ASSET="kustomize_${KUSTOMIZE_VERSION}_linux_amd64.tar.gz"
curl --fail --show-error --silent --location --remote-name "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F${KUSTOMIZE_VERSION}/${KUSTOMIZE_ASSET}"
curl --fail --show-error --silent --location "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F${KUSTOMIZE_VERSION}/checksums.txt" | grep " ${KUSTOMIZE_ASSET}$" > checksums.txt
if [ "$(wc -l < checksums.txt)" -ne 1 ]; then
echo "Failed to verify Kustomize checksums: expected exactly one checksum entry for ${KUSTOMIZE_ASSET}"
exit 1
fi
if ! sha256sum --check checksums.txt; then
echo "Failed to verify Kustomize checksums"
exit 1
fi
tar -xzvf "${KUSTOMIZE_ASSET}"
chmod a+x kustomize
mv kustomize "${USER_BINARY_DIRECTORY}/kustomize"
} || { echo "Failed to install Kustomize"; exit 1; }
# Free disk space in GitHub Actions to reduce "no space left on device" failures.
if [[ "${GITHUB_ACTIONS:-false}" == "true" ]]; then
echo "=== Disk usage before cleanup ==="
df -h
echo "=== Freeing up disk space ==="
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/share/boost
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/local/.ghcup
sudo rm -rf /usr/share/swift
sudo rm -rf /opt/hostedtoolcache/CodeQL || true
sudo rm -rf /opt/hostedtoolcache/Java_* || true
sudo rm -rf /opt/hostedtoolcache/Ruby || true
sudo rm -rf /opt/hostedtoolcache/PyPy || true
sudo rm -rf /opt/hostedtoolcache/boost || true
sudo apt-get autoclean
docker system prune -af --volumes
docker image prune -af
echo "=== Final disk usage ==="
df -h
fi