Nginx Ingress Integrator

  • By Tom Haddon
juju deploy nginx-ingress-integrator
Show information
You will need Juju 2.9 to be able to run this command. Learn how to upgrade to Juju 2.9.
Channel Version Base
latest/stable 20
20.04
latest/edge 12
20.04

Platform:

Toggle side navigation

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
- 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 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. _config_dict_errors( self , update_only )

None

Description

Check our config dict for errors. None

IngressRequires. _on_relation_changed( self , event )

None

Description

Handle the relation-changed event. None

IngressRequires. update_config( self , config_dict )

None

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. _on_relation_changed( self , event )

Handle a change to the ingress relation.

Description

Confirm we have the fields we expect to receive.