@@ -1068,11 +1068,12 @@ the configuration settings.
10681068
10691069The `kubectl cnpg psql CLUSTER` command starts a new PostgreSQL interactive front-end
10701070process (psql) connected to an existing Postgres cluster, as if you were running
1071- it from the actual pod. This means that you will be using the `postgres` user.
1071+ it from the actual pod. This means that you will be using the `postgres` user and connecting
1072+ to the `postgres` database.
10721073
10731074:::info[Important]
1074- As you will be connecting as `postgres` user, in production environments this
1075- method should be used with extreme care, by authorized personnel only.
1075+ As you will be connecting as `postgres` user, in production environments this
1076+ method should be used with extreme care, by authorized personnel only.
10761077:: :
10771078
10781079` ` ` console
@@ -1106,6 +1107,29 @@ postgres=# \q
11061107This command will start `kubectl exec`, and the `kubectl` executable must be
11071108reachable in your `PATH` variable to correctly work.
11081109
1110+ By default, the `postgres` database will be used. Any option supported by
1111+ ` psql` can be passed after the `--` delimiter. For example, to connect to a
1112+ specific database :
1113+
1114+ ` ` ` console
1115+ $ kubectl cnpg psql cluster-example -- app
1116+
1117+ psql (18.3 (Debian 18.3-1.pgdg110+1))
1118+ Type "help" for help.
1119+
1120+ app=#
1121+ ` ` `
1122+
1123+ Also, you can directly execute a query with the psql option `-c`.
1124+
1125+ ` ` ` console
1126+ $ kubectl cnpg psql cluster-example -- -c "SELECT pg_is_in_recovery();"
1127+ pg_is_in_recovery
1128+ -------------------
1129+ f
1130+ (1 row)
1131+ ` ` `
1132+
11091133# ## Snapshotting a Postgres cluster
11101134
11111135:::warning
@@ -1571,4 +1595,4 @@ rules:
15711595:::info[Important]
15721596 Keeping the verbs restricted per `resources` and per `apiGroups` helps to
15731597 prevent inadvertently granting more than intended permissions.
1574- :::
1598+ :: :
0 commit comments