In this recipe, we will learn how to deploy Red Hat OpenShift on AWS, bare-metal, or VMware vSphere VMs.
The steps in the Provisioning an OpenShift cluster recipe can be applied to deploy OpenShift on either VMs running on a virtualized environment or bare-metal servers.
Getting ready
All the operations mentioned here require a Red Hat account with active Red Hat Enterprise Linux and OpenShift Container Platform subscriptions. If you don't have one already, go to https://access.redhat.com and create an account.
For this recipe, we need to have a minimum of six nodes with Red Hat Enterprise CoreOS installed on them. These nodes can be either bare-metal, VMs, or a mix of bare-metal and VMs.
How to do it…
This section will take you through how to configure Red Hat OpenShift. To that end, this section is further divided into the following subsections to make this process easier:
- Downloading OpenShift binaries
- Provisioning an OpenShift cluster
- Connecting to OpenShift clusters
Downloading OpenShift binaries
Make sure you are on the Terminal of your first master and that you have an account with root access, or you are running as a superuser. Follow these steps:
- Go to https://cloud.redhat.com/openshift/install and download the latest OpenShift Installer:
- Extract the installer files on your workstation:
$ tar -xzf openshift-install-linux-*.tar.gz
The preceding command will create a file called openshift-install in the same folder.
Provisioning an OpenShift cluster
In this recipe, we will use the AWS platform to deploy OpenShift:
- To get your OpenShift cluster up, use the following command:
$ ./openshift-install create cluster
- Choose aws as your platform and enter your AWS Access Key ID and Secret Access Key.
- Choose your region. In our example, this is us-east-1.
- Select a base domain. In our example, this is k8s.containerized.me.
- Enter a cluster name.
- Copy Pull Secret from the Red Hat site and paste it onto the command line:
- After the installation is complete, you will see the console URL and credentials for accessing your new cluster, similar to the following:
INFO Install complete!
INFO To access the cluster as the system:admin user when using 'oc', run 'export KUBECONFIG=/home/ubuntu/auth/kubeconfig'
INFO Access the OpenShift web-console here: https://console-openshift-console.apps.os.k8s.containerized.me
INFO Login to the console with user: kubeadmin, password: ABCDE-ABCDE-ABCDE-ABCDE
- Switch to the Red Hat site and click on the Download Command-Line Tools link to download openshift-client.
- Extract the openshift-client files in your workstation:
$ tar -xzf openshift-client-linux-*.tar.gz && sudo mv oc /usr/local/bin
The preceding command will create the kubectl and oc files on the same folder and move the oc binary to PATH.
Connecting to OpenShift clusters
To connect to OpenShift clusters, follow these steps:
- To get access to your OpenShift cluster, use the following command:
$ export KUBECONFIG=~/auth/kubeconfig
- Log in to your OpenShift cluster after replacing password and cluster address:
$ oc login -u kubeadmin -p ABCDE-ABCDE-ABCDE-ABCDE \
https://api.openshift.k8s.containerized.me:6443 \
--insecure-skip-tls-verify=true
If you prefer to use the web console instead, open the web console URL address from the Provisioning an OpenShift cluster recipe, in step 7.
How it works…
This recipe showed you how to quickly deploy an OpenShift cluster on AWS.
In step 1, we created a cluster using the default configuration of the installer-provisioned infrastructure.
The installer asked a series of questions regarding user information and used mostly default values for other configuration options. These defaults can be edited and customized if needed using the install-config.yaml file.
To see the defaults that were used for the deployment, let's create an install-config.yaml file and view it:
$ ./openshift-install create install-config && cat install-config.yaml
As you can see from the following output, the file's default configuration creates a cluster consisting of three master and three worker nodes:
apiVersion: v1
baseDomain: k8s.containerized.me
compute:
- hyperthreading: Enabled
name: worker
platform: {}
replicas: 3
controlPlane:
hyperthreading: Enabled
name: master
platform: {}
replicas: 3
...
Edit install-config.yaml as needed. Next time you create the cluster, new parameters will be used instead.
There's more…
It is also useful to have knowledge of the following information:
- Deleting your cluster
Deleting your cluster
To delete your cluster, use the following command:
$ ./openshift-install destroy cluster
This process will take a few minutes and, when finished, you will get a confirmation message.
See also
- The OpenShift Container Platform 4.3 Documentation: https://docs.openshift.com/container-platform/4.3/welcome/index.html