Resource Dispatcher
- Kubeflow Charmers
Channel | Revision | Published | Runs on |
---|---|---|---|
latest/stable | 93 | 13 Sep 2023 | |
latest/beta | 93 | 13 Sep 2023 | |
latest/edge | 236 | 13 Dec 2024 | |
2.0/stable | 182 | 09 Aug 2024 | |
2.0/beta | 182 | 09 Aug 2024 | |
2.0/edge | 206 | 04 Oct 2024 | |
1.0/stable | 93 | 13 Sep 2023 | |
1.0/beta | 93 | 13 Sep 2023 | |
1.0/edge | 186 | 27 Aug 2024 |
juju deploy resource-dispatcher
Deploy Kubernetes operators easily with Juju, the Universal Operator Lifecycle Manager. Need a Kubernetes cluster? Install MicroK8s to create a full CNCF-certified Kubernetes system in under 60 seconds.
Platform:
charms.resource_dispatcher.v0.resource_dispatcher
-
- Last updated 23 Jan 2024
- Revision Library version 0.1
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.
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
class KubernetesManifest
Representation of a Kubernetes Object sent to Kubernetes Manifests.
Arguments
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 this relation is being used by
Name of this relation (from metadata.yaml)
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
- any events provided in refresh_event
This library emits:
- KubernetesManifestsUpdatedEvent: when data received on the relation is updated
KubernetesManifestsProvider. get_manifests( self )
Description
Returns a list of dictionaries sent in the data of relation relation_name. None
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 this relation is being used by
Name of this relation (from metadata.yaml)
List of KubernetesManifest objects to send over the relation
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.