Deploying and managing containerized applications is not easy. The rise of microservice architecture has made it cumbersome to deploy containers across multiple environments. Given that containers can be spun up in seconds and at a much higher volume compared to VMs, managing containers across multiple platforms can be extremely challenging.
Red Hat OpenShift to the rescue! OpenShift, the leading enterprise Kubernetes platform, enables a cloud-like experience wherever it’s deployed—in the cloud, on premises, or at the edge. OpenShift is built upon Kubernetes, which is designed and built from the ground up to deploy and manage containerized applications across hundreds of compute nodes.
Red Hat OpenShift gives you the ability to choose where you build, deploy, and run applications, providing a consistent experience every time. OpenShift’s full-stack automated operations and self-service provisioning for developers lets teams work together more efficiently to move ideas from development to production.
OpenShift focuses on developer experience and application security that’s platform agnostic. OpenShift helps you develop and deploy applications to one or more hosts, which can be public-facing web applications or backend applications, including microservices or databases. Applications can be implemented in any programming language you choose; the only requirement is that the application can run within a container.
OpenShift Container Platform (OCP) is a set of modular components and services built on top of Red Hat Enterprise Linux and Kubernetes. OpenShift supports remote management, multitenancy, increased security, application lifecycle management, and provides self-service interfaces for developers.
While OpenShift is built on Kubernetes, it extends the open source platform in several ways to make it suitable for enterprise operations teams: Automated installation and operations for platform updates on the container host, the Kubernetes cluster, and application services A consistent Kubernetes platform portable across different infrastructures and clouds Built-in cluster and application monitoring using Prometheus and Grafana dashboards Centralized policy management and enforcement across clusters Built-in security checks for the entire container stack throughout the application life cycle
OpenShift is fully pluggable and works with a wide range of technologies, including languages such as .NET, Java, Node.js, PHP, Python, Ruby, GoLang, and Perl as well as databases such as MariaDB, MongoDB, MySQL, PostgreSQL, and Redis. In addition, OpenShift is certified with and supports 100+ independent software vendors, including Redis Enterprise.
OperatorHub is the web console interface in OpenShift Container Platform that cluster administrators use to discover, install, and manage operators. In a few clicks, users can subscribe to the software they like via operators and make it available to software developers and platform administrators across clusters or isolated namespace environments using Operator Lifecycle Manager (OLM).
In this tutorial, you will learn how to deploy Redis Enterprise Cluster and Database on OpenShift using Redis Enterprise Kubernetes Operator.
To follow this guide, you should have an OpenShift cluster with 3 or more worker nodes. There are multiple ways to provision an OpenShift cluster, you can follow the installation guide based on your preferred infrastructure or cloud provider. Redis Enterprise Operator currently supports OpenShift 3.11 and OpenShift 4.x. Visit this page to find all the supported Kubernetes distributions.
In this guide we are using a self-managed OpenShift Cluster on Google Cloud Platform.
You can login to OCP via CLI and user with cluster-admin role.
You have access to 68 projects, the list has been suppressed. You can list all projects with 'oc projects'.
Ensure that all the nodes should be in “Ready” status.
Redis Enterprise can only be deployed in an user’s custom project. Hence, let us create a new project.
The SCC (security context constraint) YAML defines security context constraints for the cluster for our project. This is composed of custom security settings and strategies that will provide access to the Redis Enterprise Operator and Cluster Pods to run on OpenShift. We strongly recommend that you not change anything in this YAML file.
Apply the configuration to a resource by filename “scc.yaml” which is available in “openshift” folder as shown below:
If you want to perform this operation via UI, follow the below steps:
Login to OpenShift console with admin privileges.
Click on “OperatorHub” under Operators section.
This will open up a list of operators with various categories. Search for “Redis” and click “Redis Enterprise” (the one without the “Marketplace” tag) to proceed.
Click “Install” to start the installation process and then select the required channel, namespace and approval strategy in the next screen.
Wait for the installation to be completed.
Click on “Events” to see the streaming events in order to troubleshoot or check the progress of the installation.
Once Redis Enterprise Operator is installed, create a Redis Enterprise Cluster instance using RedisEnterpriseCluster (REC) custom resource.
RedisEnterpriseCluster is the schema for the redisenterpriseclusters API. From the installed Redis Enterprise Operator, click on “Create RedisEnterpriseCluster'' and click on “YAML” section, then paste the sample YAML file below:
For configuring any additional parameters for the Redis Enterprise Cluster custom resource, visit this page.
Wait until the status shows “Succeeded” under Redis Enterprise Operator.
To access the Redis Enterprise Cluster admin console, you will need credentials. Follow the steps below to get the credentials via “rec” secret resource.
Under the "Data" section, you can reveal username and password.
Next, Click on “Services” and choose “rec-ui” under the services list.
Click on "Services" and look for External Load-balancer IP.
Step 10. From the web browser, access the rec-ui external IP http://IP:8443 to access the Redis Enterprise Cluster Admin Console.
To log into Redis Enterprise Cluster, use the credentials that you extracted above. By now, you should be able to see three nodes of the Redis Enterprise cluster.
RedisEnterpriseDatabase is the schema for the redisenterprisedatabases API. To create REDB, navigate to Installed Operator > Redis Enterprise Operator > Redis Enterprise Database and click “Create RedisEnterpriseDatabase” to start the creation process using REDB custom resource. You can click on “YAML” and paste the sample YAML file below:
For configuring any additional parameters for the Redis Enterprise Database custom resource, visit this page.
Once the REDB creation is done, you should see the status as “active”.
Finally, navigate to Redis Enterprise Cluster admin console to verify if Redis Enterprise database is created or not.
Click on the newly created database and then click on configuration option to see the overall details.
Navigate back to the OpenShift console and verify the service object created for the Redis Database.
Select “Routes” from the left-hand column and create a new route object for this database service with the sample YAML file below:
Note the Host name 'my-db-hostname' from the created route object.
Note the database password "my-db-password" from the database secret object with name “db-name-redb”.
Get the default CA certificate from the redis-enterprise-node container on any of the Redis Enterprise pods and paste the output in a file called “proxy_cert.pem”.
Run the following openssl command, substituting your own values for 'my-db-hostname'.
Authorize the database with the password and enter the ping command. If you are connected to the database, you will receive PONG back, as shown below:
You can use the code below to test your access with Python, substituting your own values for 'my-db-hostname' and 'file-path'.
Your output should look something like this:
In our next tutorial, we will learn how to deploy a sample Real-time chat application powered by Go and Redis on OpenShift.