Install OpenShift Cluster on Google Cloud Platform
Introduction
Many organizations see the benefit of running their cloud environment as platform-agnostic as in not dependent to the public cloud and thus allow rapid transition between clouds if necessary.
In this blog, I explain how to install and configure the OpenShift environment running on Google Cloud Platform (GCP) using the Installer-provisioned installation (IPI).
References
- Documentation
https://docs.openshift.com/container-platform/4.9/installing/installing_gcp/installing-gcp-private.html - APIs
https://docs.openshift.com/container-platform/4.9/installing/installing_gcp/installing-gcp-account.html
https://cloud.google.com/service-usage/docs/enable-disable#enabling - Install binary and oc client
https://console.redhat.com/openshift/install/gcp/installer-provisioned
Prerequisites
- GCP account
Configure resources in a GCP project
Enable the following required API services in the project that hosts your cluster. See Enabling services in the GCP documentation
Enable the domain API service
Click on ‘REGISTER DOMAIN’ button
Now the DNS zone appears in the Cloud DNS dashboard
Create a service account with an owner rule
Download a file that contains the private key in a JSON format
Preparing the provisioner instance for OCP installation
In my case, I used RHEL 8 as the operating system and 2 vCPUs and 2 GB of memory
Log into Redhat dashboard and navigate to OpenShift -> Clusters -> Create cluster -> Google Cloud Platform and Select the installation type of ‘Installer-provisioned infrastructure’ (IPI)
NOTE: VPC network and router will be created automatically as part of IPI installation
Now click to download both the ‘OpenShift installer’ and the ‘Command line interface’ (with the blue buttons to the right)
Create an installation directory that will contain the following two files:
- The private key in a JSON format
- The OpenShift installer file that we downloaded just now in the last step
Create the environment variable that will hold the key file (.json) with the name of the default GCP variable by the following command:
export GOOGLE_APPLICATION_CREDENTIALS=< key file >
Create an install config file via an installation wizard by the following command from within the installation directory:
./openshift-install create install-config --dir .
Inside the wizard continue to press ‘Enter’ throughout the questions and the wizard will fill in the values correctly like so in my example:
(your values may vary)
Now the ‘install-config.yaml’ file is ready and appears inside the installation directory.
The ‘install-config’ file should look like this:
NOTE: The values can be changed according to your sermon. For example, masters or workers numbers, subnets, etc.
Create a cluster by the following command:
./openshift-install create cluster --dir . --log-level=debug
Finally (after all the creation process) we will see:
NOTE: When the deployment process is complete it will show you the following important details such as the kubeadmin user and password that with it you log in to your cluster, and your OpenShift console URL.
Let’s check our cluster
Access the OpenShift console URL using the kubeadmin user and password
Connect to the cluster with the command-line tools
oc login https://console-openshift-console.apps<base domain> -u kubeadmin -p < password >
OC commands:
oc get node
oc get co