Istio Pilot

  • Kubeflow Charmers
Channel Revision Published Runs on
latest/candidate 69 06 Apr 2022
Ubuntu 20.04
latest/beta 1013 09 Jul 2024
Ubuntu 20.04
latest/edge 1235 08 Oct 2024
Ubuntu 20.04
1.22/stable 1169 27 Aug 2024
Ubuntu 20.04
1.22/edge 1234 08 Oct 2024
Ubuntu 20.04
1.21/stable 1170 27 Aug 2024
Ubuntu 20.04
1.21/edge 1170 27 Aug 2024
Ubuntu 20.04
1.20/stable 1155 27 Aug 2024
Ubuntu 20.04
1.20/edge 1198 04 Sep 2024
Ubuntu 20.04
1.19/stable 1172 27 Aug 2024
Ubuntu 20.04
1.19/edge 1172 27 Aug 2024
Ubuntu 20.04
1.18/stable 1173 27 Aug 2024
Ubuntu 20.04
1.18/edge 1173 27 Aug 2024
Ubuntu 20.04
1.17/stable 1171 27 Aug 2024
Ubuntu 20.04
1.17/edge 1197 04 Sep 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 970 11 Jun 2024
Ubuntu 20.04
juju deploy istio-pilot --channel 1.22/stable
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.