Charmed PostgreSQL K8s

Channel Revision Published Runs on
latest/stable 20 20 Sep 2022
Ubuntu 20.04
14/stable 73 18 Apr 2023
Ubuntu 22.04
14/candidate 139 19 Sep 2023
14/beta 145 26 Sep 2023
14/edge 148 Today
juju deploy postgresql-k8s --channel 14/stable
Show information


How to enable monitoring

Warning: The feature is currently available in the channels 14/candidate only (revision 96+) and will be released to the channel 14/stable soon.

Enable monitoring requires that you:

Switch to COS K8s environment and offer COS interfaces to be cross-model related with Charmed PostgreSQL K8s model:

# Switch to Kubernetes controller, for the cos model.
juju switch <k8s_cos_controller>:<cos_model_name>

juju offer grafana:grafana-dashboard
juju offer loki:logging
juju offer prometheus:receive-remote-write

Switch to Charmed PostgreSQL K8s model, find offers and consume them:

# We are on the Kubernetes controller, for the cos model. Switch to postgresql model
juju switch <k8s_db_controller>:<postgresql_model_name>

juju find-offers <k8s_cos_controller>: # Do not miss ':' here!

A similar output should appear, if k8s is the k8s controller name and cos the model where cos-lite has been deployed:

Store  URL                    Access  Interfaces
k8s    admin/cos:grafana      admin   grafana:grafana-dashboard
k8s    admin/cos.loki         admin   loki:logging
k8s    admin/cos.prometheus   admin   prometheus:receive-remote-write

Consume offers to be reachable in the current model:

juju consume <k8s_cos_controller>:admin/cos.grafana
juju consume <k8s_cos_controller>:admin/cos.loki
juju consume <k8s_cos_controller>:admin/cos.prometheus

Now, deploy ‘grafana-agent-k8s’ and integrate (relate) it with Charmed PostgreSQL K8s, later integrate (relate) grafana-agent-k8s with consumed COS offers:

juju deploy grafana-agent-k8s --trust

juju relate grafana-agent-k8s grafana
juju relate grafana-agent-k8s loki
juju relate grafana-agent-k8s prometheus

juju relate grafana-agent-k8s postgresql-k8s:grafana-dashboard
juju relate grafana-agent-k8s postgresql-k8s:logging
juju relate grafana-agent-k8s postgresql-k8s:metrics-endpoint

After this is complete, Grafana will show the new dashboards: PostgreSQL Exporter and allows access for Charmed PostgreSQL logs on Loki.

The example of juju status on Charmed PostgreSQL K8s model:

Model    Controller  Cloud/Region        Version  SLA          Timestamp
welcome  microk8s    microk8s/localhost  3.1.6    unsupported  00:21:41+02:00

SAAS        Status  Store     URL
grafana     active  microk8s  admin/cos.grafana
loki        active  microk8s  admin/cos.loki
prometheus  active  microk8s  admin/cos.prometheus

App                Version  Status  Scale  Charm              Channel  Rev  Address         Exposed  Message
grafana-agent-k8s  0.32.1   active      1  grafana-agent-k8s  stable    42   no       
postgresql-k8s     14.9     active      3  postgresql-k8s     14/edge  145  no       

Unit                  Workload  Agent   Address       Ports  Message
grafana-agent-k8s/0*  active    idle         
postgresql-k8s/0      active    idle         
postgresql-k8s/1      active    idle         
postgresql-k8s/2*     active    idle         Primary

The example of juju status on COS K8s model:

Model  Controller  Cloud/Region        Version  SLA          Timestamp
cos    microk8s    microk8s/localhost  3.1.6    unsupported  00:21:19+02:00

App           Version  Status  Scale  Charm             Channel  Rev  Address         Exposed  Message
alertmanager  0.25.0   active      1  alertmanager-k8s  edge      91  no       
catalogue              active      1  catalogue-k8s     edge      27  no       
grafana       9.2.1    active      1  grafana-k8s       edge      92   no       
loki          2.7.4    active      1  loki-k8s          edge      99   no       
prometheus    2.46.0   active      1  prometheus-k8s    edge     149  no       
traefik       2.10.4   active      1  traefik-k8s       edge     155   no       

Unit             Workload  Agent  Address       Ports  Message
alertmanager/0*  active    idle         
catalogue/0*     active    idle         
grafana/0*       active    idle         
loki/0*          active    idle         
prometheus/0*    active    idle         
traefik/0*       active    idle         

Offer       Application  Charm           Rev  Connected  Endpoint              Interface                Role
grafana     grafana      grafana-k8s     92   1/1        grafana-dashboard     grafana_dashboard        requirer
loki        loki         loki-k8s        99   1/1        logging               loki_push_api            provider
prometheus  prometheus   prometheus-k8s  149  1/1        receive-remote-write  prometheus_remote_write  provider

To connect Grafana WEB interface, follow the COS section “Browse dashboards”:

juju run grafana/leader get-admin-password --model <k8s_cos_controller>:<cos_model_name>

Help us improve this documentation

Most of this documentation can be collaboratively discussed and changed on the respective topic in the doc category of the Charmhub forum. See the documentation guidelines if you’d like to contribute.

Last updated 15 hours ago. Help improve this document in the forum.