---
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/ingress
---

# 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/ingress#drawer)

## charms.traefik\_k8s.v2.ingress

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

    Fetch library

    ```
    charmcraft fetch-lib charms.traefik_k8s.v2.ingress
    ```

    [Download ingress.py](https://charmhub.io/traefik-k8s/libraries/ingress/download)
  + *Last updated* 08 Jun 2026
  + *Revision* Library version 2.21

#### Interface Library for ingress.

This library wraps relation endpoints using the `ingress` interface
and provides a Python API for both requesting and providing per-application
ingress, with load-balancing occurring across all units.

##### 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.v2.ingress
```

In the `metadata.yaml` of the charm, add the following:

```
requires:
    ingress:
        interface: ingress
        limit: 1
```

Then, to initialise the library:

```
from charms.traefik_k8s.v2.ingress import (IngressPerAppRequirer,
  IngressPerAppReadyEvent, IngressPerAppRevokedEvent)

class SomeCharm(CharmBase):
  def __init__(self, *args):
    # ...
    self.ingress = IngressPerAppRequirer(self, port=80)
    # The following event is triggered when the ingress URL to be used
    # by this deployment of the `SomeCharm` is ready (or changes).
    self.framework.observe(
        self.ingress.on.ready, self._on_ingress_ready
    )
    self.framework.observe(
        self.ingress.on.revoked, self._on_ingress_revoked
    )

    def _on_ingress_ready(self, event: IngressPerAppReadyEvent):
        logger.info("This app's ingress URL: %s", event.url)

    def _on_ingress_revoked(self, event: IngressPerAppRevokedEvent):
        logger.info("This app no longer has ingress")
```

---

Index

* [class IngressUrl](https://charmhub.io/traefik-k8s/libraries/ingress#ingressurl)
* [class IngressProviderAppData](https://charmhub.io/traefik-k8s/libraries/ingress#ingressproviderappdata)
* [class ProviderSchema](https://charmhub.io/traefik-k8s/libraries/ingress#providerschema)
* [class IngressHealthCheck](https://charmhub.io/traefik-k8s/libraries/ingress#ingresshealthcheck)
* [class IngressRequirerAppData](https://charmhub.io/traefik-k8s/libraries/ingress#ingressrequirerappdata)
* + [def validate\_scheme(
    cls,
    scheme)](https://charmhub.io/traefik-k8s/libraries/ingress#ingressrequirerappdata-validate_scheme)
* + [def validate\_port(
    cls,
    port)](https://charmhub.io/traefik-k8s/libraries/ingress#ingressrequirerappdata-validate_port)
* [class IngressRequirerUnitData](https://charmhub.io/traefik-k8s/libraries/ingress#ingressrequirerunitdata)
* + [def validate\_host(
    cls,
    host)](https://charmhub.io/traefik-k8s/libraries/ingress#ingressrequirerunitdata-validate_host)
* + [def validate\_ip(
    cls,
    ip)](https://charmhub.io/traefik-k8s/libraries/ingress#ingressrequirerunitdata-validate_ip)
* [class RequirerSchema](https://charmhub.io/traefik-k8s/libraries/ingress#requirerschema)
* [class IngressError](https://charmhub.io/traefik-k8s/libraries/ingress#ingresserror)
* [class NotReadyError](https://charmhub.io/traefik-k8s/libraries/ingress#notreadyerror)
* [class DataValidationError](https://charmhub.io/traefik-k8s/libraries/ingress#datavalidationerror)
* [class IngressPerAppDataProvidedEvent](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperappdataprovidedevent)
* [class IngressPerAppDataRemovedEvent](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperappdataremovedevent)
* [class IngressPerAppEndpointsUpdatedEvent](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperappendpointsupdatedevent)
* [class IngressPerAppProviderEvents](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperappproviderevents)
* [class IngressRequirerData](https://charmhub.io/traefik-k8s/libraries/ingress#ingressrequirerdata)
* [class IngressPerAppProvider](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperappprovider)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperappprovider-__init__)
* + [def wipe\_ingress\_data(
    self,
    relation)](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperappprovider-wipe_ingress_data)
* + [def get\_data(
    self,
    relation)](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperappprovider-get_data)
* + [def is\_ready(
    self,
    relation)](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperappprovider-is_ready)
* + [def publish\_url(
    self,
    relation,
    url)](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperappprovider-publish_url)
* + [def proxied\_endpoints(
    self)](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperappprovider-proxied_endpoints)
* [class IngressPerAppReadyEvent](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperappreadyevent)
* [class IngressPerAppRevokedEvent](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperapprevokedevent)
* [class IngressPerAppRequirerEvents](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperapprequirerevents)
* [class IngressPerAppRequirer](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperapprequirer)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperapprequirer-__init__)
* + [def is\_ready(
    self)](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperapprequirer-is_ready)
* + [def provide\_ingress\_requirements(
    self)](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperapprequirer-provide_ingress_requirements)
* + [def relation(
    self)](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperapprequirer-relation)
* + [def url(
    self)](https://charmhub.io/traefik-k8s/libraries/ingress#ingressperapprequirer-url)

#### class IngressUrl

Description

Ingress url schema. None

#### class IngressProviderAppData

Description

Ingress application databag schema. None

#### class ProviderSchema

Description

Provider schema for Ingress. None

#### class IngressHealthCheck

Description

HealthCheck schema for Ingress. None

#### class IngressRequirerAppData

Description

Ingress requirer application databag model. None

Methods

IngressRequirerAppData.
validate\_scheme(

cls

,
scheme: str
)

Description

Validate scheme arg. None

IngressRequirerAppData.
validate\_port(

cls

,
port: int
)

Description

Validate port. None

#### class IngressRequirerUnitData

Description

Ingress requirer unit databag model. None

Methods

IngressRequirerUnitData.
validate\_host(

cls

,
host: str
)

Description

Validate host. None

IngressRequirerUnitData.
validate\_ip(

cls

,
ip: str
)

Description

Validate ip. None

#### class RequirerSchema

Description

Requirer schema for Ingress. None

#### class IngressError

Description

Base class for custom errors raised by this library. None

#### class NotReadyError

Description

Raised when a relation is not ready. None

#### class DataValidationError

Description

Raised when data validation fails on IPU relation data. None

#### class IngressPerAppDataProvidedEvent

Description

Event representing that ingress data has been provided for an app. None

#### class IngressPerAppDataRemovedEvent

Description

Event representing that ingress data has been removed for an app. None

#### class IngressPerAppEndpointsUpdatedEvent

Description

Event representing that the proxied endpoints have been updated. None

#### class IngressPerAppProviderEvents

Description

Container for IPA Provider events. None

#### class IngressRequirerData

Description

Data exposed by the ingress requirer to the provider. None

#### class IngressPerAppProvider

Description

Implementation of the provider of ingress. None

Methods

IngressPerAppProvider.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
relation\_name: str
)

Constructor for IngressPerAppProvider.

Arguments

charm

The charm that is instantiating the instance.

relation\_name

The name of the relation endpoint to bind to
(defaults to "ingress").

IngressPerAppProvider.
wipe\_ingress\_data(

*self*

,
relation: Relation
)

Description

Clear ingress data from relation. None

IngressPerAppProvider.
get\_data(

*self*

,
relation: Relation
)

Description

Fetch the remote (requirer) app and units' databags. None

IngressPerAppProvider.
is\_ready(

*self*

,
relation
)

Description

The Provider is ready if the requirer has sent valid data. None

IngressPerAppProvider.
publish\_url(

*self*

,
relation: Relation

,
url: str
)

Description

Publish to the app databag the ingress url. None

IngressPerAppProvider.
proxied\_endpoints(

*self*
)

Returns the ingress settings provided to applications by this IngressPerAppProvider.

Description

For example, when this IngressPerAppProvider has provided the
`http://foo.bar/my-model.my-app` URL to the my-app application, the returned dictionary
will be:

```
{
    "my-app": {
        "url": "http://foo.bar/my-model.my-app"
    }
}
```

#### class IngressPerAppReadyEvent

Description

Event representing that ingress for an app is ready. None

#### class IngressPerAppRevokedEvent

Description

Event representing that ingress for an app has been revoked. None

#### class IngressPerAppRequirerEvents

Description

Container for IPA Requirer events. None

#### class IngressPerAppRequirer

Description

Implementation of the requirer of the ingress relation. None

Methods

IngressPerAppRequirer.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
relation\_name: str
)

