Skip to content

Commit 7316871

Browse files
committed
break out create/delete to separate scripts
1 parent c50f32e commit 7316871

File tree

3 files changed

+117
-45
lines changed

3 files changed

+117
-45
lines changed

ci/create-ocp-cluster.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
3+
mkdir -p installer
4+
5+
RELEASE_URL="https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest"
6+
RELEASE_IMAGE=$(curl -s "${RELEASE_URL}/release.txt" | grep 'Pull From: quay.io' | awk -F ' ' '{print $3}')
7+
8+
if [ -z "${OCM_TOKEN+x}" ]; then
9+
echo "Assuming the OCM token should be read from Prow";
10+
OCM_TOKEN=$(cat /usr/local/osde2e-credentials/ocm-refresh-token)
11+
fi
12+
13+
if [ -z "${AWS_ACCESS_KEY_ID+x}" ]; then
14+
echo "Assuming the AWS Access token should be read from Prow";
15+
AWS_ACCESS_KEY_ID=$(cat /usr/local/osde2e-credentials/aws-access-key-id)
16+
fi
17+
18+
if [ -z "${AWS_SECRET_ACCESS_KEY+x}" ]; then
19+
echo "Assuming the AWS Secret token should be read from Prow";
20+
AWS_SECRET_ACCESS_KEY=$(cat /usr/local/osde2e-credentials/aws-secret-access-key)
21+
fi
22+
23+
if [ -z "${PULL_SECRET_FILE+x}" ]; then
24+
echo "Assuming the Pull Secret should be read from Prow";
25+
PULL_SECRET_FILE=/usr/local/osde2e-credentials/stage-ocm-pull-secret
26+
fi
27+
28+
if [ -z "${INSTALLER_CONFIG+x}" ]; then
29+
echo "Assuming the Installer Config should be read from Prow";
30+
INSTALLER_CONFIG=/usr/local/osde2e-credentials/stage-installer-config
31+
fi
32+
33+
cp "${INSTALLER_CONFIG}" ./installer/install-config.yaml
34+
35+
curl -s "${RELEASE_URL}/openshift-client-linux.tar.gz" | tar zxvf - oc
36+
37+
chmod +x oc
38+
39+
./oc adm release extract --registry-config "${PULL_SECRET_FILE}" --command=openshift-install --to "$(pwd)/" "${RELEASE_IMAGE}"
40+
41+
chmod +x openshift-install
42+
43+
./openshift-install create cluster --dir=./installer/ --log-level info
44+
45+
cp "${INSTALLER_CONFIG}" "${SHARED_DIR}"
46+
cp ./installer/metadata.json "${SHARED_DIR}"
47+
cp ./installer/auth/kubeconfig "${SHARED_DIR}"

ci/destroy-ocp-cluster.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
RELEASE_URL="https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest"
4+
RELEASE_IMAGE=$(curl -s "${RELEASE_URL}/release.txt" | grep 'Pull From: quay.io' | awk -F ' ' '{print $3}')
5+
6+
if [ -z "${AWS_ACCESS_KEY_ID+x}" ]; then
7+
echo "Assuming the AWS Access token should be read from Prow";
8+
AWS_ACCESS_KEY_ID=$(cat /usr/local/osde2e-credentials/aws-access-key-id)
9+
fi
10+
11+
if [ -z "${AWS_SECRET_ACCESS_KEY+x}" ]; then
12+
echo "Assuming the AWS Secret token should be read from Prow";
13+
AWS_SECRET_ACCESS_KEY=$(cat /usr/local/osde2e-credentials/aws-secret-access-key)
14+
fi
15+
16+
if [ -z "${PULL_SECRET_FILE+x}" ]; then
17+
echo "Assuming the Pull Secret should be read from Prow";
18+
PULL_SECRET_FILE=/usr/local/osde2e-credentials/stage-ocm-pull-secret
19+
fi
20+
21+
export KUBECONFIG=${SHARED_DIR}/installer/auth/kubeconfig
22+
23+
curl -s "${RELEASE_URL}/openshift-client-linux.tar.gz" | tar zxvf - oc
24+
25+
chmod +x oc
26+
27+
./oc adm release extract --registry-config "${PULL_SECRET_FILE}" --command=openshift-install --to "$(pwd)/" "${RELEASE_IMAGE}"
28+
29+
chmod +x openshift-install
30+
31+
./openshift-install destroy cluster --dir="${SHARED_DIR}" --log-level info

ci/prow-ocm-adoption.sh

Lines changed: 39 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,71 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
set -o pipefail
44

5-
mkdir -p installer
5+
OCM_URL="https://api.stage.openshift.com"
66

