Istio Pilot

  • By Kubeflow Charmers
Channel Revision Published Runs on
latest/stable 34 03 Dec 2021
Ubuntu 20.04
latest/candidate 69 06 Apr 2022
Ubuntu 20.04
latest/beta 656 04 Oct 2023
Ubuntu 20.04
latest/edge 813 22 Mar 2024
Ubuntu 20.04
1.17/stable 827 04 Apr 2024
Ubuntu 20.04
1.17/edge 839 04 Apr 2024
Ubuntu 20.04
1.16/stable 662 09 Oct 2023
Ubuntu 20.04
1.16/beta 413 03 Apr 2023
Ubuntu 20.04
1.16/edge 709 21 Nov 2023
Ubuntu 20.04
1.15/stable 412 03 Apr 2023
Ubuntu 20.04
1.15/beta 412 03 Apr 2023
Ubuntu 20.04
1.15/edge 412 30 Mar 2023
Ubuntu 20.04
1.14/stable 422 03 Apr 2023
Ubuntu 20.04
1.14/beta 422 03 Apr 2023
Ubuntu 20.04
1.14/edge 422 31 Mar 2023
Ubuntu 20.04
1.13/stable 414 03 Apr 2023
Ubuntu 20.04
1.13/beta 414 03 Apr 2023
Ubuntu 20.04
1.13/edge 414 30 Mar 2023
Ubuntu 20.04
1.12/stable 420 03 Apr 2023
Ubuntu 20.04
1.12/beta 420 03 Apr 2023
Ubuntu 20.04
1.12/edge 420 31 Mar 2023
Ubuntu 20.04
1.11/stable 302 24 Feb 2023
Ubuntu 20.04
1.11/candidate 302 24 Feb 2023
Ubuntu 20.04
1.11/beta 302 24 Feb 2023
Ubuntu 20.04
1.11/edge 302 24 Feb 2023
Ubuntu 20.04
1.5/stable 63 01 Jul 2022
Ubuntu 20.04
1.5/candidate 61 24 Jan 2022
Ubuntu 20.04
1.5/beta 61 24 Jan 2022
Ubuntu 20.04
1.5/edge 63 24 Feb 2022
Ubuntu 20.04
juju deploy istio-pilot
Show information

Platform:

charms.istio_pilot.v0.istio_gateway_info

Library for sharing Istio Gateway(s) information.

This library offers a Python API for providing and requesting information about Istio Gateway(s) by wrapping the gateway-info relation endpoints. The default relation name is gateway-info and it's recommended to use that name, though if changed, you must ensure to pass the correct name when instantiating the provider and requirer classes, as well as in metadata.yaml.

Getting Started
Fetching the library with charmcraft

Using charmcraft you can:

charmcraft fetch-lib charms.istio_pilot.v0.istio_gateway_info
Using the library as requirer
Add relation to metadata.yaml
requires:
  gateway-info:
    interface: istio-gateway-info
    limit: 1
Instantiate the GatewayRequirer class in charm.py
from ops.charm import CharmBase
from charms.istio_pilot.v0.istio_gateway_info import GatewayRequirer, GatewayRelationError

class RequirerCharm(CharmBase):
    def __init__(self, *args):
        self.gateway = GatewayRequirer(self)
        self.framework.observe(self.on.some_event_emitted, self.some_event_function)

    def some_event_function():
        # use the getter function wherever the info is needed
        try:
            gateway_data = self.gateway_relation.get_relation_data()
        except GatewayRelationError as error:
            "your error handler goes here"
Using the library as provider
Add relation to metadata.yaml
provides:
  gateway-info:
    interface: istio-gateway-info
Instantiate the GatewayProvider class in charm.py
from ops.charm import CharmBase
from charms.istio_pilot.v0.istio_gateway_info import GatewayProvider, GatewayRelationError

class ProviderCharm(CharmBase):
    def __init__(self, *args, **kwargs):
        ...
        self.gateway_provider = GatewayProvider(self)
        self.observe(self.on.some_event, self._some_event_handler)
    def _some_event_handler(self, ...):
        # This will update the relation data bag with the Gateway name and namespace
        try:
            self.gateway_provider.send_gateway_data(charm, gateway_name, gateway_namespace)
        except GatewayRelationError as error:
            "your error handler goes here"

Note that GatewayProvider.send_gateway_data() sends data to all related applications, and will execute without error even if no applications are related. If you want to ensure that the someone is listening for the data, please add checks separately.

Relation data

The data shared by this library is:

  • gateway_name: the name of the Gateway the provider knows about. It corresponds to the name field in the Gateway definition
  • gateway_namespace: the namespace where the Gateway is deployed.
  • gateway_up: (new in v0.3) boolean indicating whether the Gateway is up. This being True indicates that the Gateway should be fully established and accepting traffic. If relating a Requirer of v0.3 to a Provider using v0.2 or earlier of this library, the Requirer will return gateway_up=True by default.

The following example shows an Istio Gateway with gateway_name=my-gateway and gateway_namespace=my-gateway-namespace

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: my-gateway
  namespace: my-gateway-namespace

class GatewayRelationError

class GatewayRelationMissingError

Methods

GatewayRelationMissingError. __init__( self )

class GatewayRelationDataMissingError

Methods

GatewayRelationDataMissingError. __init__( self , message )

class GatewayRequirer

Base class that represents a requirer relation end.

Arguments

requirer_charm (CharmBase)

the requirer application

relation_name (str)

the name of the relation

Attributes

requirer_charm (CharmBase)
variable for storing the requirer application
relation_name (str)
variable for storing the name of the relation

Methods

GatewayRequirer. __init__( self , requirer_charm , relation_name: str )

GatewayRequirer. get_relation_data( self )

Returns a dictionary with the Gateway information.

class GatewayProvider

Base class that represents a provider relation end.

Arguments

provider_charm (CharmBase)

the provider application

relation_name (str)

the name of the relation

Attributes

provider_charm (CharmBase)
variable for storing the provider application
relation_name (str)
variable for storing the name of the relation

Methods

GatewayProvider. __init__( self , provider_charm , relation_name: str )

GatewayProvider. send_gateway_relation_data( self , gateway_name: str , gateway_namespace: str , gateway_up: bool )

Updates the relation data bag with data from the local gateway.

Arguments

gateway_name (str)

the name of the Gateway the provider knows about

gateway_namespace (str)

the namespace of the Gateway the provider knows about

gateway_up (bool)

(optional) the status of the Gateway. Defaults to True if not provided.

Description

This method will complete successfully even if there are no related applications.