Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Pgpool quickstart #635

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/examples/pgpool/quickstart/quick-pgpool.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: kubedb.com/v1alpha2
kind: Pgpool
metadata:
name: quick-pgpool
namespace: pool
spec:
version: "4.5.0"
replicas: 1
postgresRef:
name: quick-postgres
namespace: demo
sslMode: disable
clientAuthMode: md5
syncUsers: true
terminationPolicy: WipeOut
19 changes: 19 additions & 0 deletions docs/examples/pgpool/quickstart/quick-postgres.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: kubedb.com/v1alpha2
kind: Postgres
metadata:
name: quick-postgres
namespace: demo
spec:
replicas: 1
version: "13.13"
configSecret:
name: pg-configuration
storageType: Durable
storage:
storageClassName: "standard"
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Mi
terminationPolicy: WipeOut
1 change: 1 addition & 0 deletions docs/examples/pgpool/quickstart/user.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
max_connections=400
41 changes: 41 additions & 0 deletions docs/guides/pgpool/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: Pgpool
menu:
docs_{{ .version }}:
identifier: pp-readme-pgpool
name: Pgpool
parent: pp-pgpool-guides
weight: 10
menu_name: docs_{{ .version }}
section_menu_id: guides
url: /docs/{{ .version }}/guides/pgpool/
aliases:
- /docs/{{ .version }}/guides/pgpool/README/
---

> New to KubeDB? Please start [here](/docs/README.md).

# Overview

