Skip to content

Commit

Permalink
Import corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-heyer committed Sep 14, 2023
1 parent 2dc5801 commit 82f01fd
Show file tree
Hide file tree
Showing 16 changed files with 414 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ kubectl cnp pgbench \

You can see the progress of the job with:

```shell 
```shell
kubectl logs jobs/pgbench-run
```

Expand Down
2 changes: 1 addition & 1 deletion product_docs/docs/postgres_for_kubernetes/1/bootstrap.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ When only the streaming connection is defined, the source can be used for the
source can be used for the `recovery` method. When both are defined, any of the
two bootstrap methods can be chosen.

Furthermore, in case of `pg_basebackup` or full `recovery`point in time), the
Furthermore, in case of `pg_basebackup` or full `recovery` point in time, the
cluster is eligible for replica cluster mode. This means that the cluster is
continuously fed from the source, either via streaming, via WAL shipping
through the PostgreSQL's `restore_command`, or any of the two.
Expand Down
383 changes: 383 additions & 0 deletions product_docs/docs/postgres_for_kubernetes/1/default-monitoring.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ for a more comprehensive example.
ports, as explained in the official
[docs](https://cloud.google.com/kubernetes-engine/docs/how-to/private-clusters#add_firewall_rules)
and by this
[issue](https://github.com/EnterpriseDB/cloud-native-postgres/issues/1360).
[issue](https://github.com/cloudnative-pg/cloudnative-pg/issues/1360).
You'll need to either change the `targetPort` in the webhook service, to be
one of the allowed ones, or open the webhooks' port (`9443`) on the
firewall.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -941,4 +941,4 @@ A specific `VolumeSnapshotClass` can be requested via the `-c` option:

```shell
kubectl cnp snapshot cluster-example -c longhorn
```
```
15 changes: 8 additions & 7 deletions product_docs/docs/postgres_for_kubernetes/1/monitoring.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ All monitoring queries that are performed on PostgreSQL are:
- executed with `application_name` set to `cnp_metrics_exporter`
- executed as user `postgres`

