Running a PostgreSQL app in Openshift & connecting to it!
This blog aims to create an application of PostgreSQL database into Openshift, & then connect to the database running in that application.
Postgresql is one of the most famous databases available & Openshift is the best tool available in the market for container orchestration. Therefore, working with both will be the best thing to do.
Let’s get started with it then.
Creating a Postgres Application in Openshift!
Any Openshift Environment can be used for the application deployment, whether cloud-based, on-premises, or playground based. Once you have the Openshift Environment ready with you, then you just have to perform the following steps to launch the Postgres application.
- Execute the below-mentioned command to run a Postgres application with the username & password of your choice, & make sure you remember these details or you can note it down somewhere.
# You can substitute your username & password in the below command!
oc new-app --image=postgres --name=database -e POSTGRES_USER=harshitdawar -e POSTGRES_PASSWORD=postgres
2. You can run the below command to confirm whether the pod is running or not.
oc get pods
3. Copy the pod name from the output of the above command & run the below command to connect to the pod.
oc rsh <pod name>
4. Running psql & listing the databases in it to verify the installation.
# Run the below command with the username that you have entered while creating the application!
"psql -U <username> -W"
psql -U harshitdawar -W
This completes the goal of the blog. Congratulations, you have now working Postgres application with you.
I hope my article explains each and everything related to the topic with all the detailed concepts and explanations. Thank you so much for investing your time in reading my blog & boosting your knowledge. If you like my work, then I request you to applaud this blog & follow me on Medium, GitHub, & LinkedIn for more amazing content on multiple technologies and their integration!
Also, subscribe to me on Medium to get updates on all my blogs!