-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Source code for postgres operator walkthrough
- Loading branch information
0 parents
commit 76b40c3
Showing
3 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM centos | ||
COPY ./test.sh /test.sh | ||
RUN chmod +x /test.sh | ||
RUN curl -L https://github.com/CrunchyData/postgres-operator/releases/download/3.0/postgres-operator.3.0.tar.gz | tar xvz ./pgo ./conf/* | ||
RUN mv pgo /usr/local/bin | ||
|
||
CMD /test.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: mypod | ||
labels: | ||
name: postgres-operator | ||
namespace: demo | ||
spec: | ||
containers: | ||
- name: psql-container | ||
image: postgres | ||
command: ['sh', '-c', 'sleep 3600'] | ||
env: | ||
- name: PGUSER | ||
valueFrom: | ||
secretKeyRef: | ||
name: mycluster-postgres-secret | ||
key: username | ||
- name: PGPASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: mycluster-postgres-secret | ||
key: password | ||
initContainers: | ||
- name: init-pgo | ||
image: quay.io/guineveresaenger/guinstest:latest | ||
imagePullPolicy: Always | ||
env: | ||
- name: CO_APISERVER_URL | ||
value: https://postgres-operator.demo.svc.cluster.local:8443 | ||
- name: PGOUSER | ||
value: username | ||
- name: PGO_CA_CERT | ||
value: /conf/apiserver/server.crt | ||
- name: PGO_CLIENT_CERT | ||
value: /conf/apiserver/server.crt | ||
- name: PGO_CLIENT_KEY | ||
value: /conf/apiserver/server.key | ||
|
||
--- | ||
|
||
apiVersion: batch/v1beta1 | ||
kind: CronJob | ||
metadata: | ||
name: backup | ||
spec: | ||
schedule: "*/5 * * * *" | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: pgo-backup | ||
image: quay.io/guineveresaenger/guinstest:latest | ||
command: ['sh', '-c', 'echo username:password > ~/.pgouser && echo backing up: && pgo backup mycluster'] | ||
env: | ||
- name: CO_APISERVER_URL | ||
value: https://postgres-operator.demo.svc.cluster.local:8443 | ||
- name: PGOUSER | ||
value: username | ||
- name: PGO_CA_CERT | ||
value: /conf/apiserver/server.crt | ||
- name: PGO_CLIENT_CERT | ||
value: /conf/apiserver/server.crt | ||
- name: PGO_CLIENT_KEY | ||
value: /conf/apiserver/server.key | ||
restartPolicy: OnFailure | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/sh | ||
echo Pgo lives in usr/local/bin: | ||
command -v pgo | ||
alias pgo=/usr/local/bin/pgo | ||
echo "username:password" > ~/.pgouser | ||
echo Pgo version: | ||
pgo version | ||
pgo create cluster mycluster | ||
echo Showing the cluster... | ||
pgo show cluster mycluster |