Constructor for IngressRequirer.

Arguments

charm

The charm that is instantiating the library.

relation\_name

The name of the relation endpoint to bind to (defaults to "ingress");
the relation must be of interface type "ingress" and have a limit of 1.

host

Hostname to be used by the ingress provider to address the requiring
application; if unspecified, the default Kubernetes service name will be used.

ip

Alternative addressing method other than host to be used by the ingress provider;
if unspecified, the binding address from the Juju network API will be used.

healthcheck\_params

Optional dictionary containing health check
configuration parameters conforming to the IngressHealthCheck schema.
The dictionary must include:
- "path" (str): The health check endpoint path (required).
It may also include:
- "scheme" (Optional[str]): Replaces the server URL scheme for the health check
endpoint.
- "hostname" (Optional[str]): Hostname to be set in the health check request.
- "port" (Optional[int]): Replaces the server URL port for the health check
endpoint.
- "interval" (str): Frequency of the health check calls
(defaults to "30s" if omitted).
- "timeout" (str): Maximum duration for a health check request
(defaults to "5s" if omitted).
If provided, "path" is required while "interval" and "timeout" will use Traefik's
defaults when not specified.

strip\_prefix

Configure Traefik to strip the path prefix.

redirect\_https

Redirect incoming requests to HTTPS.

scheme

Either a callable that returns the scheme to use when constructing the ingress
URL, or a string if the scheme is known and stable at charm initialization.

Description

The request args can be used to specify the ingress properties when the
instance is created. If any are set, at least `port` is required, and
they will be sent to the ingress provider as soon as it is available.
All request args must be given as keyword args.

IngressPerAppRequirer.
is\_ready(

*self*
)

Description

The Requirer is ready if the Provider has sent valid data. None

IngressPerAppRequirer.
provide\_ingress\_requirements(

*self*
)

Publishes the data that Traefik needs to provide ingress.

Arguments

scheme

Scheme to be used; if unspecified, use the one used by **init**.

host

Hostname to be used by the ingress provider to address the
requirer unit; if unspecified, FQDN will be used instead

ip

Alternative addressing method other than host to be used by the ingress provider.
if unspecified, binding address from juju network API will be used.

port

the port of the service (required)

IngressPerAppRequirer.
relation(

*self*
)

Description

The established Relation instance, or None. None

IngressPerAppRequirer.
url(

*self*
)

The full ingress URL to reach the charm application.

Description

Returns None if the URL isn't available yet.
