๐ Unleashing the Power of OpenShift: Creating a High-Performance Cluster on AWS EC2 Instances ๐ป๐
Introduction
Discover the game-changing alliance of OpenShift and AWS! ๐ OpenShift, the ultimate Kubernetes container platform, automates scaling, enhances security, and optimizes container orchestration. When paired with the Amazon Web Services (AWS) ecosystem, it becomes your secret weapon for creating, deploying, and maintaining applications like a pro. Get ready to build a high-performance, scalable, and ironclad infrastructure for your containerized workloads. The future of cloud computing is here, and it's electrifying! โก๐ป
Prerequisites:
AWS Account
Red Hat Account
Create a Route 53 Public Hosted Zone
Step 1: Log in to your AWS Console in a browser and Navigate to Route 53.
- Please enter your domain name, or if you do not have one already, create one on any of the following platforms: Hostinger, GoDaddy, Cloudflare, etc.
- You can see the nameservers that were created for your domain after creating a public-hosted zone. In a text editor, copy those nameservers.
- These nameservers must be added to the domain registration platform where you created the domain. For example, Hostinger
- You must replace these nameservers with custom ones and add the nameservers provided by AWS to the public-hosted zone.
Create a Jump Host in AWS
- Create a Linux EC2 instance and choose the t2.medium instance type.
- To SSH into the instance, generate a new key pair (or use an existing one).
- Use the default VPC and permit all traffic in the security group in the networking section.
Launch the instance using this configuration, and then wait for it to run successfully for two minutes.
Once the VM is successfully created, SSH into the machine
Install the AWS CLI
sudo apt install unzip
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
Using the above commands, try to install the AWS CLI in the VM and after successful installation, check the AWS version using the below command
aws --version
AWS Configure
Create an Access key and a Secret key inside your AWS account's security credentials. Apply the following command to that machine to configure your AWS Access keys and Secret Keys.
aws configure
Generating a new SSH private key and adding it to the agent
Run the below-shown command to generate the SSH key that is configured for password-less authentication.
ssh-keygen -t rsa -b 4096 -N '' -f /home/ec2-user/id_rsa
To start the ssh-agent process as a background task, execute the below-shown command.
eval "$(ssh-agent -s)"
Run the below-shown command to add the SSH private key to the ssh-agent.
ssh-add /home/ec2-user/id_rsa
To be sure you added the key successfully in this manner, look below.
Download Openshift installer using user-provisioned Infrastructure
Create an account in Red Hat Openshift (https://www.redhat.com/en/technologies/cloud-computing/openshift/try-it)
Navigate to the Red Hat console (https://console.redhat.com/openshift/)
Click on the Create Cluster button
Choose the Cloud option, then scroll down a bit to the "Run it yourself" section.
The AWS architecture type AWS (x86_64) option will display the UPI and IPI installation methods.
You can choose the desired OS type if you use the full control technique. To download the tar file, perform the following command in the terminal or click the Download Installer button.
wget https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-install-linux.tar.gz
Do the same for downloading command-line tools and it will also download a tar file
Untar the Openshift installer. Run the following command to unzip the OpenShift installer and copy the files:
tar -xvzf openshift-install-linux.tar.gz sudo mv openshift-install /usr/local/bin/ openshift-install version
Untar the Openshift Client tar file and move the files to /usr/local/bin directory
Deploy the OpenShift Cluster
Create an Install-config file using this command
openshift-install create install-config
Once you execute this command, it will ask for a couple of inputs
Cloud Provider: AWS
Region: ap-south-1 (Mumbai) (use arrow keys to move)
Base Domain: It will list all the public hosted zones in AWS Route53 and select your domain in that
Cluster Name: Give a name to the cluster
Pull Secret: Copy the secret from your Red Hat console and paste it here
After providing all the inputs, hit enter It will create an install-config.yaml file in your directory
Edit the config file using the vi editor and the file looks like
apiVersion: v1 baseDomain: yourdomain.com compute: - architecture: amd64 hyperthreading: Enabled name: worker platform: aws: zones: - us-east-2a - us-east-2b - us-east-2c rootVolume: iops: 2000 size: 500 type: io1 type: m4.xlarge replicas: 3 controlPlane: architecture: amd64 hyperthreading: Enabled name: master platform: aws: zones: - us-east-2a - us-east-2b - us-east-2c rootVolume: iops: 4000 size: 500 type: io1 type: m4.xlarge replicas: 3 metadata: creationTimestamp: null name: openshift 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: aws: region: us-east-2 publish: External pullSecret: <your-pull-secret> sshKey: <your-ssh-key>
Your previously generated SSH key needs to be included at the end of the YAML file.
The master and worker replicas, machine types, and networking components are all modifiable.
You can refer to this document for more parameters of the file https://docs.openshift.com/container-platform/4.9/installing/installing_aws/installing-aws-customizations.html
You can create a cluster now using this command
openshift-install create cluster --log-level debug
The installation program creates and configures a bootstrap machine with a temporary Kubernetes control plane, which then creates and configures the master EC2 instance. Then the control plane on the master nodes creates and configures the worker EC2 instance.
Note: It can take approximately 45 minutes to get the complete cluster up and running.
Access the OpenShift Cluster
Once the OpenShift cluster is up and running, it will provide a URL with a Username and Password to log in to the OpenShift cluster.
Note: Copy the URL with username and password and store it in a text editor
Login to the Cluster
Follow the below commands to check the cluster details and connect the cluster
export KUBECONFIG=/home/ec2-user/auth/kubeconfig
oc whoami
After a successful login, It will return as a system: admin as output
You can check the cluster by using the below command:
kubectl get ns
Uninstalling the Cluster on AWS
You can remove all the cluster-related resources created in AWS using the below command:
openshift-install destroy cluster --log-level debug
Summary
๐ In this guide, we've embarked on an exciting journey to create a high-performance OpenShift cluster on AWS EC2 instances! ๐ Now, armed with this knowledge, you're ready to craft a robust container orchestration platform.
๐ก Imagine the possibilities: effortless application deployment, seamless scalability, and ironclad security โ all at your fingertips, thanks to the powerful combo of OpenShift and AWS. ๐๐
Stay in the loop with us as we unveil the freshest insights and trends in the ever-evolving worlds of Cloud and DevOps. Your tech journey is about to get even more exciting! ๐๐ก