Skip to content

Commit 9193a53

Browse files
author
Vitaliy Guschin
committed
Update setup scripts.
Signed-off-by: Vitaliy Guschin <[email protected]>
1 parent 84206c4 commit 9193a53

File tree

163 files changed

+26495
-124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+26495
-124
lines changed
File renamed without changes.
File renamed without changes.

cluster-setup/aws-create-1.sh renamed to cluster-setup/aws/aws-create-1.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ parent_path=$( cd "$(dirname "$0")" ; pwd -P ) || exit
44

55
source "$parent_path"/private/aws-login.sh || exit
66

7-
kube_config_dir=/tmp/kind-configs
7+
kube_config_dir=/tmp/kube-configs
88
mkdir -p "$kube_config_dir" || exit
99

1010
aws_kubeconfig="$kube_config_dir"/kubeconfig-aws-1

cluster-setup/aws-create-2.sh renamed to cluster-setup/aws/aws-create-2.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ parent_path=$( cd "$(dirname "$0")" ; pwd -P ) || exit
44

55
source "$parent_path"/private/aws-login.sh || exit
66

7-
kube_config_dir=/tmp/kind-configs
7+
kube_config_dir=/tmp/kube-configs
88
mkdir -p "$kube_config_dir" || exit
99

1010
aws_kubeconfig="$kube_config_dir"/kubeconfig-aws-2
File renamed without changes.
File renamed without changes.
File renamed without changes.

cluster-setup/env-aws-aws.sh renamed to cluster-setup/aws/env-aws-aws.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env false "This script should be sourced in a shell, not executed directly"
1+
#!/usr/bin/env bash
22

33
# ===== get script folder =====
44
shellname=$(ps -cp "$$" -o command="")
@@ -16,12 +16,13 @@ parent_path=$( cd "$(dirname "$script_path")" && pwd -P ) || return || exit
1616
kube_config_dir=/tmp/kube-configs
1717

1818
echo '#!/usr/bin/env false "This script should be sourced in a shell, not executed directly"
19+
unset USE_KIND_NODE
1920
unset CLUSTER1_CIDR
2021
unset CLUSTER2_CIDR
2122
export KUBECONFIG1="'"$kube_config_dir"'"/kubeconfig-aws-1
2223
export KUBECONFIG2="'"$kube_config_dir"'"/kubeconfig-aws-2
2324
export K8S_ENV_NAME=aws_aws
24-
source "$1"/aws-login.sh
25+
source "$parent_path"/private/aws-login.sh
2526
' > "$parent_path"/private/current-env.sh
2627
chmod +x "$parent_path"/private/current-env.sh
2728

File renamed without changes.

