-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdeploy.sh
executable file
·45 lines (36 loc) · 1.48 KB
/
deploy.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
#!/bin/bash
set -e
ENVIRO=$1
if [[ ! "$ENVIRO" =~ ^(dev|preprod|prod)$ ]]; then
echo "Invalid environment $ENVIRO, only dev, preprod and prod supported"
exit
fi
mkdir -p bin
if ! /usr/local/bin/oc > /dev/null 2>&1 ; then
echo openshift origin client not found, installing
curl -#L -o openshift.tar.gz https://github.com/openshift/origin/releases/download/v3.11.0/openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz
tar -xvf openshift.tar.gz --wildcards '*oc'
mv openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit/oc bin/
rm -rd openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit*
fi
if ! /usr/local/bin/kustomize > /dev/null 2>&1 ; then
echo kustomize binary not found, installing
curl -L# -o kustomize.tar.gz https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv3.5.4/kustomize_v3.5.4_linux_amd64.tar.gz
tar -xvf kustomize.tar.gz
mv kustomize bin
fi
if [[ "$ENVIRO" == "dev" ]]; then
OPENSHIFT_TOKEN=$OPENSHIFT_TOKEN_DEV
fi
if [[ "$ENVIRO" == "preprod" ]]; then
OPENSHIFT_TOKEN=$OPENSHIFT_TOKEN_PREPROD
fi
if [[ "$ENVIRO" == "prod" ]]; then
OPENSHIFT_TOKEN=$OPENSHIFT_TOKEN_PROD
fi
oc login --token="$OPENSHIFT_TOKEN" --server="$OPENSHIFT_SERVER"
# oc login --token="$OPENSHIFT_TOKEN" --server="$OPENSHIFT_SERVER" > /dev/null
kustomize build k8s/$ENVIRO | sed "s/DEPLOYMENT_RUN_ID/$(uuidgen)/" > manifest.yaml
cat manifest.yaml
cat manifest.yaml | oc apply -f -
oc rollout status -w deploy/operatorhubio