Apache Kafka - K8s
- Canonical
- Databases
Channel | Revision | Published | Runs on |
---|---|---|---|
latest/stable | 5 | 09 Mar 2022 | |
latest/edge | 27 | 25 Apr 2023 | |
latest/edge | 13 | 21 Oct 2022 | |
3/stable | 56 | 27 Feb 2024 | |
3/candidate | 56 | 27 Feb 2024 | |
3/beta | 56 | 27 Feb 2024 | |
3/edge | 74 | Today |
juju deploy kafka-k8s --channel 3/stable
Deploy Kubernetes operators easily with Juju, the Universal Operator Lifecycle Manager. Need a Kubernetes cluster? Install MicroK8s to create a full CNCF-certified Kubernetes system in under 60 seconds.
Platform:
charms.kafka_k8s.v0.kafka
-
- Last updated 04 Mar 2022
- Revision Library version 0.4
Kafka library.
This library implements both sides of the
kafka
interface.
The provider side of this interface is implemented by the kafka-k8s Charmed Operator.
Any Charmed Operator that requires Kafka for providing its service should implement the requirer side of this interface.
In a nutshell using this library to implement a Charmed Operator requiring Kafka would look like
$ charmcraft fetch-lib charms.kafka_k8s.v0.kafka
metadata.yaml
:
requires:
kafka:
interface: kafka
limit: 1
src/charm.py
:
from charms.kafka_k8s.v0.kafka import KafkaEvents, KafkaRequires
from ops.charm import CharmBase
class MyCharm(CharmBase):
on = KafkaEvents()
def __init__(self, *args):
super().__init__(*args)
self.kafka = KafkaRequires(self)
self.framework.observe(
self.on.kafka_available,
self._on_kafka_available,
)
self.framework.observe(
self.on["kafka"].relation_broken,
self._on_kafka_broken,
)
def _on_kafka_available(self, event):
# Get Kafka host and port
host: str = self.kafka.host
port: int = self.kafka.port
# host => "kafka-k8s"
# port => 9092
def _on_kafka_broken(self, event):
# Stop service
# ...
self.unit.status = BlockedStatus("need kafka relation")
You can file bugs here!
Index
class KafkaEvents
Kafka events.
Description
This class defines the events that Kafka can emit.
Events: kafka_available (_KafkaAvailableEvent)
class KafkaRequires
Description
Requires-side of the Kafka relation. None
Methods
KafkaRequires. __init__( self , charm: CharmBase , endpoint_name: str )
KafkaRequires. host( self )
Description
Get kafka hostname. None
KafkaRequires. port( self )
Description
Get kafka port number. None
class KafkaProvides
Description
Provides-side of the Kafka relation. None
Methods
KafkaProvides. __init__( self , charm: CharmBase , endpoint_name: str )
KafkaProvides. set_host_info( self , host: str , port: int , relation )
Set Kafka host and port.
Arguments
Kafka hostname or IP address.
Kafka port.
Relation to update. If not specified, all relations will be updated.
Description
This function writes in the application data of the relation, therefore, only the unit leader can call it.