forked from okkyhtf/ocp4-at-opentlc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare-openshift-installer.sh
executable file
·65 lines (48 loc) · 1.94 KB
/
prepare-openshift-installer.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/env bash
# Make sure you setup these ENV variables
export AWSKEY=CHANGETHIS
export AWSSECRETKEY=CHANGETHIS
export REGION=ap-southeast-1
export OCP_VERSION=4.7.4
export GUID=CHANGETHIS
set -xe
# Download and extract the latest AWS Command Line Interface
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscli-bundle.zip"
# Extract downloaded AWS Command Line Interface archive file
unzip ./awscli-bundle.zip
# Install the AWS CLI into /bin/aws
./aws/install -i /usr/local/aws-cli -b /usr/local/bin --update
# Add AWS CLI to PATH
export PATH="$PATH:/usr/local/bin"
# Validate that the AWS CLI works
aws --version
# Cleanup downloaded files
rm -rf ./aws ./awscli-bundle.zip
# Configure AWS credentials
mkdir $HOME/.aws
cat <<EOF >>$HOME/.aws/credentials
[default]
aws_access_key_id = ${AWSKEY}
aws_secret_access_key = ${AWSSECRETKEY}
region = $REGION
EOF
# Validate AWS credentials
aws sts get-caller-identity
# Generate SSH keypair for OpenShift cluster
ssh-keygen -f ~/.ssh/cluster-${GUID}-key -N ''
# Download OpenShift 4 Installer binary
wget https://mirror.openshift.com/pub/openshift-v4/clients/ocp/${OCP_VERSION}/openshift-install-linux-${OCP_VERSION}.tar.gz
tar zxvf openshift-install-linux-${OCP_VERSION}.tar.gz -C /usr/bin
rm -f openshift-install-linux-${OCP_VERSION}.tar.gz /usr/bin/README.md
chmod +x /usr/bin/openshift-install
# Download OpenShift 4 Client binaries
wget https://mirror.openshift.com/pub/openshift-v4/clients/ocp/${OCP_VERSION}/openshift-client-linux-${OCP_VERSION}.tar.gz
tar zxvf openshift-client-linux-${OCP_VERSION}.tar.gz -C /usr/bin
rm -f openshift-client-linux-${OCP_VERSION}.tar.gz /usr/bin/README.md
chmod +x /usr/bin/oc
# CHeck that the OpenShift Installer
ls -l /usr/bin/{oc,openshift-install}
# Setup OpenShift Client Bash completion
oc completion bash >/etc/bash_completion.d/openshift
# Relogout to reinitialize Bash profile
echo "Please exit the session and relogin again to enable the Bash completion."