OpenShift, a container application platform developed by Red Hat, has become a popular choice for organizations looking to streamline their application development and deployment processes. Built on top of Kubernetes, OpenShift provides a robust and secure platform for managing containerized applications at scale. In this article, we will introduce OpenShift, discuss its key features, and provide a step-by-step guide to installing and setting up OpenShift on your system.
Understanding OpenShift
OpenShift is an enterprise-grade container orchestration platform that simplifies the management of containerized applications. It offers a wide range of features and tools, including:
- Source-to-Image (S2I): A framework for building and deploying containerized applications directly from source code, without the need for a separate build process or Dockerfile.
- Deployment automation: Automated rollout and rollback of application updates, ensuring minimal downtime and improved reliability.
- Horizontal scaling: Automatic scaling of applications based on resource usage and demand, helping to optimize resource utilization and maintain performance.
- Integrated logging and monitoring: Built-in tools for collecting and analyzing application logs and metrics, simplifying the monitoring and troubleshooting process.
Prerequisites for OpenShift Installation
Before installing OpenShift, ensure that you meet the following system requirements:
- A compatible Linux operating system, such as Red Hat Enterprise Linux (RHEL), CentOS, or Fedora
- A minimum of 2 CPU cores and 8 GB of RAM for a single-node installation, or more for multi-node installations
- Docker or a compatible container runtime, like CRI-O or Podman, installed on your system
- A valid Red Hat subscription, if you are using RHEL or OpenShift Enterprise
Installing OpenShift
OpenShift offers several installation options, including OpenShift Container Platform, OpenShift Origin (the community version), and Minishift (a lightweight version for local development). In this guide, we will focus on installing OpenShift Origin, also known as OKD, using the following steps:
Step 1: Install dependencies
Before installing OpenShift, you will need to install several dependencies on your system:
- On RHEL or CentOS:
sudo yum install -y wget git net-tools bind-utils iptables-services bridge-utils bash-completion kexec-tools sos psacct
- On Fedora:
sudo dnf install -y wget git net-tools bind-utils iptables-services bridge-utils bash-completion kexec-tools sos psacct
Step 2: Install Docker
If you haven't already installed Docker, you can do so using the following commands:
- On RHEL or CentOS:
sudo yum install -y docker
sudo systemctl enable docker
sudo systemctl start docker
- On Fedora:
sudo dnf install -y docker
sudo systemctl enable docker
sudo systemctl start docker
Step 3: Install the OpenShift CLI
Download and install the OpenShift CLI (oc) using the following commands:
wget https://github.com/openshift/origin/releases/download/v3.11.0/openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz
tar -xvzf openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz
cd openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit
sudo cp oc kubectl /usr/local/bin/
Step 4: Start OpenShift
Now that you have installed the necessary dependencies and the OpenShift CLI, you can start a local OpenShift cluster using the following command:
oc cluster up
This command will initialize a local OpenShift cluster and download the required container images. Once the cluster is up and running, you will see output similar to the following:
Starting OpenShift using openshift/origin:v3.11.0
...
OpenShift server started.
The server is accessible via web console at:
https://127.0.0.1:8443
You are logged in as:
User: developer
Password: <any value>
To login as administrator:
oc login -u system:admin
Step 5: Access the OpenShift Web Console
OpenShift provides a web-based console for managing your cluster and applications. You can access the console by navigating to the URL displayed in the output of the `oc cluster up` command, typically https://127.0.0.1:8443.
Log in using the default developer account (username: developer, password: any value), or as an administrator using the `system:admin` username and the token generated during the installation.
Step 6: Deploy Your First Application
With OpenShift up and running, you can now deploy your first application. As an example, let's deploy a simple Node.js application:
1. Create a new project in the OpenShift web console or using the CLI:
oc new-project my-nodejs-app
2. Deploy the Node.js application using the Source-to-Image (S2I) builder:
oc new-app nodejs~https://github.com/sclorg/nodejs-ex.git
3. Expose the application to the outside world by creating a route:
oc expose svc/nodejs-ex
4. Access the application by navigating to the URL displayed in the output of the `oc expose` command.
Congratulations! You have successfully installed OpenShift and deployed your first application.
Conclusion
OpenShift offers a powerful and flexible platform for managing containerized applications, simplifying the development and deployment process for developers and operations teams alike. By following the steps in this guide, you can get up and running with OpenShift and start taking advantage of its many features and capabilities. As you become more familiar with OpenShift, you can explore additional tools and resources, such as the OpenShift Operator Framework and OpenShift Service Mesh, to further enhance your application development and management experience.
Comments
Post a Comment