Categories
Containers OpenShift Red Hat

PostgreSQL on OpenShift 4.x

I had a little side project that used a PostgreSQL database for the backend and was initially deployed on a virtual machine. Well we wanted to modernize the deployment and move the database to OpenShift 4.6 using containers. In this post I will detail a quick and dirty way to take a PostgreSQL backup file and restore on top of OCP.

We will do the first half of this tutorial using the web ui and wrap it up with the cli. From the developer view we will click add from the left menu and select database.

Now we will look for PostgreSQL in the developer catalog and select it. Note we want to use the option without ephemeral in it’s name.

Next we are prompted with our template options before deployment. Go ahead and fill out this information according to your needs and click create. Do note the default as of 11/9/2020 deploys PostgreSQL 10.8 but we can change the version of the PostgreSQL image used to latest to get version 12.

Finally we are going to switch to the cli and import or backup that we made using pgdump. Once you are logged into oc you will want to run the following command.

oc get pods

Ignore the pod ending in deploy with status completed, what we want is the running container that ends in 5 random characters. Now let’s setup a port-forward to our local machine with the pgdump file in hand.

oc port-forward my-database-54dfv 5432:5432

Where the my-database-54dfv is the name we obtained from the oc get pods command we ran earlier and the ports are local:remote so if you want to change the local port you may if you are doing this from the actual VM already running PostgreSQL.

Once we have the port-forward setup for our local machine now we just need to import our database backup with the following.

psql database-name username --host 127.0.0.1 < /path/to/pgdump-file

Congrats you should now have your database restored and running in a container that can be accessed by the service name you provided during creation.

-Mike

Categories
Containers OpenShift RHEL

OpenShift Origin 3.11 on RHEL 7

OpenShift Origin (OKD) 3.11 on a single node while using RHEL 7 can be a bit different than the CentOS 7 install. In this article I will cover those instructions. We will assume you have installed the latest version of RHEL 7 on your node that you will be deploying on.

From there you will want to log in and update the system after enabling the repos we need.

sudo subscription-manager repos --disable "*"

sudo subscription-manager repos --enable=rhel-7-server-rpms --enable=rhel-7-server-extras-rpms

sudo yum update -y

Next we will install the dependencies we need to continue followed by a reboot.

sudo yum install -y python3-pip python-devel git && sudo yum group install -y "Development Tools" && sudo reboot

Now that we have our dependencies installed and our system up to date we will want to clone the openshift-ansible install from github.

git clone https://github.com/openshift/openshift-ansible
cd openshift-ansible
git checkout release-3.11

Now we will install the python dependencies using pip we installed earlier.

sudo pip3 install -r requirements.txt

Finally we run the two playbooks needed to deploy the standalone 3.11 version of OpenShift on RHEL 7.

sudo /usr/local/bin/ansible-playbook -i inventory/hosts.localhost playbooks/prerequisites.yml
sudo /usr/local/bin/ansible-playbook -i inventory/hosts.localhost playbooks/deploy_cluster.yml

Enjoy your OpenShift Origin 3.11 test environment on RHEL 7!

Categories
CentOS Containers Linux OpenShift

OpenShift Origin 3.11 on CentOS 7

I had a friend who was having some issues with installing OpenShift Origin (OKD) 3.11 on a single node so I took to documenting my steps taken for my test deployment. We will assume you have installed the latest version of CentOS on your node that you will be deploying on.

From there you will want to log in and update the system.

sudo yum update -y

Next we will install the dependencies we need to continue followed by a reboot.

sudo yum install -y epel-release && sudo yum install -y python-pip python-devel git && sudo yum group install -y "Development Tools" && sudo reboot

Now that we have our dependencies installed and our system up to date we will want to clone the openshift-ansible install from github.

git clone https://github.com/openshift/openshift-ansible
cd openshift-ansible
git checkout release-3.11

Now we will install the python dependencies using pip we installed earlier.

sudo pip install -r requirements.txt

Finally we run the two playbooks needed to deploy the standalone 3.11 version of OpenShift on CentOS 7.

sudo ansible-playbook -i inventory/hosts.localhost playbooks/prerequisites.yml
sudo ansible-playbook -i inventory/hosts.localhost playbooks/deploy_cluster.yml

Enjoy your OpenShift Origin 3.11 test environment!