7-
export VERSION=latest
8-
export RELEASE_IMAGE=$(curl -s https://mirror.openshift.com/pub/openshift-v4/clients/ocp/$VERSION/release.txt | grep 'Pull From: quay.io' | awk -F ' ' '{print $3}')
9-
10-
export cmd=openshift-install
11-
export pullsecret_file=~/Downloads/crc-pull-secret.txt
12-
export extract_dir=$(pwd)
13-
14-
if [ -z "$OCM_TOKEN" ]; then
15-
echo "Assuming the token should be read from Prow";
16-
export OCM_TOKEN=$(cat /usr/local/osde2e-credentials/ocm-refresh-token)
7+
if [ -z "${OCM_TOKEN+x}" ]; then
8+
echo "Assuming the OCM token should be read from Prow";
9+
OCM_TOKEN=$(cat /usr/local/osde2e-credentials/ocm-refresh-token)
1710
fi
1811

19-
if [ -z "AWS_ACCESS_KEY_ID" ]; then
20-
export AWS_ACCESS_KEY_ID=$(cat /usr/local/osde2e-credentials/aws-access-key-id)
12+
if [ -z "${AWS_ACCESS_KEY_ID+x}" ]; then
13+
echo "Assuming the AWS Access token should be read from Prow";
14+
AWS_ACCESS_KEY_ID=$(cat /usr/local/osde2e-credentials/aws-access-key-id)
2115
fi
2216

23-
if [ -z "AWS_SECRET_ACCESS_KEY" ]; then
24-
export AWS_SECRET_ACCESS_KEY=$(cat /usr/local/osde2e-credentials/aws-secret-access-key)
17+
if [ -z "${AWS_SECRET_ACCESS_KEY+x}" ]; then
18+
echo "Assuming the AWS Secret token should be read from Prow";
19+
AWS_SECRET_ACCESS_KEY=$(cat /usr/local/osde2e-credentials/aws-secret-access-key)
2520
fi
2621

22+
if [ -z "${PULL_SECRET_FILE+x}" ]; then
23+
echo "Assuming the Pull Secret should be read from Prow";
24+
PULL_SECRET_FILE=/usr/local/osde2e-credentials/stage-ocm-pull-secret
25+
fi
2726

28-
cp /usr/local/osde2e-credentials/stage-installer-config ./installer/installer-config.yaml
29-
30-
31-
32-
curl -s https://mirror.openshift.com/pub/openshift-v4/clients/ocp/$VERSION/openshift-client-linux.tar.gz | tar zxvf - oc
33-
34-
./oc adm release extract --registry-config "${pullsecret_file}" --command=$cmd --to "${extract_dir}" ${RELEASE_IMAGE}
27+
if [ -z "${INSTALLER_CONFIG+x}" ]; then
28+
echo "Assuming the Installer Config should be read from Prow";
29+
INSTALLER_CONFIG=/usr/local/osde2e-credentials/stage-installer-config
30+
fi
3531

36-
./openshift-install create cluster --dir=$(pwd)/installer/ --log-level info
32+
export OCM_CONFIG=./.ocm.json
33+
export KUBECONFIG="${SHARED_DIR}/kubeconfig"
3734

38-
export OCM_CONFIG=$(pwd)/.ocm.json
39-
export KUBECONFIG=$(pwd)/installer/auth/kubeconfig
35+
curl -s https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz | tar zxvf - oc
4036

41-
{
37+
chmod +x oc
4238

43-
go get -u github.com/openshift-online/ocm-cli/cmd/ocm
39+
GO111MODULE=on go get github.com/openshift-online/ocm-cli/cmd/ocm@master
4440

45-
if [ -z "$OCM_URL" ]; then
46-
ocm login --token=$OCM_TOKEN
41+
if [ -z "${OCM_URL}" ]; then
42+
ocm login --token="${OCM_TOKEN}"
4743
else
48-
ocm login --url=$OCM_URL --token=$OCM_TOKEN
44+
ocm login --url="${OCM_URL}" --token="${OCM_TOKEN}"
45+
fi
4946

50-
cat <<EOF | oc create -n openshift-monitoring -f -
47+
cat <<EOF | ./oc create -n openshift-monitoring -f -
5148
apiVersion: v1
5249
kind: ConfigMap
5350
metadata:
54-
name: cluster-monitoring-config
55-
namespace: openshift-monitoring
51+
name: cluster-monitoring-config
52+
namespace: openshift-monitoring
5653
data:
57-
config.yaml: |
54+
config.yaml: |
5855
telemeterClient:
59-
telemeterServerURL: https://infogw.api.stage.openshift.com
60-
56+
telemeterServerURL: https://infogw.api.stage.openshift.com
6157
EOF
62-
sleep 600;
63-
echo "Output new config"
64-
oc get -n openshift-monitoring configmap/cluster-monitoring-config -o yaml
65-
fi
6658

67-
COUNT=$(CLUSTER_ID=$(oc get clusterversion -o jsonpath='{.items[].spec.clusterID}{"\n"}'); ocm get clusters --parameter search="external_id is '$CLUSTER_ID'" | jq '.size')
59+
sleep 600;
60+
echo "Output new config"
61+
./oc get -n openshift-monitoring configmap/cluster-monitoring-config -o yaml
62+
63+
COUNT=$(CLUSTER_ID=$(./oc get clusterversion -o jsonpath='{.items[].spec.clusterID}{""}'); ocm get clusters --parameter search="external_id is '${CLUSTER_ID}'" | jq '.size')
6864

6965
if [[ "$COUNT" == "0" ]]; then
7066
echo "No cluster found!";
7167
exit 1
7268
else
7369
echo "Cluster found!";
7470
exit 0
75-
fi
76-
77-
} 2>&1 | tee -a /tmp/artifacts/test_output.log
71+
fi

0 commit comments

Comments
 (0)