logging-operator
This operator is in charge of handling the setup and configuration of the logging stack at Giant Swarm.
It reconciles cluster.cluster.x-k8s.io
objects and makes sure each Cluster
is provided with a promtail
instance and the necessary configuration to ship logs into loki
.
Getting started
Get the code and build it via:
git clone https://github.com/giantswarm/logging-operator.git
cd logging-operator
make
See make help
for help.
Architecture
The operator is built around a central reconciler, that calls multiple sub-reconcilers sequentially.
- Logging-Credentials are created if they don't exist. Then, their data (credentials) is used to create the next resources.
- grafana datasource configures Grafana to read data from Loki
- loki-multi-tenant-auth secures all Loki communication (per-tenant read/write access)
- promtail client configures write access to Loki for Promtail
- Promtail config setups some Promtail settings (like which logs to collect)
- Promtail toggle enables/disables promtail deployment on WCs
- Promtail wiring ensures promtail-app reads configs from previous steps
Gathering logs from WCs
When the need to gather logs from the WCs appears, the logging-operator will deploy promtail on those so that one may see the logs from the MC's grafana. In order to achieve that, one has to label the cluster(s) one wants to gather logs from thanks to the following command :
kubectl label cluster -n <wc_namespace> <wc_name> giantswarm.io/logging=true
Credits
This operator was built using kubebuilder
.