Skip to content

Commit 86d88d5

Browse files
committed
Use CLUSTER_NAME to preserve cluster status
1 parent be386cc commit 86d88d5

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

06_run_ocp.sh

+8-10
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
set -x
33
set -e
44

5-
source ocp_install_env.sh
65
source common.sh
7-
8-
export OS_CLOUD=openshift
6+
source ocp_install_env.sh
97

108
# check whether we already have a floating ip created
119
FLOATING_IP=$(openstack floating ip list --format value | awk -F ' ' 'NR==1 {print $2}')
@@ -20,21 +18,21 @@ grep -qxF "$FLOATING_IP $API_ADDRESS" /etc/hosts || echo "$FLOATING_IP $API_ADDR
2018
grep -qxF "$FLOATING_IP $CONSOLE_ADDRESS" /etc/hosts || echo "$FLOATING_IP $CONSOLE_ADDRESS" | sudo tee -a /etc/hosts
2119
grep -qxF "$FLOATING_IP $AUTH_ADDRESS" /etc/hosts || echo "$FLOATING_IP $AUTH_ADDRESS" | sudo tee -a /etc/hosts
2220

23-
if [ ! -d ocp ]; then
24-
mkdir -p ocp
21+
if [ ! -d $CLUSTER_NAME ]; then
22+
mkdir -p $CLUSTER_NAME
2523
fi
2624

27-
if [ ! -f ocp/install-config.yaml ]; then
25+
if [ ! -f $CLUSTER_NAME/install-config.yaml ]; then
2826
export CLUSTER_ID=$(uuidgen --random)
29-
cat > ocp/install-config.yaml << EOF
27+
cat > $CLUSTER_NAME/install-config.yaml << EOF
3028
apiVersion: v1beta3
3129
baseDomain: ${BASE_DOMAIN}
3230
clusterID: ${CLUSTER_ID}
3331
machines:
3432
- name: master
35-
replicas: 3
33+
replicas: 2
3634
- name: worker
37-
replicas: 3
35+
replicas: 1
3836
metadata:
3937
name: ${CLUSTER_NAME}
4038
networking:
@@ -59,4 +57,4 @@ EOF
5957
fi
6058

6159

62-
$GOPATH/src/github.com/openshift/installer/bin/openshift-install --log-level=debug ${1:-create} ${2:-cluster} --dir ocp
60+
$GOPATH/src/github.com/openshift/installer/bin/openshift-install --log-level=debug ${1:-create} ${2:-cluster} --dir $CLUSTER_NAME

expose_ocp_api.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ set -ex
1010
source ocp_install_env.sh
1111
source common.sh
1212

13-
LB_FLOATING_IP=$(openstack server show ostest-api -f value -c addresses | cut -d " " -f 2)
13+
LB_FLOATING_IP=$(openstack server show ${CLUSTER_NAME}-api -f value -c addresses | cut -d " " -f 2)
1414

1515
echo "Attempting to expose cluster's API on floating IP: ${LB_FLOATING_IP}" | lolcat
1616

1717
if ! grep -q ${LB_FLOATING_IP} /etc/hosts ; then
18-
(echo "${LB_FLOATING_IP} api.ostest.shiftstack.com" && grep -v "api.ostest.shiftstack.com" /etc/hosts) | sudo tee /etc/hosts
18+
(echo "${LB_FLOATING_IP} api.${CLUSTER_NAME}.shiftstack.com" && grep -v "api.${CLUSTER_NAME}.shiftstack.com" /etc/hosts) | sudo tee /etc/hosts
1919
fi

ocp_cleanup.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ set -e
44

55
source ocp_install_env.sh
66

7-
$GOPATH/src/github.com/openshift/installer/bin/openshift-install --log-level=debug --dir ocp destroy cluster
7+
$GOPATH/src/github.com/openshift/installer/bin/openshift-install --log-level=debug --dir $CLUSTER_NAME destroy cluster
88

99
# clean /etc/hosts
1010
grep -qxF "$API_ADDRESS" /etc/hosts || sudo sed -i "/$API_ADDRESS/d" /etc/hosts
1111
grep -qxF "$CONSOLE_ADDRESS" /etc/hosts || sudo sed -i "/$CONSOLE_ADDRESS/d" /etc/hosts
1212
grep -qxF "$AUTH_ADDRESS" /etc/hosts || sudo sed -i "/$AUTH_ADDRESS/d" /etc/hosts
1313

14-
rm -rf ocp/{auth,terraform.tfstate}
14+
rm -rf $CLUSTER_NAME/

ocp_install_env.sh

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
eval "$(go env)"
22

3-
export OS_CLOUD=openshift
3+
if [ -z "$OS_CLOUD" ]; then
4+
export OS_CLOUD=openshift
5+
fi
6+
7+
if [ -z "$CLUSTER_NAME" ]; then
8+
export CLUSTER_NAME=ostest
9+
fi
10+
411
export OPENSHIFT_INSTALL_DATA="$GOPATH/src/github.com/openshift/installer/data/data"
512
export OPENSTACK_REGION=regionOne
613
export OPENSTACK_IMAGE=rhcos
714
export OPENSTACK_FLAVOR=m1.medium
815
export BASE_DOMAIN=shiftstack.com
9-
export CLUSTER_NAME=ostest
1016
export OPENSTACK_EXTERNAL_NETWORK=public
1117
export PULL_SECRET='{"auths": { "quay.io": { "auth": "Y29yZW9zK3RlYzJfaWZidWdsa2VndmF0aXJyemlqZGMybnJ5ZzpWRVM0SVA0TjdSTjNROUUwMFA1Rk9NMjdSQUZNM1lIRjRYSzQ2UlJBTTFZQVdZWTdLOUFIQlM1OVBQVjhEVlla", "email": "" }}}'
1218
export SSH_PUB_KEY="`cat $HOME/.ssh/id_rsa.pub`"
1319

1420
export API_ADDRESS="api.${CLUSTER_NAME}.shiftstack.com"
15-
export CONSOLE_ADDRESS="console-openshift-console.apps.shiftstack.com"
16-
export AUTH_ADDRESS="openshift-authentication-openshift-authentication.apps.ostest.shiftstack.com"
21+
export CONSOLE_ADDRESS="console-openshift-console.apps.${CLUSTER_NAME}.shiftstack.com"
22+
export AUTH_ADDRESS="openshift-authentication-openshift-authentication.apps.${CLUSTER_NAME}.shiftstack.com"
1723

1824
# Not used by the installer. Used by s.sh.
1925
export SSH_PRIV_KEY="$HOME/.ssh/id_rsa"

0 commit comments

Comments
 (0)