cluster-setup/aws/readme.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
2+
# AWS cluster setup
3+
4+
This folder contains scripts to set up AWS clusters for testing.
5+
6+
# Authentication
7+
8+
Create file `cluster-setup/aws/private/aws-login.sh` with the following content:
9+
10+
```bash
11+
#!/usr/bin/env false
12+
13+
export AWS_ACCESS_KEY_ID=
14+
export AWS_SECRET_ACCESS_KEY=
15+
```
16+
17+
Put your values into variables.
18+
19+
No additional actions are needed.
20+
21+
# Install CLI
22+
23+
Run `aws-install-` script to install CLI
24+
25+
# Prepare clusters
26+
27+
After you set up required authentication you can just use `aws-create` scripts:
28+
29+
```bash
30+
./cluster-setup/aws/aws-create-1.sh
31+
./cluster-setup/aws/aws-create-2.sh
32+
```
33+
34+
List clusters:
35+
36+
```bash
37+
./cluster-setup/aws/aws-list.sh
38+
```
39+
40+
Setup test environment
41+
42+
Run `env-aws-aws.sh` for initial setup, to create kubeconfig files.
43+
44+
Taint nodes:
45+
46+
```bash
47+
k1 taint node -l node-role.kubernetes.io/control-plane node-role.kubernetes.io/master:NoSchedule
48+
k2 taint node -l node-role.kubernetes.io/control-plane node-role.kubernetes.io/master:NoSchedule
49+
```
50+
51+
Metallb setup:
52+
53+
```bash
54+
k1 create ns metallb-system
55+
k1 apply -f https://raw.githubusercontent.com/metallb/metallb/v0.12.1/manifests/metallb.yaml
56+
k1 -n metallb-system create cm config
57+
k2 create ns metallb-system
58+
k2 apply -f https://raw.githubusercontent.com/metallb/metallb/v0.12.1/manifests/metallb.yaml
59+
k2 -n metallb-system create cm config
60+
```
61+
62+
# Execute tests
63+
64+
```bash
65+
./scripts/test_suite.sh
66+
```
67+
68+
# Cleanup
69+
70+
```bash
71+
./cluster-setup/aws/aws-delete-1.sh
72+
./cluster-setup/aws/aws-delete-2.sh
73+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
# ===== get script folder =====
4+
shellname=$(ps -cp "$$" -o command="")
5+
if [ "$shellname" = "bash" ]; then
6+
script_path="${BASH_SOURCE[0]}"
7+
elif [ "$shellname" = "zsh" ]; then
8+
script_path="${(%):-%x}"
9+
else
10+
echo "unsupported shell $shellname"
11+
return 1 || exit 1
12+
fi
13+
parent_path=$( cd "$(dirname "$script_path")" && pwd -P ) || return || exit
14+
# ===== ===== =====
15+
16+
kind get kubeconfig --name kind-1 > "$parent_path"/kubeconfig/config1
17+
kind get kubeconfig --name kind-2 > "$parent_path"/kubeconfig/config2
18+
export KUBECONFIG1="$parent_path"/kubeconfig/config1
19+
export KUBECONFIG2="$parent_path"/kubeconfig/config2
20+
export CLUSTER1_CIDR=172.21.0.0/24
21+
export CLUSTER2_CIDR=172.21.1.0/24
22+
export K8S_ENV_NAME=kind_kind
23+
export USE_KIND_NODE=true
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
echo "
4+
kind: Cluster
5+
apiVersion: kind.x-k8s.io/v1alpha4
6+
nodes:
7+
- role: control-plane
8+
- role: worker" | kind create cluster --config - --name kind-1
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
echo "
4+
kind: Cluster
5+
apiVersion: kind.x-k8s.io/v1alpha4
6+
nodes:
7+
- role: control-plane
8+
- role: worker" | kind create cluster --config - --name kind-2

cluster-setup/kind-local/readme.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
# Kind cluster setup for local testing
3+
4+
Create clusters:
5+
6+
```bash
7+
./cluster-setup/kind-local/kind-create-1.sh
8+
./cluster-setup/kind-local/kind-create-2.sh
9+
```
10+
11+
Setup test environment:
12+
13+
```bash
14+
source ./cluster-setup/kind-local/env-kind-kind.sh
15+
```
16+
17+
Taint nodes:
18+
19+
```bash
20+
k1 taint node -l node-role.kubernetes.io/control-plane node-role.kubernetes.io/master:NoSchedule
21+
k2 taint node -l node-role.kubernetes.io/control-plane node-role.kubernetes.io/master:NoSchedule
22+
```
23+
24+
# Execute tests
25+
26+
```bash
27+
./scripts/test_suite.sh
28+
```
29+
30+
# Cleanup
31+
32+
```bash
33+
kind delete cluster --name kind-1
34+
kind delete cluster --name kind-2
35+
```

cluster-setup/clusterctl-install-linux.sh renamed to cluster-setup/packet/clusterctl-install-linux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
function install_clusterctl() {
44
clusterctl version && return
55

6-
curl -L https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.5.2/clusterctl-linux-amd64 -o clusterctl || exit
6+
curl -L https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.6.2/clusterctl-linux-amd64 -o clusterctl || exit
77
sudo install -o root -g root -m 0755 clusterctl /usr/local/bin/clusterctl
88
clusterctl version || exit
99
}

cluster-setup/clusterctl-install-macos.sh renamed to cluster-setup/packet/clusterctl-install-macos.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
function install_clusterctl() {
44
clusterctl version && return
55

6-
curl -L https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.5.2/clusterctl-darwin-amd64 -o clusterctl || exit
6+
curl -L https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.6.2/clusterctl-darwin-amd64 -o clusterctl || exit
77
chmod +x ./clusterctl || exit
88
sudo mv ./clusterctl /usr/local/bin/clusterctl || exit
99
clusterctl version || exit
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env false "This script should be sourced in a shell, not executed directly"
2+
3+
alias "k1=kubectl --kubeconfig=$KUBECONFIG1"
4+
alias "k2=kubectl --kubeconfig=$KUBECONFIG2"
5+
6+
shellname=$(ps -cp "$$" -o command="")
7+
if [ "$shellname" = "bash" ]; then
8+
echo "set autocompletion for bash"
9+
source <(kubectl completion bash) || return || exit
10+
complete -o default -F __start_kubectl k1 || return || exit
11+
complete -o default -F __start_kubectl k2 || return || exit
12+
elif [ "$shellname" = "zsh" ]; then
13+
echo "set autocompletion for zsh"
14+
source <(kubectl completion zsh) || return || exit
15+
else
16+
echo "unsupported shell $shellname"
17+
return 1
18+
fi

cluster-setup/env-packet.sh renamed to cluster-setup/packet/env-packet.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env false "This script should be sourced in a shell, not executed directly"
1+
#!/usr/bin/env bash
22

33
# ===== get script folder =====
44
shellname=$(ps -cp "$$" -o command="")
@@ -26,6 +26,7 @@ skip_fetch=${3:-}
2626
kube_config_path=$parent_path/private/kubeconfig/packet_$remote_cluster_index.yaml
2727

2828
echo '#!/usr/bin/env false "This script should be sourced in a shell, not executed directly"
29+
unset USE_KIND_NODE
2930
unset CLUSTER'$local_cluster_index'_CIDR
3031
export KUBECONFIG'$local_cluster_index'="'"$kube_config_path"'"
3132
export K8S_ENV_NAME'$local_cluster_index'=packet

cluster-setup/packet/env-restore.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env false "This script should be sourced in a shell, not executed directly"
2+
3+
# ===== get script folder =====
4+
shellname=$(ps -cp "$$" -o command="")
5+
if [ "$shellname" = "bash" ]; then
6+
script_path="${BASH_SOURCE[0]}"
7+
elif [ "$shellname" = "zsh" ]; then
8+
script_path="${(%):-%x}"
9+
else
10+
echo "unsupported shell $shellname"
11+
return 1 || exit 1
12+
fi
13+
parent_path=$( cd "$(dirname "$script_path")" && pwd -P ) || return || exit
14+
# ===== ===== =====
15+
16+
split_configs=${1:-}
17+
18+
[ "$split_configs" = 'split' ] || source "$parent_path"/private/current-env.sh "$parent_path"/private
19+
[ ! "$split_configs" = 'split' ] || source "$parent_path"/private/current-env-1.sh "$parent_path"/private
20+
[ ! "$split_configs" = 'split' ] || source "$parent_path"/private/current-env-2.sh "$parent_path"/private
21+
source "$parent_path"/env--autocomplete.sh

cluster-setup/packet/kind-create.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
echo "
4+
kind: Cluster
5+
apiVersion: kind.x-k8s.io/v1alpha4
6+
nodes:
7+
- role: control-plane
8+
- role: worker" | kind create cluster --config - --name kind-management

cluster-setup/packet-create-2.sh renamed to cluster-setup/packet/packet-create-2.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ clusterctl generate cluster msm-perf-test-2 \
3030
| sed 's/"eipTag"/"metro": "'"$METRO"'", "loadbalancer": "metallb:\/\/\/", "eipTag"/' \
3131
> "$parent_path"/private/packet-cluster-2.yaml || exit
3232

33-
kubectl apply -f "$parent_path"/private/packet-cluster-1.yaml
33+
kubectl apply -f "$parent_path"/private/packet-cluster-2.yaml

cluster-setup/packet-init-env.sh renamed to cluster-setup/packet/packet-init-env.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env false "This script should be sourced in a shell, not executed directly"
1+
#!/usr/bin/env bash
22

33
# ===== get script folder =====
44
shellname=$(ps -cp "$$" -o command="")
@@ -24,4 +24,4 @@ export KUBECONFIG="$config"
2424

2525
. "$parent_path"/private/packet-login.sh || return 1
2626

27-
clusterctl init --core cluster-api:v1.5.2 --infrastructure packet:v0.7.2
27+
clusterctl init --infrastructure packet:v0.8.0
File renamed without changes.
File renamed without changes.
File renamed without changes.

cluster-setup/packet/readme.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
2+
# Equinix Metal cluster setup
3+
4+
This folder contains scripts to set up Equinix metal clusters for testing.
5+
6+
# Authentication
7+
8+
Create file `./cluster-setup/packet/private/packet-login.sh` with the following content:
9+
10+
```bash
11+
#!/usr/bin/env false
12+
13+
export PROJECT_ID=
14+
# METAL_AUTH_TOKEN and PACKET_API_KEY should have the same value
15+
# METAL_AUTH_TOKEN is for metal cli
16+
# PACKET_API_KEY is for clusterctl
17+
export METAL_AUTH_TOKEN=
18+
export PACKET_API_KEY=
19+
# usually METRO=da
20+
export METRO=
21+
# your public key (get it using 'cat ~/.ssh/id_rsa.pub' or generate another one), like SSH_KEY="ssh-rsa AAAAC3NzaC1lZDI1NTE5AAAAIjAqaYj9nmCkgr4PdK username@computer"
22+
export SSH_KEY=
23+
```
24+
25+
# Install CLI
26+
27+
```bash
28+
./cluster-setup/packet/clusterctl-install-macos.sh
29+
```
30+
31+
# Prepare clusters
32+
33+
Initialize a Kind cluster for management
34+
35+
```bash
36+
./cluster-setup/packet/kind-create.sh
37+
kind get kubeconfig --name kind-management > /tmp/kubeconfigs/config-management
38+
source ./cluster-setup/packet/packet-init-env.sh /tmp/kubeconfigs/config-management
39+
```
40+
41+
Generate workload clusters
42+
43+
```bash
44+
source ./cluster-setup/packet/packet-create-1.sh
45+
source ./cluster-setup/packet/packet-create-2.sh
46+
```
47+
48+
List clusters
49+
50+
```bash
51+
./cluster-setup/packet/packet-list.sh
52+
clusterctl describe cluster msm-perf-test-1
53+
clusterctl describe cluster msm-perf-test-2
54+
```
55+
56+
Setup test environment
57+
58+
```bash
59+
source ./cluster-setup/packet/env-packet.sh 1 1
60+
source ./cluster-setup/packet/env-packet.sh 2 2
61+
```
62+
63+
When using a pre-configured packet cluster, place kubeconfig files here:
64+
65+
- `./cluster-setup/packet/private/kubeconfig/packet_1.yaml`
66+
- `./cluster-setup/packet/private/kubeconfig/packet_2.yaml`
67+
68+
Taint nodes:
69+
70+
```bash
71+
k1 taint node -l node-role.kubernetes.io/control-plane node-role.kubernetes.io/master:NoSchedule
72+
k2 taint node -l node-role.kubernetes.io/control-plane node-role.kubernetes.io/master:NoSchedule
73+
```
74+
75+
Install CNI
76+
77+
```bash
78+
k1 apply -k https://github.com/networkservicemesh/integration-k8s-packet/scripts/defaultCNI
79+
k2 apply -k https://github.com/networkservicemesh/integration-k8s-packet/scripts/defaultCNI
80+
```
81+
82+
Metallb setup:
83+
84+
```bash
85+
./cluster-setup/packet/packet-lb-1.sh
86+
./cluster-setup/packet/packet-lb-2.sh
87+
```
88+
89+
# Execute tests
90+
91+
```bash
92+
./scripts/test_suite.sh
93+
```
94+
95+
# Cleanup
96+
97+
```bash
98+
./cluster-setup/packet/packet-delete-1.sh
99+
./cluster-setup/packet/packet-delete-2.sh
100+
kind delete cluster --name kind-management
101+
```

0 commit comments

Comments
 (0)