-
Notifications
You must be signed in to change notification settings - Fork 1
/
create-cluster.aws-default.sh
executable file
·51 lines (41 loc) · 1.34 KB
/
create-cluster.aws-default.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
51
#!/bin/bash
set -x
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
BIN_DIR="${DIR}/bin"
PATH="${BIN_DIR}:${PATH}"
export PREFIX="k7r"
export ENV_ID="$(head -c 4 /etc/machine-id)"
export TODAY="$(date +%d%b | tr '[:upper:]' '[:lower:]')"
export CLUSTER_NAME="$PREFIX$TODAY$ENV_ID"
export BASE_DOMAIN="lab-scaling.devcluster.openshift.com"
echo "Creating cluster $CLUSTER_NAME.$BASE_DOMAIN"
export AWS_REGION="us-east-1"
export SSH_KEY=$(cat ~/.ssh/id_rsa.pub)
export INSTANCE_TYPE=${INSTANCE_TYPE:-"m6a.2xlarge"}
echo "Checking AWS $AWS_REGION ($INSTANCE_TYPE)"
aws sts get-caller-identity
echo "Generating install-config"
envsubst < "install-config.aws-default.env.yaml" > "install-config.yaml"
DATE_STAMP=$(date +%Y%m%d%H%M%S)
cp "install-config.yaml" ".install-config.${DATE_STAMP}.yaml"
echo "Creating cluster..."
sleep 5
openshift-install create cluster --log-level=debug
if [ $? -ne 0 ]; then
echo "Create cluster failed, exiting."
exit 1
fi
# openshift-install wait-for install-complete --log-level=debug
mkdir -p "$HOME/.kube"
if [ -f "$HOME/.kube/config" ]; then
mv $HOME/.kube/config ~/.kube/config.bak.$(date +%Y%m%d%H%M%S)
fi
cp auth/kubeconfig ~/.kube/config
if kubectl cluster-info; then
echo "Kubernetes API seems OK"
else
echo "Kubernetes API is not responding"
exit 1
fi
echo "create cluster done"
exit 0