Change configuration format.
This commit is contained in:
parent
417fc736d7
commit
823bcedf1e
9 changed files with 55 additions and 52 deletions
|
|
@ -3,6 +3,7 @@
|
|||
"/Manager":
|
||||
"/Controller":
|
||||
namespace: vmop-dev
|
||||
"/Reconciler":
|
||||
runnerData:
|
||||
storageClassName: null
|
||||
loadBalancerService: |
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ patches:
|
|||
config.yaml: |
|
||||
"/Manager":
|
||||
"/Controller":
|
||||
runnerData:
|
||||
"/Reconciler"
|
||||
runnerDataPvc:
|
||||
# Default is to use the default storage class
|
||||
storageClassName: local-path
|
||||
|
|
|
|||
|
|
@ -26,5 +26,6 @@ patches:
|
|||
config.yaml: |
|
||||
"/Manager":
|
||||
"/Controller":
|
||||
"/Reconciler":
|
||||
runnerData:
|
||||
storageClassName: rook-cephfs
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
"/Manager":
|
||||
"/Controller":
|
||||
# Values used when creating the PVC for the runner's data
|
||||
runnerData:
|
||||
storageClassName: null
|
||||
# Explicitly specify the namespace to be managed (only for development).
|
||||
# namespace: vmop-dev
|
||||
|
||||
"/Reconciler":
|
||||
# Amount by which the current cpu count is devided when generating
|
||||
# the resource properties.
|
||||
cpuOvercommit: 2
|
||||
|
|
@ -14,6 +14,10 @@
|
|||
# the resource properties.
|
||||
ramOvercommit: 1.5
|
||||
|
||||
# Values used when creating the PVC for the runner's data
|
||||
runnerDataPvc:
|
||||
storageClassName: null
|
||||
|
||||
# If defined, causes a load balancer service to be created.
|
||||
# May be a boolean or a string with nested yaml that
|
||||
# defines additional labels or annotations to be merged
|
||||
|
|
@ -22,5 +26,3 @@
|
|||
# labels: {}
|
||||
# annotations: {}
|
||||
|
||||
# Explicitly specify the namespace to be managed (only for development).
|
||||
# namespace: vmop-dev
|
||||
|
|
|
|||
|
|
@ -96,15 +96,15 @@ spec:
|
|||
requests:
|
||||
<#if cr.spec.vm.currentCpus?? >
|
||||
<#assign factor = 2.0 />
|
||||
<#if config.cpuOvercommit??>
|
||||
<#assign factor = config.cpuOvercommit * 1.0 />
|
||||
<#if reconciler.cpuOvercommit??>
|
||||
<#assign factor = reconciler.cpuOvercommit * 1.0 />
|
||||
</#if>
|
||||
cpu: ${ (cr.spec.vm.currentCpus.asInt / factor)?floor?c }
|
||||
</#if>
|
||||
<#if cr.spec.vm.currentRam?? >
|
||||
<#assign factor = 1.25 />
|
||||
<#if config.ramOvercommit??>
|
||||
<#assign factor = config.ramOvercommit * 1.0 />
|
||||
<#if reconciler.ramOvercommit??>
|
||||
<#assign factor = reconciler.ramOvercommit * 1.0 />
|
||||
</#if>
|
||||
memory: ${ (parseMemory(cr.spec.vm.currentRam.asString) / factor)?floor?c }
|
||||
</#if>
|
||||
|
|
@ -151,8 +151,8 @@ spec:
|
|||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
<#if config.runnerData?? && config.runnerData.storageClassName??>
|
||||
storageClassName: ${ config.runnerData.storageClassName }
|
||||
<#if reconciler.runnerDataPvc?? && reconciler.runnerDataPvc.storageClassName??>
|
||||
storageClassName: ${ reconciler.runnerDataPvc.storageClassName }
|
||||
</#if>
|
||||
resources:
|
||||
requests:
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
|
|||
* Delegee for reconciling the config map
|
||||
*/
|
||||
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
|
||||
/* default */ class CmReconciler {
|
||||
/* default */ class ConfigMapReconciler {
|
||||
|
||||
protected final Logger logger = Logger.getLogger(getClass().getName());
|
||||
private final Configuration fmConfig;
|
||||
|
|
@ -50,7 +50,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
|
|||
*
|
||||
* @param fmConfig the fm config
|
||||
*/
|
||||
public CmReconciler(Configuration fmConfig) {
|
||||
public ConfigMapReconciler(Configuration fmConfig) {
|
||||
this.fmConfig = fmConfig;
|
||||
}
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
|
|||
// Check if to be generated
|
||||
@SuppressWarnings("unchecked")
|
||||
var lbs = Optional.of(model)
|
||||
.map(m -> (Map<String, Object>) m.get("config"))
|
||||
.map(m -> (Map<String, Object>) m.get("reconciler"))
|
||||
.map(c -> c.get(LOAD_BALANCER_SERVICE)).orElse(Boolean.FALSE);
|
||||
if (lbs instanceof Boolean isOn && !isOn) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ import org.jdrupes.vmoperator.util.ExtendedObjectWrapper;
|
|||
import org.jdrupes.vmoperator.util.ParseUtils;
|
||||
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;
|
||||
|
||||
|
|
@ -58,8 +57,8 @@ public class Reconciler extends Component {
|
|||
|
||||
@SuppressWarnings("PMD.SingularField")
|
||||
private final Configuration fmConfig;
|
||||
private final CmReconciler cmReconciler;
|
||||
private final StsReconciler stsReconciler;
|
||||
private final ConfigMapReconciler cmReconciler;
|
||||
private final StatefuleSetReconciler stsReconciler;
|
||||
private final LoadBalancerReconciler lbReconciler;
|
||||
@SuppressWarnings("PMD.UseConcurrentHashMap")
|
||||
private final Map<String, Object> config = new HashMap<>();
|
||||
|
|
@ -82,8 +81,8 @@ public class Reconciler extends Component {
|
|||
fmConfig.setLogTemplateExceptions(false);
|
||||
fmConfig.setClassForTemplateLoading(Reconciler.class, "");
|
||||
|
||||
cmReconciler = new CmReconciler(fmConfig);
|
||||
stsReconciler = new StsReconciler(fmConfig);
|
||||
cmReconciler = new ConfigMapReconciler(fmConfig);
|
||||
stsReconciler = new StatefuleSetReconciler(fmConfig);
|
||||
lbReconciler = new LoadBalancerReconciler(fmConfig);
|
||||
}
|
||||
|
||||
|
|
@ -94,8 +93,7 @@ public class Reconciler extends Component {
|
|||
*/
|
||||
@Handler
|
||||
public void onConfigurationUpdate(ConfigurationUpdate event) {
|
||||
event.structured(Components.manager(parent()).componentPath())
|
||||
.ifPresent(c -> {
|
||||
event.structured(componentPath()).ifPresent(c -> {
|
||||
config.putAll(c);
|
||||
});
|
||||
}
|
||||
|
|
@ -153,7 +151,7 @@ public class Reconciler extends Component {
|
|||
Configuration.VERSION_2_3_32)
|
||||
.build().getStaticModels()
|
||||
.get(Constants.class.getName()));
|
||||
model.put("config", config);
|
||||
model.put("reconciler", config);
|
||||
|
||||
// Methods
|
||||
model.put("parseMemory", new TemplateMethodModelEx() {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
|
|||
* Delegee for reconciling the stateful set (effectively the pod).
|
||||
*/
|
||||
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
|
||||
/* default */ class StsReconciler {
|
||||
/* default */ class StatefuleSetReconciler {
|
||||
|
||||
protected final Logger logger = Logger.getLogger(getClass().getName());
|
||||
private final Configuration fmConfig;
|
||||
|
|
@ -47,7 +47,7 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
|
|||
*
|
||||
* @param fmConfig the fm config
|
||||
*/
|
||||
public StsReconciler(Configuration fmConfig) {
|
||||
public StatefuleSetReconciler(Configuration fmConfig) {
|
||||
this.fmConfig = fmConfig;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue