-
Notifications
You must be signed in to change notification settings - Fork 1
multiple substrates design
René Radoi edited this page Jan 9, 2026
·
1 revision
- can be done via
ops.model.get_cloud_spec() - cloud_spec.type returns either
kubernetesor something else (e.g.lxd) - everything else than
kubernetesmeans 'vm'
- can be added to the charm code
- will not be received on the other substrate -> logic must take this into consideration
- in charm structure pattern, there is already an abstract base class for workload, with overrides per substrate
- approach: include a substrate-specific class for K8s and for VM into the same charm code
- differentiate which class to instantiate in charm class init: if cloud_spec.type ==
kubernetes-> K8sWorkload class, otherwise VmWorkload class - within the substrate-specific class, implement things like: run subprocess, install snap, define pebble service layer
- because of difference between snap paths and rock paths, workload paths need to be specific per workload class
- same approach as for workload: differentiate class to instantiate by cloud type
- yes, was confirmed by testing; container is ignored
- this is required also for VM deployments
- is actually only relevant for deploying a local version of the charm
- for deployments from charmhub, the resource can be the one defined/uploaded in charmhub
- in general: nothing speaks against it (according to Juju team)
- needs to be confirmed by testing
- should be ignored on VM and displayed to user (e.g. via status)
- maybe we can convince juju to handle that
- should be abstracted via
endpoints - actual endpoint will be handled by substrate-specific workload class
try:
cloud_spec = self.model.get_cloud_spec()
except ModellError:
raise # to catch when deployed without --trust
if cloud_spec.type == "kubernetes":
self.workload = ValkeyK8sWorkload(container=self.unit.get_container(CONTAINER))
else:
self.workload = ValkeyVmWorkload()
-
ops.model.get_cloud_spec()requires application to betrusted->--trustneeds to be added at deploy time, even for VM - have separate integration tests for VM and K8s in the same repository