Nginx Ingress Integrator

  • By Tom Haddon
Channel Version Revision Published Runs on
latest/stable 27 27 08 Mar 2022
Ubuntu 20.04
latest/edge 27 27 25 Feb 2022
Ubuntu 20.04
juju deploy nginx-ingress-integrator
Show information

Platform:

charms.nginx_ingress_integrator.v0.ingress

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:

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

See the config section 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.
self.ingress = IngressRequires(self, {"service-hostname": self.config["external_hostname"],
                                      "service-name": self.app.name,
                                      "service-port": 80})

# In your charm's `config-changed` handler.
self.ingress.update_config({"service-hostname": self.config["external_hostname"]})

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. This is because doing so won't get the current relation changed event, because it wasn't registered to handle the event (because it wasn't created in __init__ when the event was fired).


class IngressAvailableEvent

class IngressBrokenEvent

class IngressCharmEvents

Description

Custom charm events. None

class IngressRequires

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

Description

Hook events observed: - relation-changed

Methods

IngressRequires. __init__( self , charm , config_dict )

IngressRequires. _config_dict_errors( self , update_only )

Description

Check our config dict for errors. None

IngressRequires. _on_relation_changed( self , event )

Description

Handle the relation-changed event. None

IngressRequires. update_config( self , config_dict )

Description

Allow for updates to relation. None

class IngressProvides

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

Description

Hook events observed: - relation-changed

Methods

IngressProvides. __init__( self , charm )

IngressProvides. _on_relation_changed( self , event )

Handle a change to the ingress relation.

Description

Confirm we have the fields we expect to receive.

IngressProvides. _on_relation_broken( self , _ )

Description

Handle a relation-broken event in the ingress relation. None