This blog refers to an older version of EDB’s Postgres on Kubernetes offering that is no longer available.
In this post we’ll look at how we can deploy EnterpriseDB containers in MiniShift. When you need to setup MiniShift have a look here. In this post we’ll do the setup with the MiniShift console, in a next post we’ll do the same by using the command line tools.
As a few containers will be running at the end MiniShift got more resources when it was started:
[email protected]:/opt$ minishift delete [email protected]:/opt$ minishift start --cpus 4 --disk-size 30GB --memory 4GB
Once MiniShift is up and running open the MiniShift console and login as developer/admin:
[email protected]:/opt$ minishift console
The first thing we need to do is to grant the necessary permissions after we stepped into “My Project”:
The permission are in Resources->Membership. Add admin,edit and view to the default account:
For accessing the EnterpriseDB container repository a new secret needs to be created which contains the connection details. Secrets are under Resources->Secrets:
As databases are happy when they can store their data on persistent storage we need a volume. Volumes can be created under “Storage”:
Now we need a local registry where we can push the EnterpriseDB containers to:
[email protected]:~$ minishift ssh ## . ## ## ## == ## ## ## ## ## === /"""""""""""""""""\___/ === ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~ \______ o __/ \ \ __/ \____\_______/ _ _ ____ _ _ | |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __ | '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__| | |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ | |_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_| Boot2Docker version 1.12.6, build HEAD : 5ab2289 - Wed Jan 11 03:20:40 UTC 2017 Docker version 1.12.6, build 78d1802 [email protected]:~$ docker run -d -p 5000:5000 --restart=always --name registry registry:2 Unable to find image 'registry:2' locally 2: Pulling from library/registry 81033e7c1d6a: Pull complete ... Status: Downloaded newer image for registry:2 14e85f4e2a36e727a0584803e49bbd690ffdb092c02238a241bd2ad003680625 [email protected]:~$ docker login containers.enterprisedb.com Username: dbi-services Password: Login Succeeded [email protected]:~$ docker pull containers.enterprisedb.com/edb/edb-as:v10.3 v10.3: Pulling from test/edb-as d9aaf4d82f24: Pulling fs layer ... Status: Downloaded newer image for containers.enterprisedb.com/edb/edb-as:v10.3 [email protected]:~$ docker tag containers.enterprisedb.com/edb/edb-as:v10.3 localhost:5000/edb/edb-as:v10.3 [email protected]:~$ docker push localhost:5000/edb/edb-as:v10.3 The push refers to a repository [localhost:5000/edb/edb-as] 274db5c4ff47: Preparing ... [email protected]:~$ docker pull containers.enterprisedb.com/edb/edb-pgpool:v3.5 v3.5: Pulling from test/edb-pgpool ... [email protected]:~$ docker tag containers.enterprisedb.com/edb/edb-pgpool:v3.5 localhost:5000/edb/edb-pgpool:v3.5 [email protected]:~$ docker push localhost:5000/edb/edb-pgpool:v3.5 The push refers to a repository [localhost:5000/edb/edb-pgpool] 8a7df26eb139: Pushed ...
This is all what is required for the preparation. The next step is to import to the template which specifies the setup. For this little demo we’ll use this one:
apiVersion: v1 kind: Template metadata: name: edb-as10-0 annotations: description: "Standard EDB Postgres Advanced Server 10.0 Deployment Config" tags: "database,epas,postgres,postgresql" iconClass: "icon-postgresql" objects: - apiVersion: v1 kind: Service metadata: name: ${DATABASE_NAME}-service labels: role: loadbalancer cluster: ${DATABASE_NAME} spec: selector: lb: ${DATABASE_NAME}-pgpool ports: - name: lb port: ${PGPORT} targetPort: 9999 sessionAffinity: None type: LoadBalancer - apiVersion: v1 kind: DeploymentConfig metadata: name: ${DATABASE_NAME}-pgpool spec: replicas: 2 selector: lb: ${DATABASE_NAME}-pgpool strategy: resources: {} rollingParams: intervalSeconds: 1 maxSurge: 25% maxUnavailable: 25% timeoutSeconds: 600 updatePeriodSeconds: 1 type: Rolling template: metadata: labels: lb: ${DATABASE_NAME}-pgpool role: queryrouter cluster: ${DATABASE_NAME} spec: containers: - name: edb-pgpool env: - name: DATABASE_NAME value: ${DATABASE_NAME} - name: PGPORT value: ${PGPORT} - name: REPL_USER value: ${REPL_USER} - name: ENTERPRISEDB_PASSWORD value: 'postgres' - name: REPL_PASSWORD value: 'postgres' - name: ACCEPT_EULA value: ${ACCEPT_EULA} image: containers.enterprisedb.com/edb/edb-pgpool:v3.5 imagePullPolicy: IfNotPresent readinessProbe: exec: command: - /var/lib/edb/testIsReady.sh initialDelaySeconds: 60 timeoutSeconds: 5 triggers: - type: ConfigChange - apiVersion: v1 kind: DeploymentConfig metadata: name: ${DATABASE_NAME}-as10-0 spec: replicas: 1 selector: db: ${DATABASE_NAME}-as10-0 strategy: resources: {} rollingParams: intervalSeconds: 1 maxSurge: 25% maxUnavailable: 25% timeoutSeconds: 600 updatePeriodSeconds: 1 type: Rolling template: metadata: creationTimestamp: null labels: db: ${DATABASE_NAME}-as10-0 cluster: ${DATABASE_NAME} spec: containers: - name: edb-as10 env: - name: DATABASE_NAME value: ${DATABASE_NAME} - name: DATABASE_USER value: ${DATABASE_USER} - name: DATABASE_USER_PASSWORD value: 'postgres' - name: ENTERPRISEDB_PASSWORD value: 'postgres' - name: REPL_USER value: ${REPL_USER} - name: REPL_PASSWORD value: 'postgres' - name: PGPORT value: ${PGPORT} - name: RESTORE_FILE value: ${RESTORE_FILE} - name: LOCALEPARAMETER value: ${LOCALEPARAMETER} - name: CLEANUP_SCHEDULE value: ${CLEANUP_SCHEDULE} - name: EFM_EMAIL value: ${EFM_EMAIL} - name: NAMESERVER value: ${NAMESERVER} - name: POD_NAMESPACE valueFrom: fieldRef: fieldPath: metadata.namespace - name: POD_NODE valueFrom: fieldRef: fieldPath: spec.nodeName - name: POD_IP valueFrom: fieldRef: fieldPath: status.podIP - name: ACCEPT_EULA value: ${ACCEPT_EULA} image: containers.enterprisedb.com/edb/edb-as:v10.3 imagePullPolicy: IfNotPresent readinessProbe: exec: command: - /var/lib/edb/testIsReady.sh initialDelaySeconds: 60 timeoutSeconds: 5 livenessProbe: exec: command: - /var/lib/edb/testIsHealthy.sh initialDelaySeconds: 600 timeoutSeconds: 60 ports: - containerPort: ${PGPORT} volumeMounts: - name: ${PERSISTENT_VOLUME} mountPath: /edbvolume dnsPolicy: ClusterFirst restartPolicy: Always volumes: - name: ${PERSISTENT_VOLUME} persistentVolumeClaim: claimName: ${PERSISTENT_VOLUME_CLAIM} triggers: - type: ConfigChange parameters: - name: DATABASE_NAME displayName: Database Name description: Name of Postgres database (leave edb for default) value: 'edb' - name: DATABASE_USER displayName: Default database user (leave enterprisedb for default) description: Default database user value: 'enterprisedb' - name: REPL_USER displayName: Repl user description: repl database user value: 'repl' - name: PGPORT displayName: Database Port description: Database Port (leave 5444 for default) value: "5444" - name: LOCALEPARAMETER displayName: Locale description: Locale of database value: '' - name: CLEANUP_SCHEDULE displayName: Host Cleanup Schedule description: Standard cron schedule - min (0 - 59), hour (0 - 23), day of month (1 - 31), month (1 - 12), day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0). Leave it empty if you dont want to cleanup. value: '0:0:*:*:*' - name: EFM_EMAIL displayName: Email description: Email for EFM value: '[email protected]' - name: NAMESERVER displayName: Name Server for Email description: Name Server for Email value: '8.8.8.8' - name: PERSISTENT_VOLUME displayName: Persistent Volume description: Persistent volume name value: '' required: true - name: PERSISTENT_VOLUME_CLAIM displayName: Persistent Volume Claim description: Persistent volume claim name value: '' required: true - name: RESTORE_FILE displayName: Restore File description: Restore file location value: '' - name: ACCEPT_EULA displayName: Accept end-user license agreement (leave 'Yes' for default) description: Indicates whether user accepts the end-user license agreement value: 'Yes' required: true
For importing that into OpenShift go to “Overview” and select “Import YAML/JSON”:
This imports the template but does not process it right now. When you go back to “Overview” you should see a new template which you can provision:
Selecting the new template brings you to the specification of the variables. The only bits you need to adjust are the values for the volume and the volume claim:
A few moments later the EDB containers are up and running:
[email protected]:~$ oc get pods NAME READY STATUS RESTARTS AGE edb-as10-0-1-fdr5j 1/1 Running 0 1m edb-pgpool-1-9twmc 1/1 Running 0 1m edb-pgpool-1-m5x44 1/1 Running 0 1m
Current there are two pgpool instances and one database instance container. You can double check that the instance is really running with:
[email protected]:~$ oc rsh edb-as10-0-1-fdr5j sh-4.2$ psql postgres psql.bin (10.3.8) Type "help" for help. postgres=# select version(); version ------------------------------------------------------------------------------------------------------------- EnterpriseDB 10.3.8 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16), 64-bit (1 row)
Going back to the “Overview” page in the console shows the same information:
In the next post we’ll scale up the deployment by adding two replicas and configure access from outside the cluster.
Why would you want to setup local registry if it is not being used?
Hi Tomaz,
you mean because the EDB registry is referenced in the template? You’re right, I should have mentioned that. Thanks for pointing that out.
Cheers,
Daniel
Hi Daniel,
Thanks for the handy steps.
Just a question: Is there any reason for not setting up BART container in this demo/blog?
What are the steps needed for the same?
Thanks,
Alok
Hi Alok,
check here: https://blog.dbi-services.com/backing-up-and-restoring-edb-containers-in-minishiftopenshift/
The goal was to go step by step.
Cheers,
Daniel
Hi Daniel,
I’ve one more question here: Could you please paste the contents of your yaml file here for PV creation? What is the name of PV in this case?
I want to see how you are binding mountPath (/edbvolume) to a PV; and the name of the PV?
Thanks again.
… will provide that tomorrow, but it is also mentioned in the bart post
Cheers,
Daniel
Thanks, Daniel. Sorry, I could not notice that before sending a comment.
Excellent post.
Thanks, Daniel.
In the BART post, you have used a PV (pv0060) for persistent backup, however, you have not shown how the binding is done (using pv0060) with /edbbackup mountPath.
To understand that same please if you could provide yaml file for PV and PVC for BART; or you can show me the steps you have followed for the same.
Thanks in advance for your help.
When I try and log in (below) it states the user name and password are not correct. Isn’t the user name and password to supply the credentials created within the earlier generated secret? I’d love to continue through these blogs but I’m stuck at this point. Thanks for your assistance.
Status: Downloaded newer image for registry:2
14e85f4e2a36e727a0584803e49bbd690ffdb092c02238a241bd2ad003680625
[email protected]:~$ docker login containers.enterprisedb.com
Username: dbi-services
Password:
Hi Aaron,
you need to request your own login to the EDB repository from EDB.
Cheers,
Daniel
hi,,,i requested a trial license key to evaluate Cloud Native PostgreSQL by EDB and I received the details. I also mentioned my cluster name while applying. What are my next steps to be able to run this on my openshift cluster?
Hi,
I haven’t looked at the new container solution yet.
Best regards
Daniel