Skip to content

Commit

Permalink
Merge pull request #8 from canonical/base_charm
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoppenheimer authored Aug 8, 2022
2 parents 7edfaa6 + 421ef7d commit cb43ce4
Show file tree
Hide file tree
Showing 36 changed files with 1,608 additions and 11,241 deletions.
56 changes: 0 additions & 56 deletions .github/workflows/ci.yaml

This file was deleted.

78 changes: 44 additions & 34 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,53 @@

## Overview

This documents explains the processes and practices recommended for contributing enhancements to
the Kafka K8s charm.

- Generally, before developing enhancements to this charm, you should consider [opening an issue
](https://github.com/canonical/kafka-k8s-operator/issues) explaining your use case.
- If you would like to chat with us about your use-cases or proposed implementation, you can reach
us at [Canonical Mattermost public channel](https://chat.charmhub.io/charmhub/channels/charm-dev)
or [Discourse](https://discourse.charmhub.io/).
- Familiarising yourself with the [Charmed Operator Framework](https://juju.is/docs/sdk) library
will help you a lot when working on new features or bug fixes.
This documents explains the processes and practices recommended for contributing enhancements to this operator.

- Generally, before developing enhancements to this charm, you should consider [opening an issue](https://github.com/canonical/kafka-operator/issues) explaining your problem with examples, and your desired use case.
- If you would like to chat with us about your use-cases or proposed implementation, you can reach us at [Canonical Mattermost public channel](https://chat.charmhub.io/charmhub/channels/charm-dev) or [Discourse](https://discourse.charmhub.io/).
- Familiarising yourself with the [Charmed Operator Framework](https://juju.is/docs/sdk) library will help you a lot when working on new features or bug fixes.
- All enhancements require review before being merged. Code review typically examines
- code quality
- test coverage
- user experience for Juju administrators this charm.
- Please help us out in ensuring easy to review branches by rebasing your pull request branch onto
the `main` branch. This also avoids merge commits and creates a linear Git commit history.
- Please help us out in ensuring easy to review branches by rebasing your pull request branch onto the `main` branch. This also avoids merge commits and creates a linear Git commit history.

## Requirements

To build the charm locally, you will need to install [Charmcraft](https://juju.is/docs/sdk/install-charmcraft).

To run the charm locally with Juju, it is recommended to use [LXD](https://linuxcontainers.org/lxd/introduction/) as your virtual machine manager. Instructions for running Juju on LXD can be found [here](https://juju.is/docs/olm/lxd).

## Build and Deploy

To build the charm in this repository, from the root of the dir you can run:
Once you have Juju set up locally, to download, build and deploy the charm you can run:

### Deploy

```bash
# Clone and enter the repository
git clone https://github.com/canonical/kafka-k8s-operator.git
cd kafka-k8s-operator/

# Create a working model
juju add-model kafka-k8s

# Enable DEBUG logging for the model
juju model-config logging-config="<root>=INFO;unit=DEBUG"

# Build the charm locally
charmcraft pack

# Deploy the latest ZooKeeper release
juju deploy zookeeper-k8s --channel edge -n 3

# Deploy the charm
juju deploy ./*.charm -n 3

# After ZooKeeper has initialised, relate the applications
juju relate kafka-k8s zookeeper-k8s
```

## Developing

Expand All @@ -38,27 +69,6 @@ tox -e integration # integration tests
tox # runs 'lint' and 'unit' environments
```

## Build charm

Build the charm in this git repository using:

```shell
charmcraft pack
```

### Deploy

```bash
# Create a model
juju add-model test-kafka-k8s
# Enable DEBUG logging
juju model-config logging-config="<root>=INFO;unit=DEBUG"
# Deploy the charm
juju deploy ./kafka-k8s_ubuntu-20.04-amd64.charm \
--resource kafka-image=confluentinc/cp-kafka:7.0.1 \
--resource jmx-prometheus-jar=./jmx_prometheus_javaagent-0.15.0.jar
```

## Canonical Contributor Agreement

Canonical welcomes contributions to the Charmed Kafka K8s Operator. Please check out our [contributor agreement](https://ubuntu.com/legal/contributors) if you're interested in contributing to the solution.
Canonical welcomes contributions to the Charmed Kafka Kubernetes Operator. Please check out our [contributor agreement](https://ubuntu.com/legal/contributors) if you're interested in contributing to the solution.
121 changes: 28 additions & 93 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,108 +1,43 @@
<!-- Copyright 2022 Canonical Ltd.
See LICENSE file for licensing details. -->
## Kafka K8s Operator - a Charmed Operator for running Apache Kafka on Kubernetes from Canonical

# Kafka K8s Operator
This repository hosts the Kubernetes Python Operator for [Apache Kafka](https://kafka.apache.org).
The Kafka K8s Operator is a Python script that uses the latest upstream Kafka binaries released by the The Apache Software Foundation that comes with Kafka, made available using the [`ubuntu/kafka` OCI image](https://registry.hub.docker.com/r/ubuntu/kafka) distributed by Canonical.

[![code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black/tree/main)
[![Run-Tests](https://github.com/canonical/kafka-k8s-operator/actions/workflows/ci.yaml/badge.svg)](https://github.com/canonical/kafka-k8s-operator/actions/workflows/ci.yaml)
As currently Kafka requires a paired ZooKeeper deployment in production, this operator makes use of the [ZooKeeper K8s Operator](https://github.com/canonical/zookeeper-k8s-operator) for various essential functions.

[![Kafka K8s](https://charmhub.io/kafka-k8s/badge.svg)](https://charmhub.io/kafka-k8s)
### Usage

## Description
The Kafka and ZooKeeper operators can both be deployed and connected to each other using the Juju command line as follows:

Apache Kafka is an open-source distributed event streaming platform used by thousands of companies for high-performance data pipelines, streaming analytics, data integration, and mission-critical applications.

This repository contains a Charm Operator for deploying the Kafka in a Kubernetes cluster.

<!-- ## Tutorials
- -->

## How-to guides

### Deploy Kafka

The Kafka K8s Operator may be deployed using the Juju command line as in

```shell
$ juju add-model kafka-k8s
$ juju deploy kafka-k8s --trust
$ juju deploy zookeeper-k8s
```bash
$ juju deploy zookeeper-k8s -n 3
$ juju deploy kafka-k8s -n 3
$ juju relate kafka-k8s zookeeper-k8s
```

### Scale Kafka

Scale Kafka by executing the following command

```shell
$ juju scale-application kafka-k8s 3
```

## Integration with Canonical Observability Stack

This exporter can very easily be integrated with Canonical Observability Stack (COS).

To do so, after following the steps from the previous section, execute the following commands:

```shell
$ juju deploy cos-lite --channel beta --trust
$ juju upgrade-charm grafana --channel edge
$ juju relate grafana kafka-k8s
$ juju relate prometheus kafka-k8s
```

Wait until everything is deployed:
```shell
$ watch -c juju status --color
Model Controller Cloud/Region Version SLA Timestamp
kafka-k8s microk8s-localhost microk8s/localhost 2.9.25 unsupported 15:33:09+01:00

App Version Status Scale Charm Store Channel Rev OS Address Message
alertmanager waiting 1 alertmanager-k8s charmhub beta 9 kubernetes 10.152.183.185
grafana active 1 grafana-k8s charmhub edge 28 kubernetes 10.152.183.247
kafka-k8s active 1 kafka-k8s charmhub edge 0 kubernetes 10.152.183.25
loki active 1 loki-k8s charmhub beta 13 kubernetes 10.152.183.32
prometheus active 1 prometheus-k8s charmhub beta 19 kubernetes 10.152.183.211
zookeeper-k8s active 1 zookeeper-k8s charmhub edge 10 kubernetes 10.152.183.153

Unit Workload Agent Address Ports Message
alertmanager/0* active idle 10.1.245.86
grafana/0* active idle 10.1.245.101
kafka-k8s/0* active idle 10.1.245.68
loki/0* active idle 10.1.245.107
prometheus/0* active idle 10.1.245.82
zookeeper-k8s/0* active idle 10.1.245.81
```

To see the metrics, you can get the grafana admin password as follows:

```shell
$ juju run-action grafana/0 get-admin-password --wait
unit-grafana-0:
UnitId: grafana/0
id: "2"
results:
admin-password: *************
status: completed
timing:
completed: 2022-03-02 14:31:49 +0000 UTC
enqueued: 2022-03-02 14:31:39 +0000 UTC
started: 2022-03-02 14:31:48 +0000 UTC
```
## A fast and fault-tolerant, real-time event streaming platform!

Open your browser and go to the Grafana dashboard at port 3000.
Manual, Day 2 operations for deploying and operating Apache Kafka, topic creation, client authentication, ACL management and more are all handled automatically using the [Juju Operator Lifecycle Manager](https://juju.is/docs/olm).

## Reference
### Key Features
- SASL/SCRAM auth for Broker-Broker and Client-Broker authenticaion enabled by default.
- Access control management supported with user-provided ACL lists.
- Fault-tolerance, replication and high-availability out-of-the-box.
- Streamlined topic-creation through [Juju Actions](https://juju.is/docs/olm/working-with-actions) and [application relations](https://juju.is/docs/olm/relations)

- [Kafka documentation](https://kafka.apache.org/documentation/)
- [OCI image](https://hub.docker.com/r/confluentinc/cp-kafka): currently using tag `7.0.1`.

## Explanation
### Checklist

- [What is Apache Kafka?](https://kafka.apache.org/intro)
- [x] Super-user creation
- [x] Inter-broker auth
- [x] Horizontally scale brokers
- [x] Username/Password creation for related applications
- [ ] Automatic topic creation with associated user ACLs
- [ ] Partition rebalancing during broker scaling
- [ ] Rack awareness support
- [ ] Persistent storage support with [Juju Storage](https://juju.is/docs/olm/defining-and-using-persistent-storage)
- [ ] TLS/SSL support

## Contributing
## Usage

Please see the [Juju SDK docs](https://juju.is/docs/sdk) for guidelines
on enhancements to this charm following best practice guidelines, and
`CONTRIBUTING.md` for developer guidance.
This charm is still in active development. If you would like to contribute, please refer to [CONTRIBUTING.md](https://github.com/canonical/kafka-k8s-operator/blob/main/CONTRIBUTING.md)
Loading

0 comments on commit cb43ce4

Please sign in to comment.