Skip to content

Commit 4e63d51

Browse files
Merge pull request #120 from xenophenes/master
misc. minor documentation changes
2 parents 9b5e591 + 735f5dd commit 4e63d51

File tree

1 file changed

+75
-67
lines changed

1 file changed

+75
-67
lines changed

docs/operator-docs.asciidoc

Lines changed: 75 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
= PostgreSQL Operator Documentation
1+
= PostgreSQL Operator Documentation
22
:toc:
33
v2.5, {docdate}
44

@@ -14,14 +14,14 @@ from source, you can download them from the following:
1414
Further details can be found in the link:design.asciidoc[PostgreSQL Operator Design] document on
1515
how the operator is built and how it operates.
1616

17-
For most users of the Operator who simply want to deploy
18-
it on a running Kube cluster will find the Quickstart
19-
script useful https://github.com/CrunchyData/postgres-operator/blob/master/examples/quickstart.sh
17+
For most users of the Operator who simply want to deploy
18+
it on a running Kubernetes cluster will find the link:https://github.com/CrunchyData/postgres-operator/blob/master/examples/quickstart.sh[Quickstart]
19+
script useful.
2020

2121
Executing that script will deploy the Operator to your Kube
2222
cluster and also set up your local user environment with the
2323
*pgo* client in about 10 seconds. More details on the Quickstart
24-
is at the end of this document <<Quickstart>>.
24+
script is located in the <<Quickstart>> section in this document.
2525

2626

2727
== Requirements
@@ -35,7 +35,7 @@ these versions.
3535
* *OpenShift Origin 1.7.0+*
3636

3737
The operator is developed with the Golang versions great than or equal to version 1.8 See
38-
link:https://golang.org/dl/[Golang website] for details on installing golang.
38+
link:https://golang.org/dl/[Golang website] for details on installing golang.
3939

4040
Pre-compiled versions of the Operator *pgo* client are provided for the x86_64, Mac OSX, and Windows hosts.
4141

@@ -88,6 +88,13 @@ export PGO_CLIENT_CERT=$COROOT/conf/apiserver/server.crt
8888
export PGO_CLIENT_KEY=$COROOT/conf/apiserver/server.key
8989
....
9090

91+
It will be necessary to refresh your .bashrc file in order for the changes to take
92+
effect.
93+
94+
....
95+
source ~/.bashrc
96+
....
97+
9198
The value of CO_IMAGE_PREFIX is used to prefix the Operator
9299
Docker images. For example, set this environment variable
93100
to where you have your Operator images loaded either locally (crunchydata)
@@ -155,7 +162,7 @@ tar xvzf ./postgres-operator.2.5.tar.gz
155162

156163
Lastly, add the *pgo* client into your PATH.
157164

158-
You are now ready to Deploy the operator to your Kube system.
165+
You are now ready to Deploy the operator to your Kubernetes system.
159166

160167
=== Build from Source
161168

@@ -195,7 +202,7 @@ kubectl config use-context demo
195202
kubectl config current-context
196203
....
197204

198-
Permissions are granted to the Operator by means of a
205+
Permissions are granted to the Operator by means of a
199206
Service Account called *postgres-operator*. That service
200207
account is added to the Operator deployment.
201208

@@ -233,14 +240,14 @@ To run the Operator on Openshift Container Platform note the following:
233240
=== Configure Persistent Storage
234241

235242
The default Operator configuration is defined to use a HostPath
236-
persistence configuration.
243+
persistence configuration.
237244

238245
There are example scripts provided that will create PV and PVC resources
239-
that can be used in your testing.
246+
that can be used in your testing.
240247

241-
These example scripts can create sample HostPath and NFS volumes.
248+
These example scripts can create sample HostPath and NFS volumes.
242249

243-
To create sample HostPath Persistent Volumes and CLaims use the following scripts:
250+
To create sample HostPath Persistent Volumes and Claims use the following scripts:
244251
....
245252
cd $COROOT/pv
246253
./create-pv.sh
@@ -274,7 +281,7 @@ username:password
274281
testuser:testpass
275282
....
276283

277-
Modify these values to be unique to your environment.
284+
Modify these values to be unique to your environment.
278285

279286
If the username and password passed by clients to the *apiserver* do
280287
not match, the REST call will fail and a log message will be produced
@@ -332,16 +339,17 @@ this value is set to *false* if you do not specify a value.
332339
PostgreSQL passwords are defined in Secrets starting with release
333340
2.5. When the *pgo-apiserver* starts, it will read the passwords
334341
to be used for PostgresSQL clusters from the following Kube Secrets:
342+
335343
* pgo-postgres-user-pass
336344
* pgo-primary-user-pass
337345
* pgo-testuser-user-pass
338346

