---
title: Charmhub | Deploy Istio using Charmhub - The Open Operator Collection
description: Deploy the latest version of Istio as a Kubernetes Operator on any cloud.
url: https://charmhub.io/istio-k8s/libraries/istio_metadata
---

# Istio

[Canonical Observability](https://charmhub.io/publisher/observability "View all packages from Canonical Observability")

* [Canonical Observability](https://charmhub.io/publisher/observability "View all packages from Canonical Observability")

Platform:

1.31/stable 82

```
juju deploy istio-k8s --channel 1.31/stable
```

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

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

## charms.istio\_k8s.v0.istio\_metadata

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

    Fetch library

    ```
    charmcraft fetch-lib charms.istio_k8s.v0.istio_metadata
    ```

    [Download istio\_metadata.py](https://charmhub.io/istio-k8s/libraries/istio_metadata/download)
  + *Last updated* 10 Jul 2025
  + *Revision* Library version 0.2

istio\_metadata.

This library implements endpoint wrappers for the istio-metadata interface. The istio-metadata interface is used to
transfer information about an instance of Istio, such as its root namespace. Typically, this is useful for charms that
need details on how to interface with Istio.

##### Usage

###### Requirer

IstioMetadataRequirer is a wrapper for pulling data from the istio-metadata interface. To use it in your charm:

* observe the relation-changed and relation-broken events for this relation wherever your charm needs to use this data
  (this endpoint wrapper DOES NOT automatically observe any events)
* wherever you need access to the data, call `IstioMetadataRequirer(...).get_data()`

An example implementation is:

```
class FooCharm(CharmBase):
    def __init__(self, framework):
        super().__init__(framework)

        istio_metadata = IstioMetadataRequirer(self.model.relations, "istio-metadata")

        self.framework.observe(self.on["istio-metadata"].relation_changed, self._on_istio_metadata_changed)
        self.framework.observe(self.on["istio-metadata"].relation_broken, self._on_istio_metadata_changed)

    def _on_istio_metadata_changed(self):
        data = istio_metadata.get_data()
        ...
```

Where you also add relation to your `charmcraft.yaml` or `metadata.yaml` (note that IstioMetadataRequirer is designed
for relating to a single application and must be used with limit=1 as shown below):

```
requires:
  istio-metadata:
    limit: 1
    interface: istio_metadata
```

###### Provider

IstioMetadataProvider is a wrapper for publishing data to charms related using the istio-metadata interface. Note
that `IstioMetadataProvider` *does not* manage any events, but instead provides a `publish` method for sending data to
all related applications. Triggering `publish` appropriately is left to the charm author, although generally you want
to do this at least during the `relation_joined` and `leader_elected` events. An example implementation is:

```
class FooCharm(CharmBase):
    def __init__(self, framework):
        super().__init__(framework)
        self.istio_metadata = IstioMetadataProvider(
            relation_mapping=self.model.relations,
            app=self.app,
            relation_name="istio-metadata",
        )

        self.framework.observe(self.on.leader_elected, self.do_something_to_publish)
        self.framework.observe(self._charm.on["istio-metadata"].relation_joined, self.do_something_to_publish)
        self.framework.observe(self.on.some_event_that_changes_istio_metadata, self.do_something_to_publish)

    def do_something_to_publish(self, e):
        self.istio_metadata.publish(...)
```

Where you also add the following to your `charmcraft.yaml` or `metadata.yaml`:

```
provides:
  istio-metadata:
    interface: istio_metadata
```

---

Index

* [class IstioMetadataAppData](https://charmhub.io/istio-k8s/libraries/istio_metadata#istiometadataappdata)
* [class IstioMetadataRequirer](https://charmhub.io/istio-k8s/libraries/istio_metadata#istiometadatarequirer)
* + [def \_\_init\_\_(
    self,
    relation\_mapping,
    relation\_name)](https://charmhub.io/istio-k8s/libraries/istio_metadata#istiometadatarequirer-__init__)
* + [def relations(
    self)](https://charmhub.io/istio-k8s/libraries/istio_metadata#istiometadatarequirer-relations)
* + [def get\_data(
    self)](https://charmhub.io/istio-k8s/libraries/istio_metadata#istiometadatarequirer-get_data)
* [class IstioMetadataProvider](https://charmhub.io/istio-k8s/libraries/istio_metadata#istiometadataprovider)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_mapping,
    app,
    relation\_name)](https://charmhub.io/istio-k8s/libraries/istio_metadata#istiometadataprovider-__init__)
* + [def relations(
    self)](https://charmhub.io/istio-k8s/libraries/istio_metadata#istiometadataprovider-relations)
* + [def publish(
    self,
    root\_namespace)](https://charmhub.io/istio-k8s/libraries/istio_metadata#istiometadataprovider-publish)

#### class IstioMetadataAppData

Description

Data model for the istio-metadata interface. None

#### class IstioMetadataRequirer

Description

Endpoint wrapper for the requirer side of the istio-metadata relation. None

Methods

IstioMetadataRequirer.
\_\_init\_\_(

*self*

,
relation\_mapping: RelationMapping

,
relation\_name: str
)

Initialize the IstioMetadataRequirer object.

Arguments

relation\_mapping

The RelationMapping of a charm (typically `self.model.relations` from within a charm
object).

relation\_name

The name of the wrapped relation.

Description

This object is for accessing data from relations that use the istio-metadata interface. It **does not**
autonomously handle the events associated with that relation. It is up to the charm using this object to
observe those events as they see fit. Typically, that charm should observe this relation's relation-changed
event.

This object is for interacting with a relation that has limit=1 set in charmcraft.yaml. In particular, the
get\_data method will raise if more than one related application is available.

IstioMetadataRequirer.
relations(

*self*
)

Description

Return the relation instances for applications related to us on the monitored relation. None

IstioMetadataRequirer.
get\_data(

*self*
)

Return data for at most one related application, raising if more than one is available.

Description

Useful for charms that always expect exactly one related application. It is recommended that those charms also
set limit=1 for that relation in charmcraft.yaml. Returns None if no data is available (either because no
applications are related to us, or because the related application has not sent data).

#### class IstioMetadataProvider

Description

The provider side of the istio-metadata relation. None

Methods

IstioMetadataProvider.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
relation\_mapping: RelationMapping

,
app: Application

,
relation\_name: str
)

Initialize the IstioMetadataProvider object.

Arguments

charm

The charm instantiating this object.

relation\_mapping

The RelationMapping of a charm (typically `self.model.relations` from within a charm object).

app

This application.

relation\_name

The name of the relation.

Description

This object is for serializing and sending data to a relation that uses the istio-metadata interface - it does
not automatically observe any events for that relation. It is up to the charm using this to call publish when
it is appropriate to do so, typically on at least the charm's leader\_elected event and this relation's
relation\_joined event.

IstioMetadataProvider.
relations(

*self*
)

Description

Return the applications related to us under the monitored relation. None

IstioMetadataProvider.
publish(

*self*

,
root\_namespace: str
)

Post istio-metadata to all related applications.

Arguments

root\_namespace

The root namespace of the Istio deployment.

Description

This method writes to the relation's app data bag, and thus should never be called by a unit that is not the
leader otherwise ops will raise an exception.
