canonical / grafana-agent-operator

https://charmhub.io/grafana-agent
Apache License 2.0
4 stars 11 forks source link

feat: support external ca from cloud-integrator #206

Closed lucabello closed 1 week ago

lucabello commented 1 week ago

Issue

This PR partially is in tandem with the PR https://github.com/canonical/grafana-cloud-integrator/pull/21 and should be merged after.

It also fixes (partially) https://github.com/canonical/grafana-cloud-integrator/issues/18 (I'm also opening a PR in the k8s charm).

⚠️ Do NOT merge before the other one, it contains the (yet) unreleased version of the cloud_config_requirer library.

Solution

grafana-cloud-integrator#21 (the PR for the CA issue) is addressed by saving the CA coming from relation data to file, and then calling update-ca-certificates as usual. We do this on the custom cloud-config-available event, which is emitted whenever there is a relation joined/changed/broken involving the cloud-integrator relation.

grafana-cloud-integrator#18 (the config issue) is solved by populating the _loki_config not only if there are endpoints coming from self._loki_consumer, but also considering the ones coming from the cloud integrator (self._cloud.loki_ready). The endpoints themselves are already included in self._loki_endpoints_with_tls().

Testing Instructions

The code is exactly the same as for the k8s charm, but feel free to replicate the testing instructions with the grafana-agent machine charm.

lucabello commented 1 week ago

I have tested this manually, and everything works fine :)