339347
The defaults for these Secrets are set in the *create-secrets.sh* script
340-
which is executed during the postgres-operator deployment.
348+
which is executed during the postgres-operator deployment.
341349

342350
=== Configuration
343351

344-
The *apiserver* uses the following configuration files found in $COROOT/conf/apiserver to determine how the Operator will provision PostgreSQL containers:
352+
The *apiserver* uses the following configuration files found in $COROOT/conf/apiserver to determine how the Operator will provision PostgreSQL containers:
345353
....
346354
$COROOT/conf/apiserver/pgo.yaml
347355
$COROOT/conf/apiserver/pgo.lspvc-template.json
@@ -351,11 +359,8 @@ $COROOT/conf/apiserver/pgo.load-template.json
351359
Note that the default *pgo.yaml* file assumes you are going to use *HostPath* Persistent Volumes for
352360
your storage configuration. Adjust this file for NFS or other storage configurations.
353361

354-
Note that the *pgo.yaml* configuration file assumes your Kubernetes configuration file is located in */etc/kubernetes/admin.conf*. Update this kubeconfig
355-
path to match your local Kubernetes configuration file location.
356-
357362
The version of PostgreSQL container the Operator will deploy is determined
358-
by the *CCPImageTag* setting in the *$COROOT/conf/apiserver/pgo.yaml*
363+
by the *CCPImageTag* setting in the *$COROOT/conf/apiserver/pgo.yaml*
359364
configuration file. By default, this value is set to the latest
360365
release of the Crunchy Container Suite.
361366

