Install Openshift Cluster on AWS


Install Openshift Cluster on AWS

Install the AWS CLI tools(Optional):

Download the latest AWS Command Line Interface

sudo -i
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip

Install the AWS CLI into /bin/aws

./awscli-bundle/install -i /usr/local/aws -b /bin/aws

Validate the AWS CLI works

aws --version

Clean up downloaded files

rm -rf /root/awscli-bundle /root/awscli-bundle.zip

Preparation before Run OpenShift Installer:

Get the OpenShift installer binary:

OCP_VERSION=4.4.3
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

Get the oc CLI tool:

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 and CLI are in /usr/bin:

ls -l /usr/bin/{oc,openshift-install}

Set up bash completion for the OpenShift CLI:

oc completion bash >/etc/bash_completion.d/openshift

Exit the super mode or ctrl+D

exit

Save your provided AWS credentials to the $HOME/.aws/credentials file

export AWSKEY=<YOURACCESSKEY>
export AWSSECRETKEY=<YOURSECRETKEY>
export REGION=us-east-2
mkdir $HOME/.aws
cat << EOF >>  $HOME/.aws/credentials
[User name]
aws_access_key_id = ${AWSKEY}
aws_secret_access_key = ${AWSSECRETKEY}
region = $REGION
EOF

Check your credentials work:

aws sts get-caller-identity

Copy pull secret:

  • go to https://www.openshift.com/try
  • Click Create your Own Cluster and then Try it in the cloud
  • For Infrastructure Provider, click AWS
  • Click Installer-Provisioned-Infrastructure
  • Copy Pull Secret

    Double check

    pull secret contains credentials for all three container registries: quay.io, registry.connect.redhat.com, and registry.redhat.io as well as cloud.openshift.com.

Create an SSH keypair for your OpenShift environment:

ssh-keygen -f ~/.ssh/cluster-${GUID}-key -N

Install OpenShift Container Platform:

Intro

The main assets generated by the installer are the Ignition configs for the bootstrap, master, and worker machines. Given these three configs (and correctly configured infrastructure), it is possible to start an OpenShift cluster. The process for bootstrapping a cluster looks like the following:

  • The bootstrap machine boots and starts hosting the remote resources required for the master machines to boot.

  • The master machines fetch the remote resources from the bootstrap machine and finish booting.

  • The master machines use the bootstrap node to form an etcd cluster.

  • The bootstrap node starts a temporary Kubernetes control plane using the newly created etcd cluster.

  • The temporary control plane schedules the production control plane to the master machines.

  • The temporary control plane shuts down, yielding to the production control plane.

  • The bootstrap node injects OpenShift-specific components into the newly formed control plane.

  • The installer then tears down the bootstrap node.

  • The result of this bootstrapping process is a fully running OpenShift cluster. The cluster will then download and configure the remaining components needed for day-to-day operation, including the creation of worker machines on supported platforms.

  • The installer uses a wizard approach, asking a few questions about the environment before executing the installation. If you want to avoid the wizard or run the installer from a shell script, it is useful to set up environment variables for a particular cloud platform.

Run OpenShift Installer

openshift-install create cluster --dir $HOME/cluster-${GUID}

? SSH Public Key /home/<OpenTLC User>/.ssh/cluster-<GUID>-key.pub
? Platform aws
INFO Credentials loaded from the "default" profile in file "/home/<OpenTLC User>/.aws/credentials"
? Region us-east-2 (Ohio)
? Base Domain sandboxNNN.opentlc.com
? Cluster Name cluster-<GUID>
? Pull Secret [? for help] ***************************************************************************************************************************************************************

Custom

It is possible to run a multi-step installation.

Create the installation configuration:
openshift-install create install-config --dir $HOME/cluster-${GUID}

Update the generated install-config.yaml file—for example, change the AWS EC2 instance types.

Create the YAML manifests:
`openshift-install create manifests –dir $HOME/cluster-${GUID}``

Create the Ignition configuration files:
openshift-install create ignition-configs --dir $HOME/cluster-${GUID}

Install the cluster:
openshift-install create cluster --dir $HOME/cluster-${GUID}

To delete the cluster, use:
openshift-install destroy cluster --dir $HOME/cluster-${GUID}

Validate Cluster

Set up the CLI
export KUBECONFIG=$HOME/cluster-${GUID}/auth/kubeconfig
echo "export KUBECONFIG=$HOME/cluster-${GUID}/auth/kubeconfig" >>$HOME/.bashrc
oc whoami oc get nodes oc get pod -A
Clean Up Cluster (Reference)

Delete the cluster:
openshift-install destroy cluster --dir $HOME/cluster-${GUID}

Delete all of the files created by the OpenShift installer:

rm -rf $HOME/.kube
rm -rf $HOME/cluster-${GUID}

More info: Openshift Installer


Author: bh7cw
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source bh7cw !
  TOC