Traefik Ingress Operator for Kubernetes
- Canonical Observability
Channel | Revision | Published | Runs on |
---|---|---|---|
latest/stable | 199 | 19 Nov 2024 | |
latest/candidate | 203 | 19 Nov 2024 | |
latest/beta | 218 | 19 Nov 2024 | |
latest/edge | 218 | 18 Nov 2024 | |
1.0/stable | 164 | 16 Feb 2024 | |
1.0/candidate | 164 | 22 Nov 2023 | |
1.0/beta | 164 | 22 Nov 2023 | |
1.0/edge | 164 | 22 Nov 2023 |
juju deploy traefik-k8s
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.traefik_k8s.v0.traefik_route
-
- Last updated 19 Sep 2024
- Revision Library version 0.1
Interface Library for traefik_route.
This library wraps relation endpoints for traefik_route. The requirer of this relation is the traefik-route-k8s charm, or any charm capable of providing Traefik configuration files. The provider is the traefik-k8s charm, or another charm willing to consume Traefik configuration files.
Getting Started
To get started using the library, you just need to fetch the library using charmcraft
.
cd some-charm
charmcraft fetch-lib charms.traefik_k8s.v0.traefik_route
To use the library from the provider side (Traefik):
requires:
traefik_route:
interface: traefik_route
limit: 1
from charms.traefik_k8s.v0.traefik_route import TraefikRouteProvider
class TraefikCharm(CharmBase):
def __init__(self, *args):
# ...
self.traefik_route = TraefikRouteProvider(self)
self.framework.observe(
self.traefik_route.on.ready, self._handle_traefik_route_ready
)
def _handle_traefik_route_ready(self, event):
config: str = self.traefik_route.get_config(event.relation) # yaml
# use config to configure Traefik
To use the library from the requirer side (TraefikRoute):
requires:
traefik-route:
interface: traefik_route
limit: 1
optional: false
# ...
from charms.traefik_k8s.v0.traefik_route import TraefikRouteRequirer
class TraefikRouteCharm(CharmBase):
def __init__(self, *args):
# ...
traefik_route = TraefikRouteRequirer(
self, self.model.relations.get("traefik-route"),
"traefik-route"
)
if traefik_route.is_ready():
traefik_route.submit_to_traefik(
config={'my': {'traefik': 'configuration'}}
)
Index
class TraefikRouteException
Description
Base class for exceptions raised by TraefikRoute. None
class UnauthorizedError
Description
Raised when the unit needs leadership to perform some action. None
class TraefikRouteProviderReadyEvent
Description
Event emitted when Traefik is ready to provide ingress for a routed unit. None
class TraefikRouteProviderDataRemovedEvent
Description
Event emitted when a routed ingress relation is removed. None
class TraefikRouteRequirerReadyEvent
Description
Event emitted when a unit requesting ingress has provided all data Traefik needs. None
class TraefikRouteRequirerEvents
Description
Container for TraefikRouteRequirer events. None
class TraefikRouteProviderEvents
Description
Container for TraefikRouteProvider events. None
class TraefikRouteProvider
Implementation of the provider of traefik_route.
Description
This will presumably be owned by a Traefik charm.
The main idea is that Traefik will observe the ready
event and, upon
receiving it, will fetch the config from the TraefikRoute's application databag,
apply it, and update its own app databag to let Route know that the ingress
is there.
The TraefikRouteProvider provides api to do this easily.
Methods
TraefikRouteProvider. __init__( self , charm: CharmBase , relation_name: str , external_host: str )
Constructor for TraefikRouteProvider.
Arguments
The charm that is instantiating the instance.
The name of the relation relation_name to bind to (defaults to "traefik-route").
The external host.
The scheme.
TraefikRouteProvider. external_host( self )
Description
Return the external host set by Traefik, if any. None
TraefikRouteProvider. scheme( self )
Description
Return the scheme set by Traefik, if any. None
TraefikRouteProvider. relations( self )
Description
The list of Relation instances associated with this endpoint. None
TraefikRouteProvider. update_traefik_address( self )
Description
Ensure that requirers know the external host for Traefik. None
TraefikRouteProvider. is_ready( self , relation: Relation )
Whether TraefikRoute is ready on this relation.
Description
Returns True when the remote app shared the config; False otherwise.
TraefikRouteProvider. get_config( self , relation: Relation )
Description
Renamed to get_dynamic_config
. None
TraefikRouteProvider. get_dynamic_config( self , relation: Relation )
Description
Retrieve the dynamic config published by the remote application. None
TraefikRouteProvider. get_static_config( self , relation: Relation )
Description
Retrieve the static config published by the remote application. None
class TraefikRouteRequirer
Wrapper for the requirer side of traefik-route.
Description
The traefik_route requirer will publish to the application databag an object like: { 'config': <Traefik_config> 'static': <Traefik_config> # optional }
NB: TraefikRouteRequirer does no validation; it assumes that the traefik-route-k8s charm will provide valid yaml-encoded config. The TraefikRouteRequirer provides api to store this config in the application databag.
Methods
TraefikRouteRequirer. __init__( self , charm: CharmBase , relation: Relation , relation_name: str )
TraefikRouteRequirer. external_host( self )
Description
Return the external host set by Traefik, if any. None
TraefikRouteRequirer. scheme( self )
Description
Return the scheme set by Traefik, if any. None
TraefikRouteRequirer. is_ready( self )
Description
Is the TraefikRouteRequirer ready to submit data to Traefik? None
TraefikRouteRequirer. submit_to_traefik( self , config: dict , static )
Relay an ingress configuration data structure to traefik.
Description
This will publish to the traefik-route relation databag a chunk of Traefik dynamic config that the traefik charm on the other end can pick up and apply.
Use static
if you need to update traefik's static configuration.
Note that this will force traefik to restart to comply.