@@ -402,9 +407,9 @@ Strategies for deploying the operator can be found in the link:design.asciidoc[P
402407

403408
=== Verify Installation
404409

405-
When you first run the operator, it will look for the presence of the
406-
predefined custom resource definitions, and create them if not found.
407-
The best way to verify a successful deployment of the Operator is by
410+
When you first run the operator, it will look for the presence of the
411+
predefined custom resource definitions, and create them if not found.
412+
The best way to verify a successful deployment of the Operator is by
408413
viewing these custom resource definitions:
409414

410415
....
@@ -425,7 +430,7 @@ name of the *postgres-operator* service or to the IP address of the
425430
export CO_APISERVER_URL=https://10.105.56.167:8443
426431
....
427432

428-
or if you have DNS configured on your client host:
433+
Or if you have DNS configured on your client host:
429434
....
430435
export CO_APISERVER_URL=https://postgres-operator.demo.svc.cluster.local:8443
431436
....
@@ -478,10 +483,10 @@ The following table describes the Makefile targets:
478483
|all | compile all binaries and build all images
479484
|setup | fetch the dependent packages required to build with
480485
|deployoperator | deploy the Operator (apiserver and postgers-operator) to Kubernetes
481-
|main | compile the postgres-operator
486+
|main | compile the postgres-operator
482487
|runmain | locally execute the postgres-operator
483488
|pgo | build the pgo binary
484-
|runpgo | run the pgo binary
489+
|runpgo | run the pgo binary
485490
|runapiserver | run the apiserver binary outside of Kube
486491
|clean | remove binaries and compiled packages, restore dependencies
487492
|operatorimage | compile and build the postgres-operator Docker image
@@ -566,9 +571,9 @@ Values in the pgo configuration file have the following meaning:
566571
|Cluster.Strategy | sets the deployment strategy to be used for deploying a cluster, currently there is only strategy *1*
567572
|Cluster.Replicas | the number of cluster replicas to create for newly created clusters
568573
|Cluster.Policies | optional, list of policies to apply to a newly created cluster, comma separated, must be valid policies in the catalog
569-
|Cluster.PasswordAgeDays | optional, if set, will set the VALID UNTIL date on passwords to this many days in the future when creating users or setting passwords, defaults to 365 days
574+
|Cluster.PasswordAgeDays | optional, if set, will set the VALID UNTIL date on passwords to this many days in the future when creating users or setting passwords, defaults to 60 days
570575
|Cluster.PasswordLength | optional, if set, will determine the password length used when creating passwords, defaults to 8
571-
|PrimaryStorage |required, the value of the storage configuration to use for the primary PostgreSQL deployment
576+
|PrimaryStorage |required, the value of the storage configuration to use for the primary PostgreSQL deployment
572577
|BackupStorage |required, the value of the storage configuration to use for backups
573578
|ReplicaStorage |required, the value of the storage configuration to use for the replica PostgreSQL deployments
574579
|Storage.storage1.StorageClass |for a dynamic storage type, you can specify the storage class used for storage provisioning(e.g. standard, gold, fast)
@@ -626,22 +631,22 @@ pgo create cluster testcluster2 --storage-config=fastdisk --replica-storage-conf
626631

627632
That example will create a cluster and specify a storage configuration
628633
of *fastdisk* to be used for the primary database storage, the replica
629-
storage will use the storage configuration *slowdisk*.
634+
storage will use the storage configuration *slowdisk*.
630635

631636
....
632637
pgo backup testcluster --storage-config=offsitestorage
633638
....
634639

635-
That example will create a backup and use the *offsitestorage*
640+
That example will create a backup and use the *offsitestorage*
636641
storage configuration for persisting the backup.
637642

638643
=== Disaster Recovery Using Storage Configurations
639644

640645
A simple support for disaster recovery can be obtained
641-
by leveraging network storage, Kube storage classes, and
646+
by leveraging network storage, Kubernetes storage classes, and
642647
the storage configuration options within the Operator.
643648

644-
For example, if you define a Kube storage class that refers
649+
For example, if you define a Kubernetes storage class that refers
645650
to a storage backend that is running within your disaster recovery
646651
site, and then use that storage class as a storage configuration
647652
for your backups, you essentially have moved your backup files
@@ -765,6 +770,20 @@ database using the service IP address:
765770
psql -h 10.105.121.12 -U postgres postgres
766771
....
767772

773+
More details are available on user management below, however, you may wish to take note
774+
that user credentials are created in the file $COROOT/deploy/create-secrets.sh upon
775+
deployment of the Operator. The following user accounts and passwords are created by
776+
default for connecting to the PostgreSQL clusters:
777+
778+
*username*: postgres
779+
*password*: password
780+
781+
*username*: primaryuser
782+
*password*: password
783+
784+
*username*: testuser
785+
*password*: password
786+
768787
You can view *all* databases using the special keyword *all*:
769788
....
770789
pgo show cluster all
@@ -806,28 +825,16 @@ You can view the backup:
806825
pgo show backup mycluster
807826
....
808827

809-
You can view the backup along with a PVC listing:
810-
....
811-
pgo show backup mycluster --show-pvc=true
812-
....
828+
View the PVC folder and the backups contained therein:
813829

814-
The output of the backup will list the backup snapshots
815-
found in the backup PVC, for example:
816830
....
817-
backup job pods for cluster mycluster...
818-
└── backup-mycluster-63fw1
819-
└── mydatabase
820-
821-
database pod mycluster is found
822-
823-
├── mycluster-backups/2017-03-27-13-54-33
824-
├── mycluster-backups/2017-03-27-13-56-49
825-
└── mycluster-backups/2017-03-27-14-02-38
831+
pgo show pvc mycluster-backup-pvc
832+
pgo show pvc mycluster-backup-pvc --pvc-root=mycluster-backups
826833
....
827834

828-
This output is important in that it can let you copy/paste
829-
a backup snapshot path and use it for restoring a database or
830-
essentially cloning a database with an existing backup archive.
835+
The output from this command is important in that it can let you
836+
copy/paste a backup snapshot path and use it for restoring a database
837+
or essentially cloning a database with an existing backup archive.
831838

832839
For example, to restore a database from a backup archive:
833840
....
@@ -861,15 +868,15 @@ pgo delete cluster restoredb
861868
....
862869

863870
Note, that this command will not remove the PVC associated with
864-
this cluster.
871+
this cluster.
865872

866873
Selectors also apply to the delete command as follows:
867874
....
868875
pgo delete cluster  --selector=project=xray
869876
....
870877

871878
This command will cause any cluster matching the selector
872-
to be removed.
879+
to be removed.
873880

874881
You can remove a cluster and it's data files by running:
875882
....
@@ -897,13 +904,13 @@ Deployment is set to a replica count of 1, it can not scale beyond 1.
897904
The replica Deployment is set to an initial value of 0, you will
898905
see there are 0 replica databases running. Those replica databases
899906
are in read-only mode, but you can scale up the number of replicas
900-
beyond 0 if you need higher read scaling. To set the number of
907+
beyond 0 if you need higher read scaling. To set the number of
901908
replicas issue the following command:
902909
....
903910
pgo scale mycluster --replica-count=1
904911
....
905912

906-
There are 2 service connections available to the postgres cluster, one is
913+
There are 2 service connections available to the PostgreSQL cluster. One is
907914
to the master database which allows read-write SQL processing, and
908915
the other is to the set of read-only replica databases. The replica
909916
service performs round-robin load balancing to the replica databases.
@@ -954,7 +961,7 @@ container image specified in your pgo configuration file.
954961

955962
The database data files are converted to the new major Postgres
956963
version as specified by the current Postgres image version
957-
in your pgo configuration file.
964+
in your pgo configuration file.
958965

959966
In this scenario, the upgrade is performed by the Postgres
960967
pg_upgrade utility which is containerized in the *crunchydata/crunchy-upgrade*
@@ -1034,16 +1041,16 @@ pgo create policy policy1 --url=https://someurl/policy1.sql
10341041

10351042
When you execute this command, it will create a policy named *policy1*
10361043
using the input file */tmp/policy1.sql* as input. It will create
1037-
on the server a PgPolicy CRD with the name *policy1* that you can
1044+
on the server a PgPolicy CRD with the name *policy1* that you can
10381045
examine as follows:
10391046

10401047
....
10411048
kubectl get pgpolicies policy1 -o json
10421049
....
10431050

1044-
Policies get automatically applied to any cluster you create if
1051+
Policies get automatically applied to any cluster you create if
10451052
you define in your *pgo.yaml* configuration a CLUSTER.POLICIES
1046-
value. Policy SQL is executed as the *postgres* user.
1053+
value. Policy SQL is executed as the *postgres* user.
10471054

10481055
To view policies:
10491056
....
@@ -1087,7 +1094,7 @@ pgo user --delete-user=sally --selector=name=mycluster
10871094

10881095
To delete that user in all clusters:
10891096
....
1090-
pgo user --delete-user=sally
1097+
pgo user --delete-user=sally
10911098
....
10921099

10931100
To change the password for a user in the *mycluster* cluster:
@@ -1169,7 +1176,7 @@ The loading is based on a load definition found in the *sample-load-config.json*
11691176
If you include the *--policies* flag, any specified policies will be applied prior to the data being loaded. For
11701177
example:
11711178
....
1172-
pgo load --policies="rlspolicy,xrayapp" --load-config=$COROOT/examples/sample-load-config.json --selector=name=mycluster
1179+
pgo load --policies="rlspolicy,xrayapp" --load-config=$COROOT/examples/sample-load-config.json --selector=name=mycluster
11731180
....
11741181

11751182
Likewise you can load a sample json file into a database as follows:
@@ -1197,15 +1204,16 @@ The load configuration file has the following YAML attributes:
11971204
== bash Completion
11981205

11991206
There is a bash completion file that is included for users to try, this
1200-
is located in the repo at *example/pgo-bash-completion*. To use it, copy
1201-
that file to /etc/bash_completion.d/pgo, and log out and back into your
1202-
bash shell to try it out.
1203-
1207+
is located in the repository at *example/pgo-bash-completion*. To use it:
1208+
....
1209+
cp $COROOT/example/pgo-bash-completion /etc/bash_completion.d/pgo
1210+
su - $USER
1211+
....
12041212

12051213
== Quickstart
12061214

1207-
The *quickstart.sh* script will allow users to set up a Postgres Operator quickly.
1208-
This script is tested on GKE but can be used for other Kube environments as
1215+
The *quickstart.sh* script will allow users to set up the Postgres Operator quickly.
1216+
This script is tested on GKE but can be modified for use with other Kubernetes environments as
12091217
well.
12101218

12111219
The script requires a few things in order to work:
@@ -1214,7 +1222,7 @@ The script requires a few things in order to work:
12141222
* kubectl utility installed
12151223

12161224
Executing the script will give you a default Operator deployment
1217-
that assumes *dynamic* storage and a storage class named *standard*,
1225+
that assumes *dynamic* storage and a storage class named *standard*,
12181226
things that GKE provides.
12191227

12201228
The script performs the following:
@@ -1225,5 +1233,5 @@ The script performs the following:
12251233
* sets your .bashrc to include the Operator environment variables
12261234
* sets your $HOME/.bash_completion file to be the *pgo* bash_completion file
12271235

1228-
Our plans are to provide other more customized versions of the Quickstart script
1236+
Our plans are to provide other customized versions of the Quickstart script
12291237
over time, as well as support Mac and Windows versions of the script.

0 commit comments

Comments
 (0)