-
Notifications
You must be signed in to change notification settings - Fork 1
/
clusters.sh
executable file
·50 lines (45 loc) · 1.45 KB
/
clusters.sh
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
#!/bin/bash
#==========================================================
#
# FILE: clusters.sh
# DESCRIPTION: Creates test clusters for demonstration purposes
# AUTHOR: Lindsey Tulloch , ltulloch@redhat.com
# VERSION: 1.0
# CREATED: 2018-01-26 09:31:31 AM EST
#============================================================
CURRENT_CONTEXT="$(kubectl config current-context)"
SERVER="$(kubectl config view --flatten -o json | jq -r --arg CURRENT_CONTEXT "$CURRENT_CONTEXT" '.clusters[] | select(.name==$CURRENT_CONTEXT)| .cluster.server')"
$HOME/crinit aggregated init cr-test --host-cluster-context=${CURRENT_CONTEXT}
kubectl apply -f - --context ${CURRENT_CONTEXT} --validate=false <<EOF
kind: Cluster
apiVersion: clusterregistry.k8s.io/v1alpha1
metadata:
name: test-cluster1
spec:
kubernetesApiEndpoints:
serverEndpoints:
- clientCidr: "0.0.0.0/0"
serverAddress: "${SERVER}"
EOF
kubectl apply -f - --context ${CURRENT_CONTEXT} --validate=false <<EOF
kind: Cluster
apiVersion: clusterregistry.k8s.io/v1alpha1
metadata:
name: test-cluster2
spec:
kubernetesApiEndpoints:
serverEndpoints:
- clientCidr: "0.0.0.0/0"
serverAddress: "${SERVER}"
EOF
kubectl apply -f - --context ${CURRENT_CONTEXT} --validate=false <<EOF
kind: Cluster
apiVersion: clusterregistry.k8s.io/v1alpha1
metadata:
name: test-cluster3
spec:
kubernetesApiEndpoints:
serverEndpoints:
- clientCidr: "0.0.0.0/0"
serverAddress: "${SERVER}"
EOF