---
title: Charmhub | Deploy Istio Pilot using Charmhub - The Open Operator Collection
description: Deploy the latest version of Istio Pilot on any cloud.
url: https://charmhub.io/istio-pilot/libraries/istio_gateway_info
---

# Istio Pilot

[Kubeflow Charmers](https://charmhub.io/publisher/ckfbot "View all packages from Kubeflow Charmers")

* [Kubeflow Charmers](https://charmhub.io/publisher/ckfbot "View all packages from Kubeflow Charmers")

Platform:

24.04

20.04

1.24/stable 1401

```
juju deploy istio-pilot --channel 1.24/stable
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/istio-pilot/libraries/istio_gateway_info#drawer)

## charms.istio\_pilot.v0.istio\_gateway\_info

* [*Docstrings*Docstrings](https://charmhub.io/istio-pilot/libraries/istio_gateway_info)
  [*Code*Source code](https://charmhub.io/istio-pilot/libraries/istio_gateway_info/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.istio_pilot.v0.istio_gateway_info
    ```

    [Download istio\_gateway\_info.py](https://charmhub.io/istio-pilot/libraries/istio_gateway_info/download)
  + *Last updated* 24 Jul 2023
  + *Revision* Library version 0.4

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
```

---

Index

* [class GatewayRelationError](https://charmhub.io/istio-pilot/libraries/istio_gateway_info#gatewayrelationerror)
* [class GatewayRelationMissingError](https://charmhub.io/istio-pilot/libraries/istio_gateway_info#gatewayrelationmissingerror)
* + [def \_\_init\_\_(
    self)](https://charmhub.io/istio-pilot/libraries/istio_gateway_info#gatewayrelationmissingerror-__init__)
* [class GatewayRelationDataMissingError](https://charmhub.io/istio-pilot/libraries/istio_gateway_info#gatewayrelationdatamissingerror)
* + [def \_\_init\_\_(
    self,
    message)](https://charmhub.io/istio-pilot/libraries/istio_gateway_info#gatewayrelationdatamissingerror-__init__)
* [class GatewayRequirer](https://charmhub.io/istio-pilot/libraries/istio_gateway_info#gatewayrequirer)
* + [def \_\_init\_\_(
    self,
    requirer\_charm,
    relation\_name)](https://charmhub.io/istio-pilot/libraries/istio_gateway_info#gatewayrequirer-__init__)
* + [def get\_relation\_data(
    self)](https://charmhub.io/istio-pilot/libraries/istio_gateway_info#gatewayrequirer-get_relation_data)
* [class GatewayProvider](https://charmhub.io/istio-pilot/libraries/istio_gateway_info#gatewayprovider)
* + [def \_\_init\_\_(
    self,
    provider\_charm,
    relation\_name)](https://charmhub.io/istio-pilot/libraries/istio_gateway_info#gatewayprovider-__init__)
* + [def send\_gateway\_relation\_data(
    self,
    gateway\_name,
    gateway\_namespace,
    gateway\_up)](https://charmhub.io/istio-pilot/libraries/istio_gateway_info#gatewayprovider-send_gateway_relation_data)

#### 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.
