, ,

Installing OpenShift Container Platform and setting it up on a Linux machine

Posted by

OpenShift installation and configuration on a Linux computer is a multi-step process that requires several different steps. I will thoroughly describe each step in this guide so that you have a clear grasp of how it works. OpenShift is a Kubernetes-based container orchestration platform that makes it easier to build, manage, and scale containerized applications. It is frequently utilized in the containerization and DevOps industries.

Requirements:
Below is a list of requirements that is required for us to be able to install OpenShift:

  1. Linux Machine: To be able to successfully run OpenShift, you should have a Linux machine with adequate CPU, RAM, and storage.
  2. Root or Sudo Access:On your Linux machine, you should have root or sudo privileges.
  3. Docker: OpenShift utilize Docker as a containerization platform. Test that Docker is configured up and running on the machine you are using. You may stick to your Linux distribution’s instructions for setting up for Docker.
  4. kubectl: kubectl is the command-line tool for interacting with Kubernetes clusters. Follow the instructions provided in the Kubernetes handbook, install it on your system.
  5. oc: is the OpenShift CLI tool. this tool is required to allow us interact with OpenShift cluster. it can be downloaded from from the official OpenShift website.
  6. Red Hat Account: a Red Hat Account is needed to enable us to download OpenShift you can easily sign up for free the Red Hat website.
  7. Domain Name: This will be used when setting up a wildcard DNS entry for our OpenShift cluster.

With the above prerequisites in place, we can now proceed with the installation and setup of OpenShift.

