---
title: Charmhub | Deploy Resource Dispatcher using Charmhub - The Open Operator Collection
description: Deploy the latest version of Resource Dispatcher as a Kubernetes Operator
  on any cloud.
url: https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests
---

# Resource Dispatcher

[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:

stable 93

```
juju deploy resource-dispatcher
```

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

[Toggle side navigation](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests#drawer)

## charms.resource\_dispatcher.v0.kubernetes\_manifests

* [*Docstrings*Docstrings](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests)
  [*Code*Source code](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.resource_dispatcher.v0.kubernetes_manifests
    ```

    [Download kubernetes\_manifests.py](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests/download)
  + *Last updated* 27 Jan 2026
  + *Revision* Library version 0.2

KubernetesManifests Library

This library implements data transfer for the kubernetes\_manifest interface. The library can be used by the requirer
charm to send Kubernetes manifests to the provider charm. The manifests sent by the requirer using this charm lib is
sent encapsulated inside a Juju secret that has been granted to the provider charm on the other side of the relation.

##### Getting Started

To get started using the library, fetch the library with `charmcraft`.

```
cd some-charm
charmcraft fetch-lib charms.resource_dispatcher.v0.kubernetes_manifests
```

In your charm, the library can be used in two ways depending on whether the manifests
being sent by the charm are static (available when the charm starts up),
or dynamic (for example a manifest template that gets rendered with data from a relation)

If the manifests are static, instantiate the KubernetesManifestsRequirer.
In your charm do:

```
from charms.resource_dispatcher.v0.kubernetes_manifests import KubernetesManifestsRequirer, KubernetesManifest
# ...

SECRETS_MANIFESTS = [
    KubernetesManifest(
    Path(SECRET1_PATH).read_text()
    ),
    KubernetesManifest(
    Path(SECRET2_PATH).read_text()
    ),
]

SA_MANIFESTS = [
    KubernetesManifest(
    Path(SA1_PATH).read_text()
    ),
    KubernetesManifest(
    Path(SA2_PATH).read_text()
    ),
]

class SomeCharm(CharmBase):
  def __init__(self, *args):
    # ...
    self.secrets_manifests_requirer = KubernetesManifestsRequirer(
            charm=self, relation_name="secrets", manifests_items=SECRETS_MANIFESTS
        )
    self.service_accounts_requirer = KubernetesManifestsRequirer(
            charm=self, relation_name="service-accounts", manifests_items=SA_MANIFESTS
        )
    # ...
```

If the manifests are dynamic, instantiate the KubernetesManifestsRequirerWrapper.
In your charm do:

```
class SomeCharm(CharmBase):
    def __init__(self, *args):
        # ...
        self._secrets_manifests_wrapper = KubernetesManifestsRequirerWrapper(
            charm = self,
            relation_name = "secrets"
        )
        self._service_accounts_manifests_wrapper = KubernetesManifestsRequirerWrapper(
            charm = self,
            relation_name = "service-accounts"
        )

        self.framework.observe(self.on.leader_elected, self._send_secret)
        self.framework.observe(self.on["secrets"].relation_created, self._send_secret)
        # observe all the other events for when the secrets manifests change

        self.framework.observe(self.on.leader_elected, self._send_service_account)
        self.framework.observe(self.on["service-accounts"].relation_created, self._send_service_account)
        # observe all the other events for when the service accounts manifests change

    def _send_secret(self, _):
        #...
        Write the logic to re-calculate the manifests
        rendered_manifests = ...
        #...
        manifest_items = [KubernetesManifest(rendered_manifests)]
        self._secrets_manifests_wrapper.send_data(manifest_items)

    def _send_service_account(self, _):
        #...
        Write the logic to re-calculate the manifests
        rendered_manifests = ...
        #...
        manifest_items = [KubernetesManifest(rendered_manifests)]
        self._service_accounts_manifests_wrapper.send_data(manifest_items)
```

---

Index

* [def generate\_secret\_label(
  relation
  )](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests#generate_secret_label)
* [def parse\_relation\_id\_from\_secret\_label(
  secret\_label
  )](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests#parse_relation_id_from_secret_label)
* [class KubernetesManifest](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests#kubernetesmanifest)
* + [def \_\_post\_init\_\_(
    self)](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests#kubernetesmanifest-__post_init__)
* [class KubernetesManifestsUpdatedEvent](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests#kubernetesmanifestsupdatedevent)
* [class KubernetesManifestsEvents](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests#kubernetesmanifestsevents)
* [class KubernetesManifestsProvider](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests#kubernetesmanifestsprovider)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name,
    refresh\_event)](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests#kubernetesmanifestsprovider-__init__)
* + [def is\_secret\_enabled(
    self,
    relation)](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests#kubernetesmanifestsprovider-is_secret_enabled)
* + [def get\_manifests(
    self)](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests#kubernetesmanifestsprovider-get_manifests)
* + [def register\_secrets\_to\_relation(
    self,
    relation)](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests#kubernetesmanifestsprovider-register_secrets_to_relation)
* [class KubernetesManifestsRequirer](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests#kubernetesmanifestsrequirer)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name,
    manifests\_items,
    refresh\_event)](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests#kubernetesmanifestsrequirer-__init__)
* [class KubernetesManifestRequirerWrapper](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests#kubernetesmanifestrequirerwrapper)
* + [def \_\_init\_\_(
    self,
    charm,
    relation\_name)](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests#kubernetesmanifestrequirerwrapper-__init__)
* + [def send\_data(
    self,
    manifest\_items)](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests#kubernetesmanifestrequirerwrapper-send_data)
* [def get\_name\_of\_breaking\_app(
  relation\_name
  )](https://charmhub.io/resource-dispatcher/libraries/kubernetes_manifests#get_name_of_breaking_app)

#### def generate\_secret\_label(relation: Relation)

Description

Generate a unique secret label based on the relation name and ID. None

#### def parse\_relation\_id\_from\_secret\_label(secret\_label: str)

Description

Parse the relation id from a secret label. None

#### class KubernetesManifest

Representation of a Kubernetes Object sent to Kubernetes Manifests.

Arguments

manifest\_content

the content of the Kubernetes manifest file

Methods

KubernetesManifest.
\_\_post\_init\_\_(

*self*
)

Description

Validate that the manifest content is a valid YAML. None

#### class KubernetesManifestsUpdatedEvent

Description

Indicates the Kubernetes Objects data was updated. None

#### class KubernetesManifestsEvents

Description

Events for the Kubernetes Manifests library. None

#### class KubernetesManifestsProvider

Description

Relation manager for the Provider side of the Kubernetes Manifests relations. None

Methods

KubernetesManifestsProvider.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
relation\_name: str

,
refresh\_event
)

Relation manager for the Provider side of the Kubernetes Manifests relations.

Arguments

charm

Charm this relation is being used by

relation\_name

Name of this relation (from metadata.yaml)

refresh\_event

List of BoundEvents that this manager should handle. Use this to update
the data sent on this relation on demand.

Description

This relation manager subscribes to:

* on[relation\_name].relation\_changed
* secret\_changed
* any events provided in refresh\_event

This library emits:

* KubernetesManifestsUpdatedEvent:
  when data received on the relation (either as plaintext or as secret) is updated

KubernetesManifestsProvider.
is\_secret\_enabled(

*self*

,
relation: Relation
)

Description

Return whether secret support is enabled for this relation. None

KubernetesManifestsProvider.
get\_manifests(

*self*
)

Description

Returns a list of manifest dictionaries sent in the data of relation relation\_name. If this relation supports sharing data over Juju secrets, the secret is decoded
on-the-fly to return the actual list of manifest dictionaries.

KubernetesManifestsProvider.
register\_secrets\_to\_relation(

*self*

,
relation: Relation
)

Description

Register the secret received in the relation with a label (local to this application). This is necessary because afterwards in secret-changed, we reference this secret with its local label.

#### class KubernetesManifestsRequirer

Description

Relation manager for the Requirer side of the Kubernetes Manifests relation. None

Methods

KubernetesManifestsRequirer.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
relation\_name: str

,
manifests\_items

,
refresh\_event
)

Relation manager for the Requirer side of the Kubernetes Manifests relation.

Arguments

charm

Charm this relation is being used by

relation\_name

Name of this relation (from metadata.yaml)

manifests\_items

List of KubernetesManifest objects to send over the relation

refresh\_event

List of BoundEvents that this manager should handle. Use this to update
the data sent on this relation on demand.

Description

This relation manager subscribes to:

* on.leader\_elected: because only the leader is allowed to provide this data, and
  relation\_created may fire before the leadership election
* on[relation\_name].relation\_created
* any events provided in refresh\_event

This library emits:

* (nothing)

#### class KubernetesManifestRequirerWrapper

Description

Wrapper for the relation data sending logic None

Methods

KubernetesManifestRequirerWrapper.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
relation\_name: str
)

KubernetesManifestRequirerWrapper.
send\_data(

*self*

,
manifest\_items
)

Description

Sends the manifests data to the relation in json format. None

#### def get\_name\_of\_breaking\_app(relation\_name: str)

Description

Get the name of a remote application that is leaving the relation during a relation broken event by checking Juju environment variables.
If the application name is available, returns the name as a string;
otherwise None.