[Pgpool](https://pgpool.net/) is a versatile proxy solution positioned between PostgreSQL servers and database clients. It offers essential functionalities such as Connection Pooling, Load Balancing, In-Memory Query Cache and many more. Pgpool enhances the performance, scalability, and reliability of PostgreSQL database systems.

KubeDB operator now comes bundled with Pgpool crd to manage all the essential features of Pgpool.

## Pgpool Features

| Features | Availability |
|-------------------------------| :----------: |
| Clustering | ✓ |
| Multiple Pgpool Versions | ✓ |
| Custom Configuration | ✓ |
| Sync Postgres Users to Pgpool | ✓ |
| Custom docker images | ✓ |
| Enabling TLS | ✓ |
| Builtin Prometheus Discovery | ✓ |
| Using Prometheus operator | ✓ |

## User Guide

- [Quickstart Pgpool](/docs/guides/pgpool/quickstart/quickstart.md) with KubeDB Operator.
- Detail concepts of [Pgpool object](/docs/guides/pgpool/concepts/pgpool.md).
- Want to hack on KubeDB? Check our [contribution guidelines](/docs/CONTRIBUTING.md).
10 changes: 10 additions & 0 deletions docs/guides/pgpool/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Pgpool
menu:
docs_{{ .version }}:
identifier: pp-pgpool-guides
name: Pgpool
parent: guides
weight: 10
menu_name: docs_{{ .version }}
---
10 changes: 10 additions & 0 deletions docs/guides/pgpool/concepts/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Pgpool Concepts
menu:
docs_{{ .version }}:
identifier: pp-concepts-pgpool
name: Concepts
parent: pp-pgpool-guides
weight: 20
menu_name: docs_{{ .version }}
---
146 changes: 146 additions & 0 deletions docs/guides/pgpool/concepts/appbinding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
---
title: AppBinding CRD
menu:
docs_{{ .version }}:
identifier: pp-appbinding-concepts
name: AppBinding
parent: pp-concepts-pgpool
weight: 20
menu_name: docs_{{ .version }}
section_menu_id: guides
---

> New to KubeDB? Please start [here](/docs/README.md).

# AppBinding

## What is AppBinding

An `AppBinding` is a Kubernetes `CustomResourceDefinition`(CRD) which points to an application using either its URL (usually for a non-Kubernetes resident service instance) or a Kubernetes service object (if self-hosted in a Kubernetes cluster), some optional parameters and a credential secret. To learn more about AppBinding and the problems it solves, please read this blog post: [The case for AppBinding](https://appscode.com/blog/post/the-case-for-appbinding).

If you deploy a database using [KubeDB](https://kubedb.com/docs/0.11.0/concepts/), `AppBinding` object will be created automatically for it. Otherwise, you have to create an `AppBinding` object manually pointing to your desired database.

KubeDB uses [Stash](https://appscode.com/products/stash/) to perform backup/recovery of databases. Stash needs to know how to connect with a target database and the credentials necessary to access it. This is done via an `AppBinding`.

## AppBinding CRD Specification

Like any official Kubernetes resource, an `AppBinding` has `TypeMeta`, `ObjectMeta` and `Spec` sections. However, unlike other Kubernetes resources, it does not have a `Status` section.

An `AppBinding` object created by `KubeDB` for PostgreSQL database is shown below,

```yaml
apiVersion: appcatalog.appscode.com/v1alpha1
kind: AppBinding
metadata:
labels:
app.kubernetes.io/component: database
app.kubernetes.io/instance: quick-postgres
app.kubernetes.io/managed-by: kubedb.com
app.kubernetes.io/name: postgreses.kubedb.com
name: quick-postgres
namespace: demo
spec:
appRef:
apiGroup: kubedb.com
kind: Postgres
name: quick-postgres
namespace: demo
clientConfig:
service:
name: quick-postgres
path: /
port: 5432
query: sslmode=disable
scheme: postgresql
secret:
name: quick-postgres-auth
type: kubedb.com/postgres
version: "13.13"
```

Here, we are going to describe the sections of an `AppBinding` crd.

### AppBinding `Spec`

An `AppBinding` object has the following fields in the `spec` section:

#### spec.type

`spec.type` is an optional field that indicates the type of the app that this `AppBinding` is pointing to. Stash uses this field to resolve the values of `TARGET_APP_TYPE`, `TARGET_APP_GROUP` and `TARGET_APP_RESOURCE` variables of [BackupBlueprint](https://appscode.com/products/stash/latest/concepts/crds/backupblueprint/) object.

This field follows the following format: `<app group>/<resource kind>`. The above AppBinding is pointing to a `postgres` resource under `kubedb.com` group.

Here, the variables are parsed as follows:

| Variable | Usage |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `TARGET_APP_GROUP` | Represents the application group where the respective app belongs (i.e: `kubedb.com`). |
| `TARGET_APP_RESOURCE` | Represents the resource under that application group that this appbinding represents (i.e: `postgres`). |
| `TARGET_APP_TYPE` | Represents the complete type of the application. It's simply `TARGET_APP_GROUP/TARGET_APP_RESOURCE` (i.e: `kubedb.com/postgres`). |

#### spec.secret

`spec.secret` specifies the name of the secret which contains the credentials that are required to access the database. This secret must be in the same namespace as the `AppBinding`.

This secret must contain the following keys:

PostgreSQL :

| Key | Usage |
|------------|------------------------------------------------|
| `username` | Username of the target database. |
| `password` | Password for the user specified by `username`. |

MySQL :

| Key | Usage |
| ---------- | ---------------------------------------------- |
| `username` | Username of the target database. |
| `password` | Password for the user specified by `username`. |

MongoDB :

| Key | Usage |
| ---------- | ---------------------------------------------- |
| `username` | Username of the target database. |
| `password` | Password for the user specified by `username`. |

Elasticsearch:

| Key | Usage |
| ---------------- | ----------------------- |
| `ADMIN_USERNAME` | Admin username |
| `ADMIN_PASSWORD` | Password for admin user |

#### spec.clientConfig

`spec.clientConfig` defines how to communicate with the target database. You can use either an URL or a Kubernetes service to connect with the database. You don't have to specify both of them.

You can configure following fields in `spec.clientConfig` section:

- **spec.clientConfig.url**

`spec.clientConfig.url` gives the location of the database, in standard URL form (i.e. `[scheme://]host:port/[path]`). This is particularly useful when the target database is running outside of the Kubernetes cluster. If your database is running inside the cluster, use `spec.clientConfig.service` section instead.

> Note that, attempting to use a user or basic auth (e.g. `user:password@host:port`) is not allowed. Stash will insert them automatically from the respective secret. Fragments ("#...") and query parameters ("?...") are not allowed either.

- **spec.clientConfig.service**

If you are running the database inside the Kubernetes cluster, you can use Kubernetes service to connect with the database. You have to specify the following fields in `spec.clientConfig.service` section if you manually create an `AppBinding` object.

- **name :** `name` indicates the name of the service that connects with the target database.
- **scheme :** `scheme` specifies the scheme (i.e. http, https) to use to connect with the database.
- **port :** `port` specifies the port where the target database is running.

- **spec.clientConfig.insecureSkipTLSVerify**

`spec.clientConfig.insecureSkipTLSVerify` is used to disable TLS certificate verification while connecting with the database. We strongly discourage to disable TLS verification during backup. You should provide the respective CA bundle through `spec.clientConfig.caBundle` field instead.

- **spec.clientConfig.caBundle**

`spec.clientConfig.caBundle` is a PEM encoded CA bundle which will be used to validate the serving certificate of the database.

## Next Steps

- Learn how to use KubeDB to manage various databases [here](/docs/guides/README.md).
- Want to hack on KubeDB? Check our [contribution guidelines](/docs/CONTRIBUTING.md).
74 changes: 74 additions & 0 deletions docs/guides/pgpool/concepts/catalog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
title: PgpoolVersion CRD
menu:
docs_{{ .version }}:
identifier: pp-catalog-concepts
name: PgpoolVersion
parent: pp-concepts-pgpool
weight: 15
menu_name: docs_{{ .version }}
section_menu_id: guides
---

> New to KubeDB? Please start [here](/docs/README.md).

# PgpoolVersion

## What is PgpoolVersion

`PgpoolVersion` is a Kubernetes `Custom Resource Definitions` (CRD). It provides a declarative configuration to specify the docker images to be used for [Pgpool](https://pgpool.net/) server deployed with KubeDB in a Kubernetes native way.

When you install KubeDB, a `PgpoolVersion` custom resource will be created automatically for every supported Pgpool release versions. You have to specify the name of `PgpoolVersion` crd in `spec.version` field of [Pgpool](/docs/guides/pgpool/concepts/pgpool.md) crd. Then, KubeDB will use the docker images specified in the `PgpoolVersion` crd to create your expected Pgpool instance.

Using a separate crd for specifying respective docker image names allow us to modify the images independent of KubeDB operator. This will also allow the users to use a custom Pgpool image for their server. For more details about how to use custom image with Pgpool in KubeDB, please visit [here](/docs/guides/pgpool/custom-versions/setup.md).

## PgpoolVersion Specification

As with all other Kubernetes objects, a PgpoolVersion needs `apiVersion`, `kind`, and `metadata` fields. It also needs a `.spec` section.

```yaml
apiVersion: catalog.kubedb.com/v1alpha1
kind: PgpoolVersion
metadata:
name: 4.5.0
spec:
exporter:
image: ghcr.io/appscode-images/pgpool2_exporter:v1.2.2
pgpool:
image: ghcr.io/appscode-images/pgpool2:4.5.0
version: 4.5.0
deprecated: false
```

### metadata.name

`metadata.name` is a required field that specifies the name of the `PgpoolVersion` crd. You have to specify this name in `spec.version` field of [Pgpool](/docs/guides/pgpool/concepts/pgpool.md) crd.

We follow this convention for naming PgpoolVersion crd:

- Name format: `{Original pgpool image version}-{modification tag}`

We plan to modify original Pgpool docker images to support additional features. Re-tagging the image with v1, v2 etc. modification tag help separating newer iterations from the older ones. An image with higher modification tag will have more features than the images with lower modification tag. Hence, it is recommended to use PgpoolVersion crd with higher modification tag to take advantage of the latest features.

### spec.version

`spec.version` is a required field that specifies the original version of Pgpool that has been used to build the docker image specified in `spec.server.image` field.

### spec.deprecated

`spec.deprecated` is an optional field that specifies whether the docker images specified here is supported by the current KubeDB operator.

The default value of this field is `false`. If `spec.deprecated` is set `true`, KubeDB operator will not create the server and other respective resources for this version.

### spec.pgpool.image

`spec.pgpool.image` is a required field that specifies the docker image which will be used to create PetSet by KubeDB operator to create expected Pgpool server.

### spec.exporter.image

`spec.exporter.image` is a required field that specifies the image which will be used to export Prometheus metrics.

## Next Steps

- Learn about Pgpool crd [here](/docs/guides/pgpool/concepts/catalog.md).
- Deploy your first Pgpool server with KubeDB by following the guide [here](/docs/guides/pgpool/quickstart/quickstart.md).
15 changes: 15 additions & 0 deletions docs/guides/pgpool/concepts/pgpool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: Pgpool CRD
menu:
docs_{{ .version }}:
identifier: pp-pgpool-concepts
name: Pgpool
parent: pp-concepts-pgpool
weight: 10
menu_name: docs_{{ .version }}
section_menu_id: guides
---

> New to KubeDB? Please start [here](/docs/README.md).

# Pgpool
10 changes: 10 additions & 0 deletions docs/guides/pgpool/custom-versions/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Pgpool Custom Versions
menu:
docs_{{ .version }}:
identifier: pp-custom-versions-pgpool
name: Custom Versions
parent: pp-pgpool-guides
weight: 36
menu_name: docs_{{ .version }}
---
Loading
Loading