Step 1: Download and Install OpenShift

  1. Go to the Red Hat OpenShift download page (https://www.openshift.com/try) and log in with your Red Hat account.
  2. Choose the version of OpenShift you to install. Our recommended is you use the latest stable release.
  3. proceed to download the OpenShift installer for Linux.
  4. when download is complete, ensur to set the installer executable:
   chmod +x openshift-install
  1. Set a directory and move the the directory PATH to make it easily accessible:
   sudo mv openshift-install /usr/local/bin/

Step 2: Create an OpenShift Install Configuration

  1. Have a directory that we will use to store our OpenShift installation files:
   mkdir ~/openshift-install
   cd ~/openshift-install
  1. The command below will allow us to generate an OpenShift install configuration file by running:
   openshift-install create install-config
  1. Ensre tou follow the prompts to configure your installation. along the processyou will be asked to provide details such as your platform (e.g., AWS, GCP, Azure, or bare metal), SSH public key, and cluster name.
  2. when configuration is complete, the installer will generate an install-config.yaml file in the current working directory.

Step 3: Generate OpenShift Installation Artifacts

  1. We will use the OpenShift installer to generate the necessary installation artifacts which include the ignition configuration files:
   openshift-install create ignition-configs
  1. This ouput of the command will createthe following files:
  • bootstrap.ign: Ignition file for the bootstrap node.
  • master.ign: Ignition file for the control plane nodes.
  • worker.ign: Ignition file for the worker nodes.

Step 4: Create a DNS Wildcard Entry

Thepurpose of the wildcard DNS entry required by OpenShift is to route subdomains to the cluster. This will be achieved by adding a wildcard DNS record for your domain that points to the IP address of your OpenShift machine. usually this process vary depending on the DNS provider that we are using.

  1. Log in to your DNS provider’s control panel.
  2. Create a DNS A record that points to the IP address of your Linux machine, and make it a wildcard record by using an asterisk (*) as the subdomain. This ensures it will route all subdomains to your OpenShift cluster.
  3. a times DNS changes may take a while to propagate ,so we have to give some time.verification of the DNS configuration can be done using the nslookup command:
   nslookup subdomain.yourdomain.com

ensure you replace subdomain.yourdomain.com with the domain you have purchased subdomain.

Step 5: Set Up the OpenShift Cluster

  1. Copy the ignition files (bootstrap.ign, master.ign, and worker.ign) to a web server or a location accessible from your Linux machine.The Nodes will use the files will be during the installation process.
  2. open a terminal and cd …. to the directory where the ignition files are located.
  3. We then bootstrap node installation process by running the following command:
   sudo coreos-installer install /dev/sda \
   --ignition-url=https://path/to/bootstrap.ign \
   --insecure

ensre to replace https://path/to/bootstrap.ign with the actual URL of the bootstrap.ign file.

Note: The --insecure flag is enables us to download ignition files from an HTTP server without SSL. When doing installation for production we recommended you use HTTPS and obtain SSL certificates.

  1. When bootstrap node installation is complete, the machine will reboot. We will then proceed and Remove the installation media (if any) and let it boot from the hard drive.
  2. the bootstrap node oce up we can monitor its progress using the journalctl command:
   journalctl -b -f -u bootkube.service

The command will show the logs of the control plane components being deployed.

  1. Once the control plane is up, Now you can proceed to add worker nodes when the control plane is up. we will achieve this by generating a kubeconfig file on the control plane node by doing SSH into the control plane node:
   ssh core@<control_plane_node_ip>
  1. We now proced and create a kubeconfig file on the control plane node:
   sudo mkdir -p /etc/kubernetes/auth
   sudo cp /root/auth/kubeconfig /etc/kubernetes/auth/kubeconfig
   sudo chmod 644 /etc/kubernetes/auth/kubeconfig
  1. Quit the SSH session:
   exit
  1. The worker nodes will be added to the cluster and this is achieved by doing SSH into each worker node and run the following command:
   sudo coreos-installer install /dev/sda \
   --ignition-url=https://path/to/worker.ign \
   --insecure

Ensure you replace https://path/to/worker.ign with the actual URL of the worker.ign file.

  1. Whe all the nodes are added, proceed and verify the cluster’s status by SSHing into the control plane node and running: oc get nodes you will get a list of control plane and worker nodes in a “Ready” state.

Step 6: Accessing OpenShift Web Console

Below is the steps to access the OpenShift web console:

  1. Navigate to Browser in the local machine and avigate to the OpenShift URL of which by default usually is https://console-openshift-console.apps.yourdomain.com,we will replace yourdomain.com the actual domain we used
  2. the OpenShift login page will open,you are suppose to Use the username and password we configured configured during the installation process to able to log in.
  3. When default configuration is used , the username is kubeadmin.
  4. if you want to retrieve the password from the control plane node,we will use the following command: ssh core@<control_plane_node_ip> sudo cat /root/auth/kubeadmin-password
  5. On successful login, the openshift web graphical interface will open,we can manage our cluster,deploy applicationa and do monitoring of resources.

Step 8: Deploying Applications

Here are the steps to guide you on deployment procedure for your applications

  1. Click the “Developer” perspective in the left sidebar of the OpenShift web console.
  2. To start a new project, click the “Add” button. After naming your project, click “Create.”
  3. To navigate to the context of the project you just created, click on it.
  4. On the “Topology” tab on the left sidebar, click to deploy an application.
  5. To start a new deployment, click “Deploy”.
  6. Include the URL, name, and desired replicas for the container image when completing the deployment information.
  7. To release the application, click “Create”.
  8. The “Topology” view allows you to keep track of the deployment’s progress. Once the deployment is complete we can now access your application by clicking on the corresponding pod.

Step 9: Scaling Applications

Applications may be easily scaled up or down with OpenShift as necessary:

  1. Click on the application you want to scale in the “Topology” view.
  2. Click the “Scaling” tab in the application details panel.
  3. Pick the appropriate number of replicas, then click “Save.”

Step 10: Monitoring and Logging

To assist you in keeping a check on your cluster and apps, OpenShift includes built-in monitoring and logging features:

  1. Navigate to the “Monitoring” perspective in the OpenShift web console’s left sidebar.
  2. To monitor cluster health and application performance, you may access a number of monitoring and alerting tools from here.
  3. You can use the “Logs” tab in the “Developer” perspective to access application logs. Choose the pod or container that you wish to review logs.

Step 11: Networking and Routes

OpenShift manages routing and networking to make your applications accessible to anyone outside the organization:

  1. Create a “Route” to expose an application to the external environment.
  2. Go to the “Networking” perspective in the OpenShift web console’s left sidebar.
  3. In the “Routes” options, click “Create Route.”
  4. Specify the hostname and details of the service for that route. To create the route, click “Create”.
  5. Now, you are able to access your application at the provided hostname.

Step 12: Updating and Maintaining OpenShift

To maintain security and performance, OpenShift requires frequent updates and maintenance. How to install the latest OpenShift is as follows:

  1. Run the oc command-line tool or the OpenShift online portal to check for updates that have become available.
  2. Before performing any updates, create a backup of your cluster and applications.
  3. For the update process, follow to the official documents. Updates to the OpenShift CLI (oc), the control plane, and worker nodes are often necessary for this.
  4. Test your applications thoroughly after the update to ensure sure they function properly.

Step 13: Security Best Practices

Although OpenShift has strong security features, it’s still important to adhere to best practices to safeguard your cluster and applications:

  1. To limit who is granted access to and control over resources within your cluster, configure RBAC (Role-Based Access Control).
  2. To check container images for vulnerabilities, enable image scanning.
  3. Install security patches to your cluster and applications.
  4. For controlling traffic between pods and services, use network policies.
  5. often review and audit cluster activity and logs.

Conclusion

There are various phases involved in setting up OpenShift on a Linux computer, from installation to application deployment and maintenance. OpenShift simplifies container orchestration easy to use and provides effective solutions for scalable containerized application administration. You should have a strong foundation for working with OpenShift and effectively creating and managing containerized applications after reading this manual. Keep in mind that for comprehensive information on specific topics and advanced configurations, consult the official OpenShift handbook.

Leave a Reply

Your email address will not be published. Required fields are marked *