diff --git a/product_docs/docs/postgres_for_kubernetes/1/benchmarking.mdx b/product_docs/docs/postgres_for_kubernetes/1/benchmarking.mdx index cb90ac72b44..0884e13a29e 100644 --- a/product_docs/docs/postgres_for_kubernetes/1/benchmarking.mdx +++ b/product_docs/docs/postgres_for_kubernetes/1/benchmarking.mdx @@ -55,7 +55,7 @@ kubectl cnp pgbench \ You can see the progress of the job with: -```shell  +```shell kubectl logs jobs/pgbench-run ``` diff --git a/product_docs/docs/postgres_for_kubernetes/1/bootstrap.mdx b/product_docs/docs/postgres_for_kubernetes/1/bootstrap.mdx index 427408ac4fa..62e64f500ae 100644 --- a/product_docs/docs/postgres_for_kubernetes/1/bootstrap.mdx +++ b/product_docs/docs/postgres_for_kubernetes/1/bootstrap.mdx @@ -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. diff --git a/product_docs/docs/postgres_for_kubernetes/1/default-monitoring.yaml b/product_docs/docs/postgres_for_kubernetes/1/default-monitoring.yaml new file mode 100644 index 00000000000..08dd66346a8 --- /dev/null +++ b/product_docs/docs/postgres_for_kubernetes/1/default-monitoring.yaml @@ -0,0 +1,383 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: default-monitoring + labels: + k8s.enterprisedb.io/reload: "" +data: + queries: | + backends: + query: | + SELECT sa.datname + , sa.usename + , sa.application_name + , states.state + , COALESCE(sa.count, 0) AS total + , COALESCE(sa.max_tx_secs, 0) AS max_tx_duration_seconds + FROM ( VALUES ('active') + , ('idle') + , ('idle in transaction') + , ('idle in transaction (aborted)') + , ('fastpath function call') + , ('disabled') + ) AS states(state) + LEFT JOIN ( + SELECT datname + , state + , usename + , COALESCE(application_name, '') AS application_name + , COUNT(*) + , COALESCE(EXTRACT (EPOCH FROM (max(now() - xact_start))), 0) AS max_tx_secs + FROM pg_catalog.pg_stat_activity + GROUP BY datname, state, usename, application_name + ) sa ON states.state = sa.state + WHERE sa.usename IS NOT NULL + metrics: + - datname: + usage: "LABEL" + description: "Name of the database" + - usename: + usage: "LABEL" + description: "Name of the user" + - application_name: + usage: "LABEL" + description: "Name of the application" + - state: + usage: "LABEL" + description: "State of the backend" + - total: + usage: "GAUGE" + description: "Number of backends" + - max_tx_duration_seconds: + usage: "GAUGE" + description: "Maximum duration of a transaction in seconds" + + backends_waiting: + query: | + SELECT count(*) AS total + FROM pg_catalog.pg_locks blocked_locks + JOIN pg_catalog.pg_locks blocking_locks + ON blocking_locks.locktype = blocked_locks.locktype + AND blocking_locks.database IS NOT DISTINCT FROM blocked_locks.database + AND blocking_locks.relation IS NOT DISTINCT FROM blocked_locks.relation + AND blocking_locks.page IS NOT DISTINCT FROM blocked_locks.page + AND blocking_locks.tuple IS NOT DISTINCT FROM blocked_locks.tuple + AND blocking_locks.virtualxid IS NOT DISTINCT FROM blocked_locks.virtualxid + AND blocking_locks.transactionid IS NOT DISTINCT FROM blocked_locks.transactionid + AND blocking_locks.classid IS NOT DISTINCT FROM blocked_locks.classid + AND blocking_locks.objid IS NOT DISTINCT FROM blocked_locks.objid + AND blocking_locks.objsubid IS NOT DISTINCT FROM blocked_locks.objsubid + AND blocking_locks.pid != blocked_locks.pid + JOIN pg_catalog.pg_stat_activity blocking_activity ON blocking_activity.pid = blocking_locks.pid + WHERE NOT blocked_locks.granted + metrics: + - total: + usage: "GAUGE" + description: "Total number of backends that are currently waiting on other queries" + + pg_database: + query: | + SELECT datname + , pg_catalog.pg_database_size(datname) AS size_bytes + , pg_catalog.age(datfrozenxid) AS xid_age + , pg_catalog.mxid_age(datminmxid) AS mxid_age + FROM pg_catalog.pg_database + metrics: + - datname: + usage: "LABEL" + description: "Name of the database" + - size_bytes: + usage: "GAUGE" + description: "Disk space used by the database" + - xid_age: + usage: "GAUGE" + description: "Number of transactions from the frozen XID to the current one" + - mxid_age: + usage: "GAUGE" + description: "Number of multiple transactions (Multixact) from the frozen XID to the current one" + + pg_postmaster: + query: | + SELECT EXTRACT(EPOCH FROM pg_postmaster_start_time) AS start_time + FROM pg_catalog.pg_postmaster_start_time() + metrics: + - start_time: + usage: "GAUGE" + description: "Time at which postgres started (based on epoch)" + + pg_replication: + query: "SELECT CASE WHEN ( + NOT pg_catalog.pg_is_in_recovery() + OR pg_catalog.pg_last_wal_receive_lsn() = pg_catalog.pg_last_wal_replay_lsn()) + THEN 0 + ELSE GREATEST (0, + EXTRACT(EPOCH FROM (now() - pg_catalog.pg_last_xact_replay_timestamp()))) + END AS lag, + pg_catalog.pg_is_in_recovery() AS in_recovery, + EXISTS (TABLE pg_stat_wal_receiver) AS is_wal_receiver_up, + (SELECT count(*) FROM pg_catalog.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_replication_slots: + primary: true + query: | + SELECT slot_name, + slot_type, + database, + active, + pg_catalog.pg_wal_lsn_diff(pg_catalog.pg_current_wal_lsn(), restart_lsn) + FROM pg_catalog.pg_replication_slots + WHERE NOT temporary + metrics: + - slot_name: + usage: "LABEL" + description: "Name of the replication slot" + - slot_type: + usage: "LABEL" + description: "Type of the replication slot" + - database: + usage: "LABEL" + description: "Name of the database" + - active: + usage: "GAUGE" + description: "Flag indicating whether the slot is active" + - pg_wal_lsn_diff: + usage: "GAUGE" + description: "Replication lag in bytes" + + pg_stat_archiver: + query: | + SELECT archived_count + , failed_count + , COALESCE(EXTRACT(EPOCH FROM (now() - last_archived_time)), -1) AS seconds_since_last_archival + , COALESCE(EXTRACT(EPOCH FROM (now() - last_failed_time)), -1) AS seconds_since_last_failure + , COALESCE(EXTRACT(EPOCH FROM last_archived_time), -1) AS last_archived_time + , COALESCE(EXTRACT(EPOCH FROM last_failed_time), -1) AS last_failed_time + , COALESCE(CAST(CAST('x'||pg_catalog.right(pg_catalog.split_part(last_archived_wal, '.', 1), 16) AS pg_catalog.bit(64)) AS pg_catalog.int8), -1) AS last_archived_wal_start_lsn + , COALESCE(CAST(CAST('x'||pg_catalog.right(pg_catalog.split_part(last_failed_wal, '.', 1), 16) AS pg_catalog.bit(64)) AS pg_catalog.int8), -1) AS last_failed_wal_start_lsn + , EXTRACT(EPOCH FROM stats_reset) AS stats_reset_time + FROM pg_catalog.pg_stat_archiver + metrics: + - archived_count: + usage: "COUNTER" + description: "Number of WAL files that have been successfully archived" + - failed_count: + usage: "COUNTER" + description: "Number of failed attempts for archiving WAL files" + - seconds_since_last_archival: + usage: "GAUGE" + description: "Seconds since the last successful archival operation" + - seconds_since_last_failure: + usage: "GAUGE" + description: "Seconds since the last failed archival operation" + - last_archived_time: + usage: "GAUGE" + description: "Epoch of the last time WAL archiving succeeded" + - last_failed_time: + usage: "GAUGE" + description: "Epoch of the last time WAL archiving failed" + - last_archived_wal_start_lsn: + usage: "GAUGE" + description: "Archived WAL start LSN" + - last_failed_wal_start_lsn: + usage: "GAUGE" + description: "Last failed WAL LSN" + - stats_reset_time: + usage: "GAUGE" + description: "Time at which these statistics were last reset" + + pg_stat_bgwriter: + query: | + SELECT checkpoints_timed + , checkpoints_req + , checkpoint_write_time + , checkpoint_sync_time + , buffers_checkpoint + , buffers_clean + , maxwritten_clean + , buffers_backend + , buffers_backend_fsync + , buffers_alloc + FROM pg_catalog.pg_stat_bgwriter + metrics: + - checkpoints_timed: + usage: "COUNTER" + description: "Number of scheduled checkpoints that have been performed" + - checkpoints_req: + usage: "COUNTER" + description: "Number of requested checkpoints that have been performed" + - checkpoint_write_time: + usage: "COUNTER" + description: "Total amount of time that has been spent in the portion of checkpoint processing where files are written to disk, in milliseconds" + - checkpoint_sync_time: + usage: "COUNTER" + description: "Total amount of time that has been spent in the portion of checkpoint processing where files are synchronized to disk, in milliseconds" + - buffers_checkpoint: + usage: "COUNTER" + description: "Number of buffers written during checkpoints" + - buffers_clean: + usage: "COUNTER" + description: "Number of buffers written by the background writer" + - maxwritten_clean: + usage: "COUNTER" + description: "Number of times the background writer stopped a cleaning scan because it had written too many buffers" + - buffers_backend: + usage: "COUNTER" + description: "Number of buffers written directly by a backend" + - buffers_backend_fsync: + usage: "COUNTER" + description: "Number of times a backend had to execute its own fsync call (normally the background writer handles those even when the backend does its own write)" + - buffers_alloc: + usage: "COUNTER" + description: "Number of buffers allocated" + + pg_stat_database: + query: | + SELECT datname + , xact_commit + , xact_rollback + , blks_read + , blks_hit + , tup_returned + , tup_fetched + , tup_inserted + , tup_updated + , tup_deleted + , conflicts + , temp_files + , temp_bytes + , deadlocks + , blk_read_time + , blk_write_time + FROM pg_catalog.pg_stat_database + metrics: + - datname: + usage: "LABEL" + description: "Name of this database" + - xact_commit: + usage: "COUNTER" + description: "Number of transactions in this database that have been committed" + - xact_rollback: + usage: "COUNTER" + description: "Number of transactions in this database that have been rolled back" + - blks_read: + usage: "COUNTER" + description: "Number of disk blocks read in this database" + - blks_hit: + usage: "COUNTER" + description: "Number of times disk blocks were found already in the buffer cache, so that a read was not necessary (this only includes hits in the PostgreSQL buffer cache, not the operating system's file system cache)" + - tup_returned: + usage: "COUNTER" + description: "Number of rows returned by queries in this database" + - tup_fetched: + usage: "COUNTER" + description: "Number of rows fetched by queries in this database" + - tup_inserted: + usage: "COUNTER" + description: "Number of rows inserted by queries in this database" + - tup_updated: + usage: "COUNTER" + description: "Number of rows updated by queries in this database" + - tup_deleted: + usage: "COUNTER" + description: "Number of rows deleted by queries in this database" + - conflicts: + usage: "COUNTER" + description: "Number of queries canceled due to conflicts with recovery in this database" + - temp_files: + usage: "COUNTER" + description: "Number of temporary files created by queries in this database" + - temp_bytes: + usage: "COUNTER" + description: "Total amount of data written to temporary files by queries in this database" + - deadlocks: + usage: "COUNTER" + description: "Number of deadlocks detected in this database" + - blk_read_time: + usage: "COUNTER" + description: "Time spent reading data file blocks by backends in this database, in milliseconds" + - blk_write_time: + usage: "COUNTER" + description: "Time spent writing data file blocks by backends in this database, in milliseconds" + + pg_stat_replication: + primary: true + query: | + SELECT usename + , COALESCE(application_name, '') AS application_name + , COALESCE(client_addr::text, '') AS client_addr + , EXTRACT(EPOCH FROM backend_start) AS backend_start + , COALESCE(pg_catalog.age(backend_xmin), 0) AS backend_xmin_age + , pg_catalog.pg_wal_lsn_diff(pg_catalog.pg_current_wal_lsn(), sent_lsn) AS sent_diff_bytes + , pg_catalog.pg_wal_lsn_diff(pg_catalog.pg_current_wal_lsn(), write_lsn) AS write_diff_bytes + , pg_catalog.pg_wal_lsn_diff(pg_catalog.pg_current_wal_lsn(), flush_lsn) AS flush_diff_bytes + , COALESCE(pg_catalog.pg_wal_lsn_diff(pg_catalog.pg_current_wal_lsn(), replay_lsn),0) AS replay_diff_bytes + , COALESCE((EXTRACT(EPOCH FROM write_lag)),0)::float AS write_lag_seconds + , COALESCE((EXTRACT(EPOCH FROM flush_lag)),0)::float AS flush_lag_seconds + , COALESCE((EXTRACT(EPOCH FROM replay_lag)),0)::float AS replay_lag_seconds + FROM pg_catalog.pg_stat_replication + metrics: + - usename: + usage: "LABEL" + description: "Name of the replication user" + - application_name: + usage: "LABEL" + description: "Name of the application" + - client_addr: + usage: "LABEL" + description: "Client IP address" + - backend_start: + usage: "COUNTER" + description: "Time when this process was started" + - backend_xmin_age: + usage: "COUNTER" + description: "The age of this standby's xmin horizon" + - sent_diff_bytes: + usage: "GAUGE" + description: "Difference in bytes from the last write-ahead log location sent on this connection" + - write_diff_bytes: + usage: "GAUGE" + description: "Difference in bytes from the last write-ahead log location written to disk by this standby server" + - flush_diff_bytes: + usage: "GAUGE" + description: "Difference in bytes from the last write-ahead log location flushed to disk by this standby server" + - replay_diff_bytes: + usage: "GAUGE" + description: "Difference in bytes from the last write-ahead log location replayed into the database on this standby server" + - write_lag_seconds: + usage: "GAUGE" + description: "Time elapsed between flushing recent WAL locally and receiving notification that this standby server has written it" + - flush_lag_seconds: + usage: "GAUGE" + description: "Time elapsed between flushing recent WAL locally and receiving notification that this standby server has written and flushed it" + - replay_lag_seconds: + usage: "GAUGE" + description: "Time elapsed between flushing recent WAL locally and receiving notification that this standby server has written, flushed and applied it" + + pg_settings: + query: | + SELECT name, + CASE setting WHEN 'on' THEN '1' WHEN 'off' THEN '0' ELSE setting END AS setting + FROM pg_catalog.pg_settings + WHERE vartype IN ('integer', 'real', 'bool') + ORDER BY 1 + metrics: + - name: + usage: "LABEL" + description: "Name of the setting" + - setting: + usage: "GAUGE" + description: "Setting value" diff --git a/product_docs/docs/postgres_for_kubernetes/1/installation_upgrade.mdx b/product_docs/docs/postgres_for_kubernetes/1/installation_upgrade.mdx index 421ac797426..0cfb10c663b 100644 --- a/product_docs/docs/postgres_for_kubernetes/1/installation_upgrade.mdx +++ b/product_docs/docs/postgres_for_kubernetes/1/installation_upgrade.mdx @@ -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. diff --git a/product_docs/docs/postgres_for_kubernetes/1/kubectl-plugin.mdx b/product_docs/docs/postgres_for_kubernetes/1/kubectl-plugin.mdx index db070492918..84a5744a4e3 100644 --- a/product_docs/docs/postgres_for_kubernetes/1/kubectl-plugin.mdx +++ b/product_docs/docs/postgres_for_kubernetes/1/kubectl-plugin.mdx @@ -941,4 +941,4 @@ A specific `VolumeSnapshotClass` can be requested via the `-c` option: ```shell kubectl cnp snapshot cluster-example -c longhorn -``` +``` \ No newline at end of file diff --git a/product_docs/docs/postgres_for_kubernetes/1/monitoring.mdx b/product_docs/docs/postgres_for_kubernetes/1/monitoring.mdx index fb3688fb605..2221bd3cb0d 100644 --- a/product_docs/docs/postgres_for_kubernetes/1/monitoring.mdx +++ b/product_docs/docs/postgres_for_kubernetes/1/monitoring.mdx @@ -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 @@ -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) +[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 @@ -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 @@ -543,7 +543,7 @@ Here is a short description of all the available fields: - ``: 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 + - `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) - `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"`) @@ -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/1/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. diff --git a/product_docs/docs/postgres_for_kubernetes/1/openshift.mdx b/product_docs/docs/postgres_for_kubernetes/1/openshift.mdx index 4dec98b6713..cb417fda042 100644 --- a/product_docs/docs/postgres_for_kubernetes/1/openshift.mdx +++ b/product_docs/docs/postgres_for_kubernetes/1/openshift.mdx @@ -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. diff --git a/product_docs/docs/postgres_for_kubernetes/1/operator_conf.mdx b/product_docs/docs/postgres_for_kubernetes/1/operator_conf.mdx index 6e71212990d..8097d31b22b 100644 --- a/product_docs/docs/postgres_for_kubernetes/1/operator_conf.mdx +++ b/product_docs/docs/postgres_for_kubernetes/1/operator_conf.mdx @@ -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 ``` @@ -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 -- bash ``` Once inside execute: -``` +```shell curl localhost:6060/debug/pprof/ ``` \ No newline at end of file diff --git a/product_docs/docs/postgres_for_kubernetes/1/quickstart.mdx b/product_docs/docs/postgres_for_kubernetes/1/quickstart.mdx index 35647edd10c..881fb86b8fa 100644 --- a/product_docs/docs/postgres_for_kubernetes/1/quickstart.mdx +++ b/product_docs/docs/postgres_for_kubernetes/1/quickstart.mdx @@ -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/1/samples/monitoring/kube-stack-config.yaml \ prometheus-community \ prometheus-community/kube-prometheus-stack ``` @@ -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/1/samples/monitoring/prometheusrule.yaml ``` You should see the default alerts now: @@ -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/1/samples/monitoring/grafana-configmap.yaml ``` Which will be picked up by the Grafana page in a few seconds. You should now diff --git a/product_docs/docs/postgres_for_kubernetes/1/samples/monitoring/cnp-operator-podmonitor.yaml b/product_docs/docs/postgres_for_kubernetes/1/samples/monitoring/podmonitor.yaml similarity index 100% rename from product_docs/docs/postgres_for_kubernetes/1/samples/monitoring/cnp-operator-podmonitor.yaml rename to product_docs/docs/postgres_for_kubernetes/1/samples/monitoring/podmonitor.yaml diff --git a/product_docs/docs/postgres_for_kubernetes/1/samples/monitoring/cnp-prometheusrule.yaml b/product_docs/docs/postgres_for_kubernetes/1/samples/monitoring/prometheusrule.yaml similarity index 100% rename from product_docs/docs/postgres_for_kubernetes/1/samples/monitoring/cnp-prometheusrule.yaml rename to product_docs/docs/postgres_for_kubernetes/1/samples/monitoring/prometheusrule.yaml diff --git a/product_docs/docs/postgres_for_kubernetes/1/security.mdx b/product_docs/docs/postgres_for_kubernetes/1/security.mdx index 642e4740e29..dad9841372d 100644 --- a/product_docs/docs/postgres_for_kubernetes/1/security.mdx +++ b/product_docs/docs/postgres_for_kubernetes/1/security.mdx @@ -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: diff --git a/scripts/fileProcessor/processors/cnp/replace-github-urls.mjs b/scripts/fileProcessor/processors/cnp/replace-github-urls.mjs new file mode 100644 index 00000000000..a3d366ae5fc --- /dev/null +++ b/scripts/fileProcessor/processors/cnp/replace-github-urls.mjs @@ -0,0 +1,22 @@ +// Replace URLs beginning with the following patterns... +// - https://raw.githubusercontent.com/EnterpriseDB/cloud-native-postgres/main/config/manager/default-monitoring.yaml +// - https://github.com/EnterpriseDB/cloud-native-postgres/tree/main/docs/ +// - https://raw.githubusercontent.com/EnterpriseDB/cloud-native-postgres/main/docs/src/ +// ...with equivalent URLs referencing postgres for kubernetes in the public EDB Docs repo + +const replacements = [ + {pattern: /https:\/\/raw\.githubusercontent\.com\/EnterpriseDB\/cloud-native-postgres\/main\/config\/manager\/default-monitoring\.yaml/g, replacement: "default-monitoring.yaml"}, + {pattern: /https:\/\/github\.com\/EnterpriseDB\/cloud-native-postgres\/tree\/main\/docs\/src\//g, replacement: "https://github.com/EnterpriseDB/docs/tree/main/product_docs/docs/postgres_for_kubernetes/1/"}, + {pattern: /https:\/\/github\.com\/EnterpriseDB\/cloud-native-postgres\/blob\/main\/docs\/src\//g, replacement: "https://github.com/EnterpriseDB/docs/blob/main/product_docs/docs/postgres_for_kubernetes/1/"}, + {pattern: /https:\/\/raw\.githubusercontent\.com\/EnterpriseDB\/cloud-native-postgres\/main\/docs\/src\//g, replacement: "https://raw.githubusercontent.com/EnterpriseDB/docs/main/product_docs/docs/postgres_for_kubernetes/1/"}, +]; + +export const process = (filename, content) => { + for (const r of replacements) + content = content.replace(r.pattern, r.replacement); + + return { + newFilename: filename, + newContent: content, + }; +}; diff --git a/scripts/source/process-cnp-docs.sh b/scripts/source/process-cnp-docs.sh index d70a4abeee1..b5df0948b2e 100755 --- a/scripts/source/process-cnp-docs.sh +++ b/scripts/source/process-cnp-docs.sh @@ -20,12 +20,16 @@ node $DESTINATION_CHECKOUT/scripts/source/files-to-ignore.mjs \ cd $SOURCE_CHECKOUT/docs +# grab key bit of source for use in docs +cp $SOURCE_CHECKOUT/config/manager/default-monitoring.yaml $SOURCE_CHECKOUT/docs/src/ + node $DESTINATION_CHECKOUT/scripts/fileProcessor/main.mjs \ -f "src/**/quickstart.md" \ -p cnp/add-quickstart-content node $DESTINATION_CHECKOUT/scripts/fileProcessor/main.mjs \ -f "src/**/*.md" \ + -p "cnp/replace-github-urls" \ -p "cnp/update-yaml-links" \ -p "cnp/add-frontmatters" \ -p "cnp/rename-to-mdx" diff --git a/scripts/source/process-pgd4k-docs.sh b/scripts/source/process-pgd4k-docs.sh index 11ad5d9aa28..052c5db1d1a 100755 --- a/scripts/source/process-pgd4k-docs.sh +++ b/scripts/source/process-pgd4k-docs.sh @@ -22,6 +22,7 @@ cd $SOURCE_CHECKOUT/docs node $DESTINATION_CHECKOUT/scripts/fileProcessor/main.mjs \ -f "src/**/*.md" \ + -p "cnp/replace-github-urls" \ -p "cnp/update-yaml-links" \ -p "cnp/add-frontmatters" \ -p "cnp/rename-to-mdx"