Skip to content

Commit

Permalink
postgres pgo 5
Browse files Browse the repository at this point in the history
  • Loading branch information
wardviaene committed Feb 17, 2022
1 parent 1d3ecde commit 895ec81
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 700 deletions.
40 changes: 18 additions & 22 deletions postgres-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,46 @@ kubectl create -f storage.yml
# setup Operator
```
./quickstart.sh
./set-path.sh
```

After these commands you'll need to logout and login again.

# port forwarding

```
kubectl get pods -n pgo
kubectl port-forward -n pgo postgres-operator-xxx-yyy 8443:8443
```

# Test command
# Create cluster

```
pgo version
kubectl apply -f postgres-example.yaml
```

# Create cluster
# Show cluster pods

```
pgo create cluster mycluster
kubectl get pods -n postgres-operator
```

# show secrets
```
pgo show cluster mycluster
kubectl get secrets -n postgres-operator hippo-pguser-hippo -o yaml |grep user |cut -d ':' -f2 |cut -d ' ' -f2 |base64 --decode
kubectl get secrets -n postgres-operator hippo-pguser-hippo -o yaml |grep password |cut -d ':' -f2 |cut -d ' ' -f2 |base64 --decode
kubectl get secrets -n postgres-operator hippo-pguser-hippo -o yaml |grep host |cut -d ':' -f2 |cut -d ' ' -f2 |base64 --decode
```

# connect to psql

Use user, password, and host from previous step.

```
pgo show user mycluster
kubectl run -it --rm --image=postgres:10.4 psql-client -- psql -h mycluster.pgo -U testuser -W postgres
kubectl run -n postgres-operator -it --rm --image=postgres:10.4 psql-client -- psql -h hippo-primary.postgres-operator.svc -U hippo -W postgres
```

Note: When you see 'If you don't see a command prompt, try pressing enter.', you can enter the password


# Create read replic
Once you add replicas: 2 to the yaml definition, and you apply it, you'll see the new replica being spun up
```
pgo scale mycluster
kubectl apply -f postgres-example-scale.yaml
kubectl get pods -n postgres-operator
```

# manually failover
# Shutdown cluster
```
pgo failover mycluster --query
pgo failover mycluster --target=mycluster-xxx
kubectl get pgtasks mycluster-failover -o yaml
kubectl patch postgrescluster/hippo -n postgres-operator --type merge --patch '{"spec":{"shutdown": true}}'
```
80 changes: 0 additions & 80 deletions postgres-operator/client-setup.sh

This file was deleted.

29 changes: 29 additions & 0 deletions postgres-operator/postgres-example-scale.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PostgresCluster
metadata:
name: hippo
namespace: postgres-operator
spec:
image: registry.developers.crunchydata.com/crunchydata/crunchy-postgres:centos8-13.5-0
postgresVersion: 13
instances:
- name: instance1
replicas: 2
dataVolumeClaimSpec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: 1Gi
backups:
pgbackrest:
image: registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:centos8-2.36-0
repos:
- name: repo1
volume:
volumeClaimSpec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: 1Gi
28 changes: 28 additions & 0 deletions postgres-operator/postgres-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PostgresCluster
metadata:
name: hippo
namespace: postgres-operator
spec:
image: registry.developers.crunchydata.com/crunchydata/crunchy-postgres:centos8-13.5-0
postgresVersion: 13
instances:
- name: instance1
dataVolumeClaimSpec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: 1Gi
backups:
pgbackrest:
image: registry.developers.crunchydata.com/crunchydata/crunchy-pgbackrest:centos8-2.36-0
repos:
- name: repo1
volume:
volumeClaimSpec:
accessModes:
- "ReadWriteOnce"
resources:
requests:
storage: 1Gi
Loading

0 comments on commit 895ec81

Please sign in to comment.