---
title: Charmhub | Deploy Nginx Ingress Integrator using Charmhub - The Open Operator
  Collection
description: Deploy the latest version of Nginx Ingress Integrator on any cloud.
url: https://charmhub.io/nginx-ingress-integrator/libraries/ingress
---

# Nginx Ingress Integrator

[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:

22.04

20.04

stable 203

```
juju deploy nginx-ingress-integrator
```

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

[Toggle side navigation](https://charmhub.io/nginx-ingress-integrator/libraries/ingress#drawer)

## charms.nginx\_ingress\_integrator.v0.ingress

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

    Fetch library

    ```
    charmcraft fetch-lib charms.nginx_ingress_integrator.v0.ingress
    ```

    [Download ingress.py](https://charmhub.io/nginx-ingress-integrator/libraries/ingress/download)
  + *Last updated* 08 Aug 2023
  + *Revision* Library version 0.17

Library for the ingress relation.

This library contains the Requires and Provides classes for handling
the ingress interface.

Import `IngressRequires` in your charm, with two required options:

* "self" (the charm itself)
* config\_dict

`config_dict` accepts the following keys:

* additional-hostnames
* backend-protocol
* limit-rps
* limit-whitelist
* max-body-size
* owasp-modsecurity-crs
* owasp-modsecurity-custom-rules
* path-routes
* retry-errors
* rewrite-enabled
* rewrite-target
* service-hostname (required)
* service-name (required)
* service-namespace
* service-port (required)
* session-cookie-max-age
* tls-secret-name

See [the config section](https://charmhub.io/nginx-ingress-integrator/configure) for descriptions
of each, along with the required type.

As an example, add the following to `src/charm.py`:

```
from charms.nginx_ingress_integrator.v0.ingress import IngressRequires

# In your charm's `__init__` method (assuming your app is listening on port 8080).
self.ingress = IngressRequires(self, {
        "service-hostname": self.app.name,
        "service-name": self.app.name,
        "service-port": 8080,
    }
)
```

And then add the following to `metadata.yaml`:

```
requires:
  ingress:
    interface: ingress
```

You *must* register the IngressRequires class as part of the `__init__` method
rather than, for instance, a config-changed event handler, for the relation
changed event to be properly handled.

In the example above we're setting `service-hostname` (which translates to the
external hostname for the application when related to nginx-ingress-integrator)
to `self.app.name` here. This ensures by default the charm will be available on
the name of the deployed juju application, but can be overridden in a
production deployment by setting `service-hostname` on the
nginx-ingress-integrator charm. For example:

```
juju deploy nginx-ingress-integrator
juju deploy my-charm
juju relate nginx-ingress-integrator my-charm:ingress
# The service is now reachable on the ingress IP(s) of your k8s cluster at
# 'http://my-charm'.
juju config nginx-ingress-integrator service-hostname='my-charm.example.com'
# The service is now reachable on the ingress IP(s) of your k8s cluster at
# 'http://my-charm.example.com'.
```

---

Index

* [class IngressAvailableEvent](https://charmhub.io/nginx-ingress-integrator/libraries/ingress#ingressavailableevent)
* [class IngressProxyAvailableEvent](https://charmhub.io/nginx-ingress-integrator/libraries/ingress#ingressproxyavailableevent)
* [class IngressBrokenEvent](https://charmhub.io/nginx-ingress-integrator/libraries/ingress#ingressbrokenevent)
* [class IngressCharmEvents](https://charmhub.io/nginx-ingress-integrator/libraries/ingress#ingresscharmevents)
* [class IngressRequires](https://charmhub.io/nginx-ingress-integrator/libraries/ingress#ingressrequires)
* + [def \_\_init\_\_(
    self,
    charm,
    config\_dict)](https://charmhub.io/nginx-ingress-integrator/libraries/ingress#ingressrequires-__init__)
* + [def update\_config(
    self,
    config\_dict)](https://charmhub.io/nginx-ingress-integrator/libraries/ingress#ingressrequires-update_config)
* [class IngressBaseProvides](https://charmhub.io/nginx-ingress-integrator/libraries/ingress#ingressbaseprovides)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/nginx-ingress-integrator/libraries/ingress#ingressbaseprovides-__init__)
* [class IngressProvides](https://charmhub.io/nginx-ingress-integrator/libraries/ingress#ingressprovides)
* + [def \_\_init\_\_(
    self,
    charm)](https://charmhub.io/nginx-ingress-integrator/libraries/ingress#ingressprovides-__init__)
* [class IngressProxyProvides](https://charmhub.io/nginx-ingress-integrator/libraries/ingress#ingressproxyprovides)
* + [def \_\_init\_\_(
    self,
    charm)](https://charmhub.io/nginx-ingress-integrator/libraries/ingress#ingressproxyprovides-__init__)

#### class IngressAvailableEvent

IngressAvailableEvent custom event.

Description

This event indicates the Ingress provider is available.

#### class IngressProxyAvailableEvent

IngressProxyAvailableEvent custom event.

Description

This event indicates the IngressProxy provider is available.

#### class IngressBrokenEvent

IngressBrokenEvent custom event.

Description

This event indicates the Ingress provider is broken.

#### class IngressCharmEvents

Custom charm events.

Description

Attrs:
ingress\_available: Event to indicate that Ingress is available.
ingress\_proxy\_available: Event to indicate that IngressProxy is available.
ingress\_broken: Event to indicate that Ingress is broken.

#### class IngressRequires

This class defines the functionality for the 'requires' side of the 'ingress' relation.

Description

Hook events observed:
- relation-changed

Attrs:
model: Juju model where the charm is deployed.
config\_dict: Contains all the configuration options for Ingress.

Methods

IngressRequires.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
config\_dict: Dict
)

Init function for the IngressRequires class.

Arguments

charm

The charm that requires the ingress relation.

config\_dict

Contains all the configuration options for Ingress.

IngressRequires.
update\_config(

*self*

,
config\_dict: Dict
)

Allow for updates to relation.

Arguments

config\_dict

Contains all the configuration options for Ingress.

#### class IngressBaseProvides

Parent class for IngressProvides and IngressProxyProvides.

Description

Attrs:
model: Juju model where the charm is deployed.

Methods

IngressBaseProvides.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
relation\_name: str
)

Init function for the IngressProxyProvides class.

Arguments

charm

The charm that provides the ingress-proxy relation.

relation\_name

The name of the relation.

#### class IngressProvides

Class containing the functionality for the 'provides' side of the 'ingress' relation.

Description

Hook events observed:
- relation-changed

Methods

IngressProvides.
\_\_init\_\_(

*self*

,
charm: CharmBase
)

Init function for the IngressProvides class.

Arguments

charm

The charm that provides the ingress relation.

#### class IngressProxyProvides

Class containing the functionality for the 'provides' side of the 'ingress-proxy' relation.

Description

Hook events observed:
- relation-changed

Methods

IngressProxyProvides.
\_\_init\_\_(

*self*

,
charm: CharmBase
)

Init function for the IngressProxyProvides class.

Arguments

charm

The charm that provides the ingress-proxy relation.
