Skip to content

Commit 9bbe659

Browse files
ValClarksonJonathan S. Katz
authored andcommitted
Added directions for GCP Marketplace
Added directions to guide a user to run locally with with a PostgreSQL Operator deployed via the GCP Marketplace installer. Separated the documentation into two sections: one for deploying the PostgreSQL Operator via the GCP Marketplace, and the other using the Ansible installer. Expanded on how to get keys from the Operator running via the GCP Marketplace, how to set those keys and get the pgo binary, how to setting up access to the API server via a user, and adding namespaces to create a new PostgreSQL with the Operator.
1 parent 1cdd259 commit 9bbe659

File tree

1 file changed

+201
-6
lines changed

1 file changed

+201
-6
lines changed

hugo/content/quickstart/_index.md

Lines changed: 201 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@ Can't wait to try out the PostgreSQL Operator? Let us show you the quickest poss
1111

1212
There are two paths to quickly get you up and running with the PostgreSQL Operator:
1313

14+
- [Installation via Ansible](#ansible)
1415
- Installation via a Marketplace
15-
- Installation via the Ansible Installer
16+
- Installation via [Google Cloud Platform Marketplace](#google-cloud-platform-marketplace)
1617

17-
The marketplaces that include the Crunchy PostgreSQL Operator include:
18+
Marketplaces can help you get more quickly started in your environment as they provide a mostly automated process, but there are a few steps you will need to take to ensure you can fully utilize your PostgreSQL Operator environment.
1819

19-
- [Crunchy PostgreSQL for GKE](https://console.cloud.google.com/marketplace/details/crunchydata/crunchy-postgresql-operator) - Google Cloud Marketplace
20+
# Ansible
2021

21-
The marketplaces will get your environment set up quickly, and you can use "Step 5" below to validate your installation.
22-
23-
Below will guide you through the steps for installing and using the PostgreSQL Operator using the Ansible Installer.
22+
Below will guide you through the steps for installing and using the PostgreSQL Operator using an installer that works with Ansible.
2423

2524
## Step 1: Prerequisites
2625

@@ -46,6 +45,7 @@ You can download the playbook by cloning the [PostgreSQL Operator git repository
4645

4746
```shell
4847
git clone https://github.com/CrunchyData/postgres-operator.git
48+
cd postgres-operator
4949
git checkout v4.2.0 # you can substitute this for the version that you want to install
5050
cd ansible
5151
```
@@ -285,3 +285,198 @@ cluster : hippo
285285
```
286286

287287
The `pgo test` command provides you the basic information you need to connect to your PostgreSQL cluster from within your Kubernetes environment. For more detailed information, you can use `pgo show cluster -n pgouser1 hippo`.
288+
289+
# Marketplaces
290+
291+
Below is the list of the marketplaces where you can find the Crunchy PostgreSQL Operator:
292+
293+
- Google Cloud Platform Marketplace: [Crunchy PostgreSQL for GKE](https://console.cloud.google.com/marketplace/details/crunchydata/crunchy-postgresql-operator)
294+
295+
Follow the instructions below for the marketplace that you want to use to deploy the Crunchy PostgreSQL Operator.
296+
297+
## Google Cloud Platform Marketplace
298+
299+
The PostgreSQL Operator is installed as part of the [Crunchy PostgreSQL for GKE](https://console.cloud.google.com/marketplace/details/crunchydata/crunchy-postgresql-operator) project that is available in the Google Cloud Platform Marketplace (GCP Marketplace). Please follow the steps deploy to get the PostgreSQL Operator deployed!
300+
301+
### Step 1: Prerequisites
302+
303+
#### Install `Kubectl` and `gcloud` SDK
304+
305+
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) is required to execute kube commands with in GKE.
306+
- [gcloudsdk](https://cloud.google.com/sdk/install) essential command line tools for google cloud
307+
308+
#### Verification
309+
310+
Below are a few steps to check if the PostgreSQL Operator is up and running.
311+
312+
For this example we are deploying the operator into a namespace called `pgo`. First, see that the the Kubernetes Deployment of the Operator exists and is healthy:
313+
314+
```shell
315+
kubectl -n pgo get deployments
316+
```
317+
318+
If successful, you should see output similar to this:
319+
320+
```
321+
NAME READY UP-TO-DATE AVAILABLE AGE
322+
postgres-operator 1/1 1 1 16h
323+
```
324+
325+
Next, see if the Pods that run the PostgreSQL Operator are up and running:
326+
327+
```shell
328+
kubectl -n pgo get pods
329+
```
330+
331+
If successful, you should see output similar to this:
332+
333+
```
334+
NAME READY STATUS RESTARTS AGE
335+
postgres-operator-56d6ccb97-tmz7m 4/4 Running 0 2m
336+
```
337+
338+
### Step 2: Install the PostgreSQL Operator User Keys
339+
340+
After your operator is deployed via GCP Marketplace you will need to get keys used to secure the Operator REST API. For these instructions we will assume the operator is deployed in a namespace named "pgo" if this in not the case for your operator change the namespace to coencide with where your operator is deployed. Using the `gcloud` utility, ensure you are logged into the GKE cluster that you installed the PostgreSQL Operator into, run the following commands to retrieve the cert and key:
341+
342+
```shell
343+
kubectl get secret pgo.tls -n pgo -o jsonpath='{.data.tls\.key}' | base64 --decode > /tmp/client.key
344+
kubectl get secret pgo.tls -n pgo -o jsonpath='{.data.tls\.crt}' | base64 --decode > /tmp/client.crt
345+
```
346+
347+
### Step 3: Setup PostgreSQL Operator User
348+
349+
The PostgreSQL Operator implements its own role-based access control (RBAC) system for authenticating and authorization PostgreSQL Operator users access to its REST API. A default PostgreSQL Operator user (aka a "pgouser") is created as part of the marketplace installation (these credentials are set during the marketplace deployment workflow).
350+
351+
Create the pgouser file in `${HOME?}/.pgo/<operatornamespace>/pgouser` and insert the user and password you created on deployment of the PostgreSQL Operator via GCP Marketplace. For example, if you set up a user with the username of `username` and a password of `hippo`:
352+
353+
```shell
354+
username:hippo
355+
```
356+
357+
### Step 4: Setup Environment variables
358+
359+
The PostgreSQL Operator Client uses several environmental variables to make it easier for interfacing with the PostgreSQL Operator.
360+
361+
Set the environmental variables to use the key / certificate pair that you pulled in Step 2 was deployed via the marketplace. Using the previous examples, You can set up environment variables with the following command:
362+
363+
```shell
364+
export PGOUSER="${HOME?}/.pgo/pgo/pgouser"
365+
export PGO_CA_CERT="/tmp/client.crt"
366+
export PGO_CLIENT_CERT="/tmp/client.crt"
367+
export PGO_CLIENT_KEY="/tmp/client.key"
368+
export PGO_APISERVER_URL='https://127.0.0.1:8443'
369+
```
370+
371+
If you wish to permanently add these variables to your environment, you can run the following command:
372+
373+
```shell
374+
cat <<EOF >> ~/.bashrc
375+
export PGOUSER="${HOME?}/.pgo/pgo/pgouser"
376+
export PGO_CA_CERT="/tmp/client.crt"
377+
export PGO_CLIENT_CERT="/tmp/client.crt"
378+
export PGO_CLIENT_KEY="/tmp/client.key"
379+
export PGO_APISERVER_URL='https://127.0.0.1:8443'
380+
EOF
381+
382+
source ~/.bashrc
383+
```
384+
385+
**NOTE**: For macOS users, you must use `~/.bash_profile` instead of `~/.bashrc`
386+
387+
### Step 5: Install the PostgreSQL Operator Client `pgo`
388+
389+
The [`pgo` client](/pgo-client/) provides a helpful command-line interface to perform key operations on a PostgreSQL Operator, such as creating a PostgreSQL cluster.
390+
391+
The `pgo` client can be downloaded from GitHub [Releases](https://github.com/crunchydata/postgres-operator/releases) (subscribers can download it from the [Crunchy Data Customer Portal](https://access.crunchydata.com)).
392+
393+
Note that the `pgo` client's version must match the version of the PostgreSQL Operator that you have deployed. For example, if you have deployed version 4.2.0 of the PostgreSQL Operator, you must use the `pgo` for 4.2.0.
394+
395+
Once you have download the `pgo` client, change the permissions on the file to be executable if need be as shown below:
396+
397+
```shell
398+
chmod +x pgo
399+
```
400+
401+
### Step 6: Connect to the PostgreSQL Operator
402+
403+
Finally, let's see if we can connect to the PostgreSQL Operator from the `pgo` client. In order to communicate with the PostgreSQL Operator API server, you will first need to set up a [port forward](https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/) to your local environment.
404+
405+
In a new console window, run the following command to set up a port forward:
406+
407+
```shell
408+
kubectl -n pgo port-forward svc/postgres-operator 8443:8443
409+
```
410+
411+
Back to your original console window, you can verify that you can connect to the PostgreSQL Operator using the following command:
412+
413+
```shell
414+
pgo version
415+
```
416+
417+
If successful, you should see output similar to this:
418+
419+
```
420+
pgo client version 4.2.0
421+
pgo-apiserver version 4.2.0
422+
```
423+
424+
### Step 7: Create a Namespace
425+
426+
We are almost there! You can optionally add a namespace that can be managed by the PostgreSQL Operator to watch and to deploy a PostgreSQL cluster into.
427+
428+
```shell
429+
pgo create namespace wateringhole
430+
```
431+
432+
verify the operator has access to the newly added namespace
433+
434+
```shell
435+
pgo show namespace --all
436+
```
437+
438+
you should see out put similar to this:
439+
440+
```shell
441+
pgo username: admin
442+
namespace useraccess installaccess
443+
application-system accessible no access
444+
default accessible no access
445+
kube-public accessible no access
446+
kube-system accessible no access
447+
pgo accessible no access
448+
wateringhole accessible accessible
449+
```
450+
451+
### Step 8: Have Some Fun - Create a PostgreSQL Cluster
452+
453+
You are now ready to create a new cluster in the `wateringhole` namespace, try the command below:
454+
455+
```shell
456+
pgo create cluster -n wateringhole hippo
457+
```
458+
459+
If successful, you should see output similar to this:
460+
461+
```
462+
created Pgcluster hippo
463+
workflow id 1cd0d225-7cd4-4044-b269-aa7bedae219b
464+
```
465+
466+
This will create a PostgreSQL cluster named `hippo`. It may take a few moments for the cluster to be provisioned. You can see the status of this cluster using the `pgo test` command:
467+
468+
```shell
469+
pgo test -n wateringhole hippo
470+
```
471+
472+
When everything is up and running, you should see output similar to this:
473+
474+
```
475+
cluster : hippo
476+
Services
477+
primary (10.97.140.113:5432): UP
478+
Instances
479+
primary (hippo-7b64747476-6dr4h): UP
480+
```
481+
482+
The `pgo test` command provides you the basic information you need to connect to your PostgreSQL cluster from within your Kubernetes environment. For more detailed information, you can use `pgo show cluster -n wateringhole hippo`.

0 commit comments

Comments
 (0)