![]() ![]() Always run the latest version of Postgres without having to manage software updates.In the following gif you see the result of the steps above in a OpenShift cluster on IBM Cloud.So you want to spin up a Postgres database on your local machine, but you don't fancy having to install and manage everything manually? Running Postgres inside Docker is a great way to simplify the situation. The last step is to expose the service, so that we can access our database with our sample application.Oc start-build build-postgres -from-dir=. ![]() ![]() Now it’s time to start the build and then directly apply the Kubernetes Deployment and a Kubernetes Service specification in the postgres-oc.yaml.Oc new-build -name build-postgres -binary -strategy docker The reason why we don’t use the same name as for the Deployment and Service, you remember the name is database-articles, is: later we maybe want to automate the deployment to OpenShift with a bash script and it that bash script we will use grep and awk to verify the oc CLI outputs to get the status of the deployment. The name of the configuration is build-postgres. Then we create a OpenShift build configuration.To separate the postgreSQL database from the Cloud Native Starter example application, we create an additional project called postgres in OpenShift.Image: :5000/postgres/build-postgres:latestĪpp: database-articles Deploy postgreSQL with the oc CLI commands You find the definition for that environment configuration in the postgreSQL Docker image on dockerhub. The needed env settings for the postgreSQL container to create the database in the container are defined in the .env Deployment section of the yaml. As you see in the yaml extract below the name is database-articles, that’s needed by our Cloud Native Starter example application. In the Deployment and Service specification for OpenShift we need to define the name for the Pod and Service. USER non-root-postgres The Kubernetes Deployment and Kubernetes Service specification ![]() RUN chown -R non-root-postgres-user:non-root-postgres-group /temp # Set user rights to allow the on-root-postgres-user RUN useradd non-root-postgres-user -group non-root-postgres-group # Create the needed temp file before the first postgreSQL execution To run the container later as non root we change the user for the execution to the non-root-postgres-user . That user get’s all access rights to the /temp folder to create the needed database files in the container. The user is called non-root-postgres-user. In the content of the Dockerfile below you see, that it specifies a non-root user and group. Specifications and configurations Dockerfile
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |