Consul K8s Operator
- OpenStack Charmers
Channel | Revision | Published | Runs on |
---|---|---|---|
latest/edge | 3 | 10 Oct 2024 | |
1.19/edge | 3 | 17 Oct 2024 |
juju deploy consul-k8s --channel edge
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.consul_k8s.v0.consul_cluster
-
- Last updated 03 Oct 2024
- Revision Library version 0.1
ConsulCluster Provides and Requires module.
This library contains Provider and Requirer classes for consul-cluster interface.
The provider side updates relation data with the endpoints information required by consul agents running in client mode or consul users/clients.
The requirer side receives the endpoints via relation data. Example on how to use Requirer side using this library.
Import ConsulEndpointsRequirer
in your charm, with the charm object and the
relation name:
- self
- "consul-cluster"
Two events are also available to respond to: - endpoints_changed - goneaway
A basic example showing the usage of this relation follows:
from charms.consul_k8s.v0.consul_cluster import (
ConsulEndpointsRequirer
)
class ConsulClientCharm(CharmBase):
def __init__(self, *args):
super().__init__(*args)
# ConsulCluster Requires
self.consul = ConsulEdnpointsRequirer(
self, "consul-cluster",
)
self.framework.observe(
self.consul.on.endpoints_changed,
self._on_consul_service_endpoints_changed
)
self.framework.observe(
self.consul.on.goneaway,
self._on_consul_service_goneaway
)
def _on_consul_service_endpoints_changed(self, event):
'''React to the Consul service endpoints changed event.
This event happens when consul-cluster relation is added to the
model and relation data is changed.
'''
# Do something with the endpoints provided by relation.
pass
def _on_consul_service_goneaway(self, event):
'''React to the ConsulService goneaway event.
This event happens when consul-cluster relation is removed.
'''
# ConsulService Relation has goneaway.
pass
Index
class ConsulServiceProviderAppData
Description
Cluster endpoints from Consul server. None
Methods
ConsulServiceProviderAppData. convert_str_to_list_of_str( cls , v: str )
Description
Convert string field to list of str. None
ConsulServiceProviderAppData. convert_str_null_to_none( cls , v: str )
Description
Convert null string to None. None
class ClusterEndpointsChangedEvent
Description
Consul cluster endpoints changed event. None
class ClusterServerGoneAwayEvent
Description
Cluster server relation gone away event. None
class ConsulEndpointsRequirerEvents
Description
Consul Cluster requirer events. None
class ConsulEndpointsRequirer
Description
Class to be instantiated on the requirer side of the relation. None
Methods
ConsulEndpointsRequirer. __init__( self , charm: CharmBase , relation_name: str )
ConsulEndpointsRequirer. datacenter( self )
Description
Return datacenter name from provider app data. None
ConsulEndpointsRequirer. internal_gossip_endpoints( self )
Description
Return internal gossip endpoints from provider app data. None
ConsulEndpointsRequirer. external_gossip_endpoints( self )
Description
Return external gossip endpoints from provider app data. None
ConsulEndpointsRequirer. internal_http_endpoint( self )
Description
Return internal http endpoint from provider app data. None
ConsulEndpointsRequirer. external_http_endpoint( self )
Description
Return external http endpoint from provider app data. None
class ClusterEndpointsRequestEvent
Description
Consul cluster endpoints request event. None
class ConsulServiceProviderEvents
Description
Events class for on
. None
class ConsulServiceProvider
Description
Class to be instantiated on the provider side of the relation. None
Methods
ConsulServiceProvider. __init__( self , charm: CharmBase , relation_name: str )
ConsulServiceProvider. set_cluster_endpoints( self , relation , datacenter: str , internal_gossip_endpoints , external_gossip_endpoints , internal_http_endpoint , external_http_endpoint )
Set consul cluster endpoints on the relation.
Description
If relation is None, send cluster endpoints on all related units.