---
title: "Charmhub | Deploy Traefik Ingress Operator for Kubernetes\n using Charmhub\
  \ - The Open Operator Collection"
description: "Deploy the latest version of Traefik Ingress Operator for Kubernetes\n\
  \ as a Kubernetes Operator on any cloud."
url: https://charmhub.io/traefik-k8s/libraries/traefik_route
---

# Traefik Ingress Operator for Kubernetes

[Canonical IS DevOps](https://charmhub.io/publisher/canonical-is-devops "View all packages from Canonical IS DevOps")

* [Canonical IS DevOps](https://charmhub.io/publisher/canonical-is-devops "View all packages from Canonical IS DevOps")

Platform:

stable 32bad7a

```
juju deploy traefik-k8s
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/traefik-k8s/libraries/traefik_route#drawer)

## charms.traefik\_k8s.v0.traefik\_route

* [*Docstrings*Docstrings](https://charmhub.io/traefik-k8s/libraries/traefik_route)
  [*Code*Source code](https://charmhub.io/traefik-k8s/libraries/traefik_route/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.traefik_k8s.v0.traefik_route
    ```

    [Download traefik\_route.py](https://charmhub.io/traefik-k8s/libraries/traefik_route/download)
  + *Last updated* 27 Aug 2026
  + *Revision* Library version 0.8

#### 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):

```
provides:
    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
```

Example usage without raw flag (default behavior):

```
# ...
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",
        raw=False  # Default: Traefik will append TLS configs
    )
    if traefik_route.is_ready():
        traefik_route.submit_to_traefik(
            config={'my': {'traefik': 'configuration'}}
        )
```

Example usage with raw flag enabled (full control over TLS configuration):

```
# ...
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",
        raw=True  # Traefik will not modify TLS settings on all routes
    )
    if self.traefik_route.is_ready():
        self.traefik_route.submit_to_traefik(
            config={
                'tcp': {
                    'routers': {
                        'secure-route': {
                            'rule': 'Host(`secure.example.com`)',
                            'service': 'my-service',
                            'tls': {'certResolver': 'myresolver'}
                        }
                    }
                }
            }
        )
```

---

Index

* [class TraefikRouteException](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouteexception)
* [class UnauthorizedError](https://charmhub.io/traefik-k8s/libraries/traefik_route#unauthorizederror)
* [class TraefikRouteProviderReadyEvent](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouteproviderreadyevent)
* [class TraefikRouteProviderDataRemovedEvent](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouteproviderdataremovedevent)
* [class TraefikRouteRequirerReadyEvent](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouterequirerreadyevent)
* [class TraefikRouteRequirerEvents](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouterequirerevents)
* [class TraefikRouteProviderEvents](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouteproviderevents)
* [class TraefikRouteProvider](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouteprovider)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name,
    external\_host)](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouteprovider-__init__)
* + [def external\_host(
    self)](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouteprovider-external_host)
* + [def scheme(
    self)](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouteprovider-scheme)
* + [def relations(
    self)](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouteprovider-relations)
* + [def update\_traefik\_address(
    self)](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouteprovider-update_traefik_address)
* + [def is\_ready(
    self,
    relation)](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouteprovider-is_ready)
* + [def get\_config(
    self,
    relation)](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouteprovider-get_config)
* + [def get\_dynamic\_config(
    self,
    relation)](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouteprovider-get_dynamic_config)
* + [def is\_raw\_enabled(
    self,
    relation)](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouteprovider-is_raw_enabled)
* + [def get\_static\_config(
    self,
    relation)](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouteprovider-get_static_config)
* [class TraefikRouteRequirer](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouterequirer)
* + [def \_\_init\_\_(
    self,
    charm,
    relation,
    relation\_name,
    raw)](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouterequirer-__init__)
* + [def external\_host(
    self)](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouterequirer-external_host)
* + [def scheme(
    self)](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouterequirer-scheme)
* + [def is\_ready(
    self)](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouterequirer-is_ready)
* + [def submit\_to\_traefik(
    self,
    config,
    static)](https://charmhub.io/traefik-k8s/libraries/traefik_route#traefikrouterequirer-submit_to_traefik)

#### 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

charm

The charm that is instantiating the instance.

relation\_name

The name of the relation relation\_name to bind to
(defaults to "traefik-route").

external\_host

The external host.

scheme

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.
is\_raw\_enabled(

*self*

,
relation: Relation
)

Description

Check if the raw config mode is enabled 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

Handles the requirer side of the traefik-route interface.

Description

This class provides an API for publishing dynamic and static configurations
to the Traefik charm through the `traefik-route` relation. It does not perform
validation on the provided configurations, assuming that Traefik will handle
valid YAML-encoded data.

The application databag follows the structure:

```
{
    "config": "<Traefik dynamic config YAML>",
    "static": "<Traefik static config YAML>",  # Optional, requires Traefik restart
    "raw": "<bool>"  # Determines if Traefik should append TLS config for ALL routes
}
```

Methods

TraefikRouteRequirer.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
relation

,
relation\_name: str

,
raw
)

Initialize the traefik-route requirer class.

Arguments

charm

Requirer charm.

relation

traefik-route relation. Defaults to None.

relation\_name

Name of the relation. Defaults to "traefik-route".

raw

Whether or not to enable raw mode. Defaults to False.

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
)

Submit an ingress configuration to Traefik.

Description

This method publishes dynamic and static configuration data to the
`traefik-route` relation, allowing Traefik to pick up and apply the settings.

* **Dynamic config (`config`)**: Defines routing rules for Traefik.
* **Static config (`static`)**: Requires a Traefik restart to take effect.
