diff --git a/dev-example/config.yaml b/dev-example/config.yaml index 342ac4e..45a33bc 100644 --- a/dev-example/config.yaml +++ b/dev-example/config.yaml @@ -3,3 +3,5 @@ "/Manager": "/Controller": namespace: vmop-dev + runnerData: + storageClassName: null diff --git a/org.jdrupes.vmoperator.manager/config-sample.yaml b/org.jdrupes.vmoperator.manager/config-sample.yaml new file mode 100644 index 0000000..e2b2619 --- /dev/null +++ b/org.jdrupes.vmoperator.manager/config-sample.yaml @@ -0,0 +1,10 @@ +# The values in comments are the defaults. + +"/Manager": + "/Controller": + # Values used when creating the PVC for the runner's data + runnerData: + storageClassName: null + + # Only for development: + # namespace: vmop-dev diff --git a/org.jdrupes.vmoperator.manager/resources/org/jdrupes/vmoperator/manager/runnerSts.ftl.yaml b/org.jdrupes.vmoperator.manager/resources/org/jdrupes/vmoperator/manager/runnerSts.ftl.yaml index e2390d9..f4bdd17 100644 --- a/org.jdrupes.vmoperator.manager/resources/org/jdrupes/vmoperator/manager/runnerSts.ftl.yaml +++ b/org.jdrupes.vmoperator.manager/resources/org/jdrupes/vmoperator/manager/runnerSts.ftl.yaml @@ -30,7 +30,7 @@ spec: - name: ${ cr.metadata.name.asString } <#assign image = cr.spec.image> <#if image.source??> - image: ${ source.asString } + image: ${ image.source.asString } <#else> image: ${ image.repository.asString }/${ image.path.asString }<#if image.version??>:${ image.version.asString } @@ -101,6 +101,9 @@ spec: spec: accessModes: - ReadWriteOnce + <#if config.runnerData?? && config.runnerData.storageClassName??> + storageClassName: ${ config.runnerData.storageClassName } + resources: requests: storage: 1Mi diff --git a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Reconciler.java b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Reconciler.java index 1e32a0d..dd5b864 100644 --- a/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Reconciler.java +++ b/org.jdrupes.vmoperator.manager/src/org/jdrupes/vmoperator/manager/Reconciler.java @@ -40,7 +40,9 @@ import org.jdrupes.vmoperator.manager.VmDefChanged.Type; import org.jdrupes.vmoperator.util.ExtendedObjectWrapper; import org.jgrapes.core.Channel; import org.jgrapes.core.Component; +import org.jgrapes.core.Components; import org.jgrapes.core.annotation.Handler; +import org.jgrapes.util.events.ConfigurationUpdate; /** * Adapts Kubenetes resources to changes in VM definitions (CRs). @@ -54,6 +56,8 @@ public class Reconciler extends Component { private final CmReconciler cmReconciler; private final StsReconciler stsReconciler; private final ServiceReconciler serviceReconciler; + @SuppressWarnings("PMD.UseConcurrentHashMap") + private final Map config = new HashMap<>(); /** * Instantiates a new reconciler. @@ -78,6 +82,21 @@ public class Reconciler extends Component { serviceReconciler = new ServiceReconciler(fmConfig); } + /** + * Configure the component. + * + * @param event the event + */ + @Handler + public void onConfigurationUpdate(ConfigurationUpdate event) { + event.structured(Components.manager(parent()).componentPath()) + .ifPresent(c -> { + if (c.containsKey("runnerData")) { + config.put("runnerData", c.get("runnerData")); + } + }); + } + /** * Handles the change event. * @@ -117,6 +136,7 @@ public class Reconciler extends Component { Configuration.VERSION_2_3_32) .build().getStaticModels() .get(Constants.class.getName())); + model.put("config", config); // Reconcile if (event.type() != Type.DELETED) {