Nginx Ingress Integrator

  • By Tom Haddon
Channel Version Revision Published Runs on
latest/stable 45 45 16 Nov 2022
Ubuntu 20.04
latest/edge 52 52 Yesterday
Ubuntu 20.04
juju deploy nginx-ingress-integrator
Show information

Platform:

Ubuntu
20.04

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:

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

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, for the relation changed event to be properly handled.


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. _convert_to_relation_interface( config_dict: Dict )

Description

create a new relation dict that conforms with charm-relation-interfaces. None

IngressRequires. _config_dict_errors( self , update_only: bool )

Description

Check our config dict for errors. None

IngressRequires. _on_relation_changed( self , event: RelationChangedEvent )

Description

Handle the relation-changed event. None

IngressRequires. update_config( self , config_dict: 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: RelationChangedEvent )

Handle a change to the ingress relation.

Description

Confirm we have the fields we expect to receive.

IngressProvides. _on_relation_broken( self , event: RelationBrokenEvent )

Description

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