This article explains the steps you can take to build an OpenShift environment on a Centos 7.7 VM image on your desktop using VMware.
You can also apply it to deploy on AWS, IBM, or Azure Cloud Infrastructure as a service deployment.
The below instructions will have you deploy a Db2 as a service on OpenShift in an environment that is perfect for development and demonstration purposes. The Db2 install will be a licensed community edition that is fully featured but limited to 4 cores—more than enough for desktop development.
The service that is being deployed is the basis of IBM Db2 Warehouse on Cloud and Db2 OLTP Services for IBM’s Cloud Pak for Data.
Prerequisites
You should have resources of at least 16GB of ram and 5 cores for your VM and reserve 50-60GB of space for the image. A good internet connection is also required—at least 50 Mbps—as certain steps may time out as the install waits to download required code and containers.
Create your image and environment for installing OpenShift and Db2
1. Build a Centos Image 7.7
You can source a version here.
Note: When Centos installs, it does not automatically enable network access. Make sure you enable it as part of your install. Also, when selecting Software Installation options, choose an install type and install a development desktop with system tools, Python, and development tools. This will ensure the right server components are there to install OpenShift and that you have an environment friendly for desktop development.
See this link for more details on installation.
2. Create a user called “db2shift” using the install UI
During installation, you can define the root password and a second user—“db2shift”—and select it to be a system administrator (AKA member of the wheel group).
3. Create a user called “db2shift” (alternative command line approach)
If you prefer the command line, follow these steps:
- Add a linux user:
- Give the user a password:
- Give the user access to the wheel and root privileges:
- Switch to the db2shift user-id:
4. Install single-node OpenShift cluster
- Update your system with the required tools to install OpenShift:
- Load the dependencies for OpenShift:
- Clone the OpenShift Ansible Install github repository—first, log back into the image as db2shift after the machine reboots:
- Install python dependencies for Ansible Install:
- Install a single-node version of OpenShift 3.11:
Note: If the second step fails, you can re-run from the second step again. The problem could be that your network bandwidth is causing a time out on downloading some components in OpenShift. If, for some reason, you have environmental issues while using your environment, you can re-run these steps to restart your image. I always suggest that if you are using VMware, this is a good point to take a backup of your environment. More details on this process can be found at Michael Tipton’s blog.
5. Set up admin user for OpenShift
- Install password tools:
- Add admin to admin group on the cluster:
6. Install Helm
- Create the Tiller project:
- Install and deploy Tiller:
- Install Tiller and check the progress:
7. Set up OpenShift for Db2
- Set Container_group_permissions:
- Set up Hostpath directory:
- Give the directory the permissions it requires to be managed as a Hostpath volume:
8. Build the Db2 project
- Create and prepare the Db2 project:
- Clone the Github project:
9. Apply Db2 security, permissions, and local storage
- Apply Db2 administrative bindings and SCC:
- Enable Db2 SCC to allow privileges to work with Hostpath storage and add SCC to Service Account:
- Create Db2 volume and claim:
- Place the following
db2vol.yaml
in home directory: - Apply the volume and PVC definitions:
- Place the following
10. Get up and running
- Run Db2 install:
Note: If, during this state, you get back-off messages when running the
oc get pods
command, do not worry—this is likely be because your network connection is slow and the jobs time out waiting for the Db2 containers to download. They may do this until all containers are downloaded. - Monitor the deployment until the db2u-db2u-0 pod is running with a status of 1/1:
- You can use the following command from your command line to determine the status:
- Monitoring through the console (login with user ID: admin and password: redhat). Go to the Db2 Project and select the Applications -> Pods and you will see the following:
Connecting to Db2
Run the following command:
Note: Db2 exposes its service externally via the db2u-db2u-engn-svc service. In this case, 31020 is the non-SSL port Db2 will be listening on, and 31578 is the port that will support SSL connectivity. They are mapped to the db2u-db2u-0 50000/50001 ports that Db2 operates on.
To get your IP address for your server for external communication, use the following (if you are running on VMware):
Alternatively, you can just type “ip addr show” and it should be the IP address of the second device listed. This will provide you the IP address your OpenShift node will be listening on, external and internal to the VM.
In my example, I can now connect to Db2 and then on 192.168.154.132 port 31020 from my desktop (make sure any firewalls on your desktop allow your VM to be reachable).
You can also connect to the OpenShift Console using your IP address and port 8443. For example, for the system above, the address would be https://192.168.154.132:8443.