Please refer to the "Default roles" section in PostgreSQL
[documentation](https://www.postgresql.org/docs/current/default-roles.html)
Please refer to the "Predefined Roles" section in PostgreSQL
[documentation](https://www.postgresql.org/docs/current/predefined-roles.html)
for details on the `pg_monitor` role.

Queries, by default, are run against the *main database*, as defined by
Expand Down Expand Up @@ -363,7 +363,7 @@ go_threads 18
### User defined metrics

This feature is currently in *beta* state and the format is inspired by the
[queries.yaml file](https://github.com/prometheus-community/postgres_exporter/blob/master/queries.yaml) <!-- wokeignore:rule=master -->
[queries.yaml file (release 0.12)](https://github.com/prometheus-community/postgres_exporter/blob/v0.12.1/queries.yaml)
of the PostgreSQL Prometheus Exporter.

Custom metrics can be defined by users by referring to the created `Configmap`/`Secret` in a `Cluster` definition
Expand Down Expand Up @@ -442,7 +442,7 @@ data:
```

A list of basic monitoring queries can be found in the
[`default-monitoring.yaml` file](https://github.com/EnterpriseDB/cloud-native-postgres/blob/main/config/manager/default-monitoring.yaml)
[`default-monitoring.yaml` file](default-monitoring.yaml)
that is already installed in your EDB Postgres for Kubernetes deployment (see ["Default set of metrics"](#default-set-of-metrics)).

#### Example of a user defined metric running on multiple databases
Expand Down Expand Up @@ -543,7 +543,7 @@ Here is a short description of all the available fields:

- `<MetricName>`: the name of the Prometheus metric
- `query`: the SQL query to run on the target database to generate the metrics
- `primary`: whether to run the query only on the primary instance <!-- wokeignore:rule=master -->
- `primary`: whether to run the query only on the primary instance
- `master`: same as `primary` (for compatibility with the Prometheus PostgreSQL exporter's syntax - deprecated) <!-- wokeignore:rule=master -->
- `runonserver`: a semantic version range to limit the versions of PostgreSQL the query should run on
(e.g. `">=11.0.0"` or `">=12.0.0 <=15.0.0"`)
Expand Down Expand Up @@ -737,16 +737,17 @@ kubectl delete -f curl.yaml
These resources are provided for illustration and experimentation, and do
not represent any kind of recommendation for your production system

In the [`doc/src/samples/monitoring/`](https://github.com/EnterpriseDB/cloud-native-postgres/tree/main/docs/src/samples/monitoring)
In the [`doc/src/samples/monitoring/`](https://github.com/EnterpriseDB/docs/tree/main/product_docs/docs/postgres-for-kubernetes/latest/src/samples/monitoring)
directory you will find a series of sample files for observability.
Please refer to [Part 4 of the quickstart](quickstart.md#part-4-monitor-clusters-with-prometheus-and-grafana)
section for context:

- `kube-stack-config.yaml`: a configuration file for the kube-stack helm chart
installation. It ensures that Prometheus listens for all PodMonitor resources.
- `postgresql-operator-prometheusrule.yaml`: a `PrometheusRule` with alerts for EDB Postgres for Kubernetes.
- `prometheusrule.yaml`: a `PrometheusRule` with alerts for EDB Postgres for Kubernetes.
NOTE: this does not include inter-operation with notification services. Please refer
to the [Prometheus documentation](https://prometheus.io/docs/alerting/latest/alertmanager/).
- `podmonitor.yaml`: a `PodMonitor` for the EDB Postgres for Kubernetes Operator deployment.
- `grafana-configmap.yaml`: a ConfigMap containing the definition of the sample
EDB Postgres for Kubernetes Dashboard. Note the labels in the definition, which ensure that
the Grafana deployment will find the ConfigMap.
Expand Down
2 changes: 1 addition & 1 deletion product_docs/docs/postgres_for_kubernetes/1/openshift.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ enabled, so you can peek the `cnp_` prefix:
![Prometheus queries](./images/openshift/prometheus-queries.png)

It is easy to define Alerts based on the default metrics as `PrometheusRules`.
You can find some examples of rules in the [cnp-prometheusrule.yaml](../samples/monitoring/cnp-prometheusrule.yaml)
You can find some examples of rules in the [prometheusrule.yaml](../samples/monitoring/prometheusrule.yaml)
file, which you can download.

Before applying the rules, again, some OpenShift setup may be necessary.
Expand Down
22 changes: 10 additions & 12 deletions product_docs/docs/postgres_for_kubernetes/1/operator_conf.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,21 @@ Following the above example, if the `Cluster` definition contains a `categories`
annotation and any of the `environment`, `workload`, or `app` labels, these will
be inherited by all the resources generated by the deployment.

## PPROF HTTP SERVER
## pprof HTTP Server

The operator can expose a PPROF HTTP server with the following endpoints on localhost:6060:
The operator can expose a PPROF HTTP server with the following endpoints on `localhost:6060`:

```
- `/debug/pprof/`. Responds to a request for "/debug/pprof/" with an HTML page listing the available profiles
- `/debug/pprof/cmdline`. Responds with the running program's command line, with arguments separated by NUL bytes.
- `/debug/pprof/profile`. Responds with the pprof-formatted cpu profile. Profiling lasts for duration specified in seconds GET parameter, or for 30 seconds if not specified.
- `/debug/pprof/symbol`. Looks up the program counters listed in the request, responding with a table mapping program counters to function names.
- `/debug/pprof/trace`. Responds with the execution trace in binary form. Tracing lasts for duration specified in seconds GET parameter, or for 1 second if not specified.
```
- `/debug/pprof/`. Responds to a request for "/debug/pprof/" with an HTML page listing the available profiles
- `/debug/pprof/cmdline`. Responds with the running program's command line, with arguments separated by NULL bytes.
- `/debug/pprof/profile`. Responds with the pprof-formatted cpu profile. Profiling lasts for duration specified in seconds GET parameter, or for 30 seconds if not specified.
- `/debug/pprof/symbol`. Looks up the program counters listed in the request, responding with a table mapping program counters to function names.
- `/debug/pprof/trace`. Responds with the execution trace in binary form. Tracing lasts for duration specified in seconds GET parameter, or for 1 second if not specified.

To enable the operator you need to edit the operator deployment add the flag `--pprof-server=true`.

You can do this by executing these commands:

```
```shell
kubectl edit deployment -n postgresql-operator-system postgresql-operator-controller-manager
```

Expand All @@ -173,12 +171,12 @@ Save the changes, the deployment now will execute a rollout and the new pod will
Once the pod is running you can exec inside the container by doing:
```
```shell
kubectl exec -ti -n postgresql-operator-system <pod name> -- bash
```

Once inside execute:

```
```shell
curl localhost:6060/debug/pprof/
```
6 changes: 3 additions & 3 deletions product_docs/docs/postgres_for_kubernetes/1/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ helm repo add prometheus-community \
https://prometheus-community.github.io/helm-charts

helm upgrade --install \
-f https://raw.githubusercontent.com/EnterpriseDB/cloud-native-postgres/main/docs/src/samples/monitoring/kube-stack-config.yaml \
-f https://raw.githubusercontent.com/EnterpriseDB/docs/main/product_docs/docs/postgres-for-kubernetes/latest/samples/monitoring/kube-stack-config.yaml \
prometheus-community \
prometheus-community/kube-prometheus-stack
```
Expand Down Expand Up @@ -330,7 +330,7 @@ You can now define some alerts by creating a `prometheusRule`:

```sh
kubectl apply -f \
https://raw.githubusercontent.com/EnterpriseDB/cloud-native-postgres/main/docs/src/samples/monitoring/postgresql-operator-prometheusrule.yaml
https://raw.githubusercontent.com/EnterpriseDB/docs/main/product_docs/docs/postgres-for-kubernetes/latest/samples/monitoring/prometheusrule.yaml
```

You should see the default alerts now:
Expand Down Expand Up @@ -361,7 +361,7 @@ We can now install our sample Grafana dashboard:

```sh
kubectl apply -f \
https://raw.githubusercontent.com/EnterpriseDB/cloud-native-postgres/main/docs/src/samples/monitoring/grafana-configmap.yaml
https://raw.githubusercontent.com/EnterpriseDB/docs/main/product_docs/docs/postgres-for-kubernetes/latest/samples/monitoring/grafana-configmap.yaml
```

Which will be picked up by the Grafana page in a few seconds. You should now
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ metadata:
name: cluster-example-full
spec:
description: "Example of cluster"
imageName: quay.io/enterprisedb/postgresql:15.3
imageName: quay.io/enterprisedb/postgresql:15.4
# imagePullSecret is only required if the images are located in a private registry
# imagePullSecrets:
# - name: private_registry_access
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,6 @@ metadata:
k8s.enterprisedb.io/reload: ""
data:
custom-queries: |
pg_replication:
query: "SELECT CASE WHEN NOT pg_is_in_recovery()
THEN 0
ELSE GREATEST (0,
EXTRACT(EPOCH FROM (now() - pg_last_xact_replay_timestamp())))
END AS lag,
pg_is_in_recovery() AS in_recovery,
EXISTS (TABLE pg_stat_wal_receiver) AS is_wal_receiver_up,
(SELECT count(*) FROM pg_stat_replication) AS streaming_replicas"
metrics:
- lag:
usage: "GAUGE"
description: "Replication lag behind primary in seconds"
- in_recovery:
usage: "GAUGE"
description: "Whether the instance is in recovery"
- is_wal_receiver_up:
usage: "GAUGE"
description: "Whether the instance wal_receiver is up"
- streaming_replicas:
usage: "GAUGE"
description: "Number of streaming replicas connected to the instance"
pg_postmaster:
query: "SELECT pg_postmaster_start_time as start_time from pg_postmaster_start_time()"
primary: true
metrics:
- start_time:
usage: "GAUGE"
description: "Time at which postgres started"
pg_stat_user_tables:
target_databases:
- "*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ spec:

# Persistent storage configuration
storage:
storageClass: standard
storageClass: csi-hostpath-sc
size: 1Gi

# Backup properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ spec:

storage:
size: 1Gi
storageClass: csi-hostpath-sc

bootstrap:
recovery:
volumeSnapshots:
storage:
name: my-backup
name: cluster-example-with-backup-3-1692618163
kind: VolumeSnapshot
apiGroup: snapshot.storage.k8s.io

2 changes: 1 addition & 1 deletion product_docs/docs/postgres_for_kubernetes/1/security.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ PostgreSQL `Cluster` resource name.
[recommended way to access the API server from within a Pod](https://kubernetes.io/docs/tasks/run-application/access-api-from-pod/).

For transparency, the permissions associated with the service account are defined in the
[roles.go](https://github.com/EnterpriseDB/cloud-native-postgres/blob/main/pkg/specs/roles.go)
[roles.go](https://github.com/cloudnative-pg/cloudnative-pg/blob/main/pkg/specs/roles.go)
file. For example, to retrieve the permissions of a generic `mypg` cluster in the
`myns` namespace, you can type the following command:

Expand Down

0 comments on commit 82f01fd

Please sign in to comment.