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:
dwe@dwe:/opt$ minishift delete dwe@dwe:/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:
dwe@dwe:/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:
dwe@dwe:~$ 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 docker@minishift:~$ 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 docker@minishift:~$ docker login containers.enterprisedb.com Username: dbi-services Password: Login Succeeded docker@minishift:~$ 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 docker@minishift:~$ docker tag containers.enterprisedb.com/edb/edb-as:v10.3 localhost:5000/edb/edb-as:v10.3 docker@minishift:~$ docker push localhost:5000/edb/edb-as:v10.3 The push refers to a repository [localhost:5000/edb/edb-as] 274db5c4ff47: Preparing ... docker@minishift:~$ docker pull containers.enterprisedb.com/edb/edb-pgpool:v3.5 v3.5: Pulling from test/edb-pgpool ... docker@minishift:~$ docker tag containers.enterprisedb.com/edb/edb-pgpool:v3.5 localhost:5000/edb/edb-pgpool:v3.5 docker@minishift:~$ 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:
dwe@dwe:~$ 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:
dwe@dwe:~$ 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.