Nginx Ingress Integrator

  • By Tom Haddon
Channel Revision Published Runs on
latest/stable 58 Yesterday
Ubuntu 20.04
latest/edge 59 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
  • 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 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

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.

class IngressProvides

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

Description

Attrs: charm: The charm that provides the ingress relation. 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

Attrs: charm: The charm that provides the ingress-proxy relation. 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.