Skip to content

Commit

Permalink
Add o11y integrations (#69)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Barry <[email protected]>
  • Loading branch information
sed-i and rbarry82 authored Mar 17, 2023
1 parent 2959b94 commit 4151006
Show file tree
Hide file tree
Showing 20 changed files with 1,506 additions and 5,806 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ jobs:
# TODO: Replace with custom image on self-hosted runner
uses: charmed-kubernetes/actions-operator@main
with:
juju-channel: 2.9/stable
provider: lxd
bootstrap-options: "--agent-version 2.9.38"
bootstrap-options: "--agent-version 2.9.42"
- name: Download packed charm(s)
uses: actions/download-artifact@v3
with:
Expand Down
81 changes: 35 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ While the following requirements are meant to be for production, the charm can b
- 12 storage devices
- 10 GbE card

The charm is meant to be deployed using `juju>=2.9.37`.
The charm is meant to be deployed using `juju>=2.9.37`.

## Usage

Expand All @@ -54,7 +54,7 @@ $ juju relate kafka zookeeper

To watch the process, `juju status` can be used. Once all the units show as `active|idle` the credentials to access a broker can be queried with:
```shell
juju run-action kafka/leader get-admin-credentials --wait
juju run-action kafka/leader get-admin-credentials --wait
```

Apache Kafka ships with `bin/*.sh` commands to do various administrative tasks, e.g `bin/kafka-config.sh` to update cluster configuration, `bin/kafka-topics.sh` for topic management, and many more! The Kafka Charmed Operator provides these commands to administrators to easily run their desired cluster configurations securely with SASL authentication, either from within the cluster or as an external client.
Expand All @@ -65,7 +65,7 @@ BOOTSTRAP_SERVERS=$(juju run-action kafka/leader get-admin-credentials --wait |
juju ssh kafka/leader 'charmed-kafka.topics --bootstrap-server $BOOTSTRAP_SERVERS --list --command-config /var/snap/charmed-kafka/common/client.properties'
```

Note that when no other application is related to Kafka, the cluster is secured-by-default and listeners are disabled, thus preventing any incoming connection. However, even for running the commands above, listeners must be enable. If there is no other application, deploy a `data-integrator` charm and relate it to Kafka, as outlined in the Relation section to enable listeners.
Note that when no other application is related to Kafka, the cluster is secured-by-default and listeners are disabled, thus preventing any incoming connection. However, even for running the commands above, listeners must be enable. If there is no other application, deploy a `data-integrator` charm and relate it to Kafka, as outlined in the Relation section to enable listeners.

Available Kafka bin commands can be found with:
```
Expand Down Expand Up @@ -118,7 +118,7 @@ Supported [relations](https://juju.is/docs/olm/relations):

The `kafka_client` interface is used with the `data-integrator` charm. This charm allows to automatically create and manage product credentials needed to authenticate with different kinds of data platform charmed products:

Deploy the data-integrator charm with the desired `topic-name` and user roles:
Deploy the data-integrator charm with the desired `topic-name` and user roles:
```shell
juju deploy data-integrator --channel edge
juju config data-integrator topic-name=test-topic extra-user-roles=producer,consumer
Expand All @@ -136,23 +136,23 @@ juju run-action data-integrator/leader get-credentials --wait

This should output something like:
```yaml
unit-data-integrator-0:
UnitId: data-integrator/0
id: "4"
results:
kafka:
consumer-group-prefix: relation-27-
endpoints: 10.123.8.133:19092
password: ejMp4SblzxkMCF0yUXjaspneflXqcyXK
tls: disabled
username: relation-27
unit-data-integrator-0:
UnitId: data-integrator/0
id: "4"
results:
kafka:
consumer-group-prefix: relation-27-
endpoints: 10.123.8.133:19092
password: ejMp4SblzxkMCF0yUXjaspneflXqcyXK
tls: disabled
username: relation-27
zookeeper-uris: 10.123.8.154:2181,10.123.8.181:2181,10.123.8.61:2181/kafka
ok: "True"
status: completed
timing:
completed: 2023-01-27 14:22:51 +0000 UTC
enqueued: 2023-01-27 14:22:50 +0000 UTC
started: 2023-01-27 14:22:51 +0000 UTC
ok: "True"
status: completed
timing:
completed: 2023-01-27 14:22:51 +0000 UTC
enqueued: 2023-01-27 14:22:50 +0000 UTC
started: 2023-01-27 14:22:51 +0000 UTC
```
#### `tls-certificates` interface:
Expand All @@ -162,11 +162,11 @@ The `tls-certificates` interface is used with the `tls-certificates-operator` ch
To enable TLS:

```shell
# deploy the TLS charm
# deploy the TLS charm
juju deploy tls-certificates-operator --channel=edge
# add the necessary configurations for TLS
juju config tls-certificates-operator generate-self-signed-certificates="true" ca-common-name="Test CA"
# to enable TLS relate the two applications
juju config tls-certificates-operator generate-self-signed-certificates="true" ca-common-name="Test CA"
# to enable TLS relate the two applications
juju relate tls-certificates-operator zookeeper
juju relate tls-certificates-operator kafka
```
Expand Down Expand Up @@ -200,35 +200,24 @@ Note: The TLS settings here are for self-signed-certificates which are not recom

## Monitoring

The Charmed Kafka Operator comes with several exporters by default. The metrics can be queried by accessing the following endpoints:

- Node exporter: `http://<unit-ip>:9100/metrics`
- JMX exporter: `http://<unit-ip>:9101/metrics`
The Charmed Kafka Operator comes with the [JMX exporter](https://github.com/prometheus/jmx_exporter/).
The metrics can be queried by accessing the `http://<unit-ip>:9101/metrics` endpoints.

Additionally, the charm provides integration with the [Canonical Observability Stack](https://charmhub.io/topics/canonical-observability-stack).

Deploy cos-lite bundle in a Kubernetes environment. This can be done by following the [deployment tutorial](https://charmhub.io/topics/canonical-observability-stack/tutorials/install-microk8s). Since the Charmed Kafka Operator is deployed on a machine environment, it is needed to offer the endpoints of the COS relations. The [offers-overlay](https://github.com/canonical/cos-lite-bundle/blob/main/overlays/offers-overlay.yaml) can be used, and this step is shown on the COS tutorial.

Once COS is deployed, we can find the offers from the Kafka model:
```shell
# We are on the Kubernetes controller, for the cos model. Switch to kafka model
juju switch <machine_controller_name>:<kafka_model_name>
Deploy cos-lite bundle in a Kubernetes environment. This can be done by following the
[deployment tutorial](https://charmhub.io/topics/canonical-observability-stack/tutorials/install-microk8s).
Since the Charmed Kafka Operator is deployed on a machine environment, it is needed to offer the endpoints
of the COS relations. The [offers-overlay](https://github.com/canonical/cos-lite-bundle/blob/main/overlays/offers-overlay.yaml)
can be used, and this step is shown in the COS tutorial.

juju find-offers <k8s_controller_name>:
```

A similar output should appear, if `micro` is the k8s controller name and `cos` the model where `cos-lite` has been deployed:
```
Store URL Access Interfaces
micro admin/cos.grafana admin grafana_dashboard:grafana-dashboard
micro admin/cos.prometheus admin prometheus_scrape:metrics-endpoint
. . .
```
Next, deploy [grafana-agent](https://charmhub.io/grafana-agent) and follow the
[tutorial](https://discourse.charmhub.io/t/using-the-grafana-agent-machine-charm/8896)
to relate it to the COS Lite offers.

Now, relate kafka with the `metrics-endpoint` and `grafana-dashboard` interfaces:
Now, relate kafka with the grafana-agent:
```shell
juju relate micro:admin/cos.prometheus kafka
juju relate micro:admin/cos.grafana kafka
juju relate kafka grafana-agent
```

After this is complete, Grafana will show two new dashboards: `Kafka Metrics` and `Node Exporter Kafka`
Expand Down
Loading

0 comments on commit 4151006

Please sign in to comment.