Voiced by Amazon Polly |
Overview
This blog will walk you through the process of creating an OpenShift cluster in Google Cloud using the automation scripts included in this project.
Containerized services are managed using Kubernetes or OpenShift. Upgrades, failover, and service provisioning can all be automated. Container deployment, operation, scaling, and maintenance are thus simplified and automated for administrators.
Prerequisites
- GCP Account
- RedHat OpenShift
- Enabling API services in GCP
Note: If you plan to deploy your cluster in one of the following regions, you will exceed the maximum storage quota and are likely to exceed the CPU quota limit.
“Great Services come with great quota”
Customized Cloud Solutions to Drive your Business Success
- Cloud Migration
- Devops
- AIML & IoT
Step-by-Step Guide
Step 1 – Create Service Account, Assign Roles and Key
Create Service Account
1. Open GCP console > YOUR PROJECT NAME > IAM & Admin > Service Accounts > Create Service Account
2. Add Your Service Account Name
3. Add your Service Account ID
4. Create and Continue
5. Assign rolls to your Service Account
- compute admin
- security admin
- storage admin
- service account admin
- service account user
- service account key admin
- service Usage admin
- DNS Administrator
6. Click on Done
7. Go to Your service account
a. Click on KEYS > Add Key > Create New
b. Select key type as JSON
Step 2 – Create DNS Zone
1. Open GCP console > YOUR PROJECT NAME > Network & Services > Cloud DNS > Create a DNS Zone
2. Click on Public
3. Add Zone Your Name
4. Add DNS name yourname.com (Your Base Domain)
5. Click Create
Step 3 – Create Host VM to Deploy OpenShift Cluster
1. Open GCP console > YOUR PROJECT NAME > Compute > Create an Instance
2. Add your Name.
3. Choose Your Regions and Zone. (Page 4)
4. Select your Machine Configuration as E2-medium
5. Change your Boot Disk
a. ubuntu
b. Size 50
6. Change the Access scopes to Allow full access to all Cloud APIs
7. Check the Firewall for Http & Https Traffic.
8. Click create.
Step 4 – Setup OpenShift on Host VM
1. Select your VM that was previously created
2. Click on SSH
Your Host VM SSH Terminal
3. Enable the APIs needed to create a cluster
1 2 3 4 5 6 7 8 9 10 11 |
gcloud services enable compute.googleapis.com gcloud services enable cloudapis.googleapis.com gcloud services enable cloudresourcemanager.googleapis.com gcloud services enable dns.googleapis.com gcloud services enable iam.googleapis.com gcloud services enable iamcredentials.googleapis.com gcloud services enable servicemanagement.googleapis.com gcloud services enable serviceusage.googleapis.com gcloud services enable storage-api.googleapis.com gcloud services enable storage-component.googleapis.com gcloud services enable deploymentmanager.googleapis.com |
4. Create ssh-key for cluster
1 |
ssh-keygen -t ed25519 -N '' |
5. To check key is created
1 |
cat ~/.ssh/id_ed25519.pub |
6. Copy your JSON key to your host VM
a. Copy your JSON file to Host VM
b. Create a file in Host VM vi key.json > paste the Keys
c. Check the File with cat key.json
7. Set the GOOGLE_APPLICATION_CREDENTIALS environment variable to the full path to your service account private key file.
1 |
export GOOGLE_APPLICATION_CREDENTIALS=key.json |
8. To activate your service account in Host VM
a. Copy your service account email
1 |
gcloud auth activate-service-account <your service account email> --key-file=key.json |
b. Paste the command with your service account email and key
9. Now go to https://console.redhat.com/openshift/
a. Click on Clusters > Create Cluster > Click on GCP Platform > Select installer-provisioned infrastructure
https://console.redhat.com/openshift/install/gcp/installer-provisioned
b. copy link of Download Installer & Command line tool
c. Copy pull secrets
10. Download OpenShift Installer & Command Line Interface in Host VM
1 2 |
wget https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/stable/openshift-install-linux.tar.gz wget https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/stable/openshift-client-linux.tar.gz |
11. Extract the file and move it to
1 2 3 4 5 6 |
tar -xvf openshift-install-linux.tar.gz tar -xvf openshift-client-linux.tar.gz ls sudo mv oc kubectl openshift-install /usr/local/bin/ oc version openshift-install version |
12. Now we have to create a configuration file for cluster
1 2 3 4 5 6 7 |
openshift-install create install-config ? SSH Public Key /home/navy_nyx/.ssh/id_ed25519.pub #your ssh-key created ? Platform gcp #select gcp platform ? Project ID My First Project (iconic-biplane-367910) #select your gcp project ID ? Region us-east1 # select the host region ? Base Domain navneettoppo.ml # select your dns zone ? Cluster Name nav-cluster # your cluster name |
This command creates a template of install-config.yaml
13. Now create a directory as mkdir install
14. Now copy the config file inside the install directory & make changes as per your needs
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 |
cp install-config.yaml install/install-config.yaml apiVersion: v1 baseDomain: navneettoppo.ml compute: - architecture: amd64 hyperthreading: Enabled name: worker platform: gcp: type: e2-standard-4 osDisk: diskType: pd-standard diskSizeGB: 30 replicas: 1 controlPlane: architecture: amd64 hyperthreading: Enabled name: master platform: gcp: type: n2-standard-4 osDisk: diskType: pd-ssd diskSizeGB: 50 replicas: 1 metadata: creationTimestamp: null name: nav-cluster networking: clusterNetwork: - cidr: 10.128.0.0/14 hostPrefix: 23 machineNetwork: - cidr: 10.0.0.0/16 networkType: OpenShiftSDN serviceNetwork: - 172.30.0.0/16 platform: gcp: projectID: iconic-biplane-367910 region: us-east1 publish: External pullSecret: ‘YOUR OPENSHIFT PULL SECRET’ sshKey: ssh-ed25519 AAAA….. navy_nyx@ocp-host |
15. Now run the command to create a cluster from your configuration file
1 |
openshift-install create cluster –dir install –log-level=debug |
You can see the 2 new nodes created by
1 |
openshift-install and check the GCP console. |
To check cluster is created in the RedHat
console.
Step 5: Deploy the nginx server in OpenShift Cluster
1. Create nginx yaml script
1 2 3 |
mkdir nginx cd nginx nano nginx.yaml |
2. Copy below nginx.yaml script save it
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 |
kind: Service apiVersion: v1 metadata: name: nginx labels: app: nginx spec: selector: app: nginx ports: - port: 80 protocol: TCP targetPort: 80 type: ClusterIP --- apiVersion: apps/v1 kind: Deployment metadata: name: nginx labels: app: nginx spec: replicas: 1 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:latest imagePullPolicy: Always ports: - containerPort: 80 protocol: TCP |
3. Now run the following commands
1 2 3 4 5 |
oc apply --filename nginx/nginx.yaml cd nginix/ oc get pods oc get deployments oc get svc |
4. Go to your browser and paste the External IP of the nginx server
Conclusion
The built-in Kubernetes support makes operating a PaaS environment very straightforward, and the powerful management tools make day-to-day management a breeze. The platform handles resource intensive workloads like elastic search and media streaming. It’s also worth noting that the platform performs exceptionally well under load. For example, I saw almost no latency when running tests that subjected the applications to excessive demand. However, there are some aspects of the platform that could be improved.
In particular, I would very much like to see additional support for additional cloud providers. Currently, only the RHEL ecosystems are supported, so organizations that prefer to host their platforms on other OS will need to look elsewhere for their solutions. Finally, the cost of maintaining the platform could be reduced if the platform were hosted in regions that are closer to customers’ locations. As we discussed in the last post, this would help to reduce latency and provide more consistent performance. All in all, though, the OpenShift on Google Cloud Platform is a great solution for organizations looking to deploy and operate complex multi-tier applications in the cloud.
I hope that this guide will be useful to anyone who is trying to deploy and run applications on the OpenShift in GCP.
Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.
- Cloud Training
- Customized Training
- Experiential Learning
About CloudThat
CloudThat is also the official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner and Microsoft gold partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.
Drop a query if you have any questions regarding Kubernetes, VMware, vSphere, or any other services and I will get back to you quickly.
To get started, go through our Consultancy page and Managed Services Package that is CloudThat’s offerings.
FAQs
1. Is OpenShift free to use?
ANS: – OpenShift offers a free starter tier for experimentation, testing, and development. When you are ready to put your application into production and make it available to others, or if you require more resources than the free tier provides, you can upgrade to the paid tier.
2. Is OpenShift open source?
ANS: – Red Hat OpenShift is an enterprise grade open-source application platform that accelerates the development and delivery of cloud-native applications across hybrid and multi-cloud environments, all the way to the edge.
3. How do I install OpenShift on my computer?
ANS: – To quickly start up an OpenShift cluster locally inside of a virtual machine (VM), you can use Red Hat Code Ready Containers. CodeReady Containers requires a hypervisor to run the VM containing OpenShift.
- VMware
- Virtual Box
![](https://content.cloudthat.com/resources/wp-content/uploads/2022/11/Navneet-150x150-1.png)
WRITTEN BY Navneet Nirmal Toppo
Navneet is a Research Associate at CloudThat. He is a Microsoft Certified Solution Professional and a Certified Network Security Specialist and who has experience in AWS, Azure, GCP & vSphere. He is passionate about cloud computing, cybersecurity, and learning new cloud-native technologies who strives to provide the best cloud experience to clients through transparency.
Comments