Use embedded YAML for load balancer configuration.
This commit is contained in:
parent
cdc37725ce
commit
0419136a59
2 changed files with 7 additions and 8 deletions
|
|
@ -75,16 +75,16 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||||
Map<String, Object> model, VmChannel channel)
|
Map<String, Object> model, VmChannel channel)
|
||||||
throws IOException, TemplateException, ApiException {
|
throws IOException, TemplateException, ApiException {
|
||||||
// Check if to be generated
|
// Check if to be generated
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({ "unchecked", "PMD.AvoidDuplicateLiterals" })
|
||||||
var lbs = Optional.of(model)
|
var lbs = Optional.of(model)
|
||||||
.map(m -> (Map<String, Object>) m.get("reconciler"))
|
.map(m -> (Map<String, Object>) m.get("reconciler"))
|
||||||
.map(c -> c.get(LOAD_BALANCER_SERVICE)).orElse(Boolean.FALSE);
|
.map(c -> c.get(LOAD_BALANCER_SERVICE)).orElse(Boolean.FALSE);
|
||||||
if (lbs instanceof Boolean isOn && !isOn) {
|
if (lbs instanceof Boolean isOn && !isOn) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(lbs instanceof String)) {
|
if (!(lbs instanceof Map)) {
|
||||||
logger.warning(() -> "\"" + LOAD_BALANCER_SERVICE
|
logger.warning(() -> "\"" + LOAD_BALANCER_SERVICE
|
||||||
+ "\" in configuration must be boolean or string but is "
|
+ "\" in configuration must be boolean or mapping but is "
|
||||||
+ lbs.getClass() + ".");
|
+ lbs.getClass() + ".");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -110,9 +110,8 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||||
Object lbsConfig, VmChannel channel) {
|
Object lbsConfig, VmChannel channel) {
|
||||||
// Get metadata from config
|
// Get metadata from config
|
||||||
Map<String, Object> asmData = Collections.emptyMap();
|
Map<String, Object> asmData = Collections.emptyMap();
|
||||||
if (lbsConfig instanceof String config) {
|
if (lbsConfig instanceof Map config) {
|
||||||
asmData = (Map<String, Object>) new Yaml(
|
asmData = (Map<String, Object>) config;
|
||||||
new SafeConstructor(new LoaderOptions())).load(config);
|
|
||||||
}
|
}
|
||||||
var json = channel.client().getJSON();
|
var json = channel.client().getJSON();
|
||||||
JsonObject cfgMeta
|
JsonObject cfgMeta
|
||||||
|
|
|
||||||
|
|
@ -106,12 +106,12 @@ import org.jgrapes.util.events.ConfigurationUpdate;
|
||||||
* properties for the VM (defaults to 1.25).
|
* properties for the VM (defaults to 1.25).
|
||||||
*
|
*
|
||||||
* * `loadBalancerService`: If defined, causes a load balancer service
|
* * `loadBalancerService`: If defined, causes a load balancer service
|
||||||
* to be created. This property may be a boolean or a string with nested
|
* to be created. This property may be a boolean or
|
||||||
* YAML that defines additional labels or annotations to be merged
|
* YAML that defines additional labels or annotations to be merged
|
||||||
* into the service defintion. Here's an example for using
|
* into the service defintion. Here's an example for using
|
||||||
* [MetalLb](https://metallb.universe.tf/) as "internal load balancer":
|
* [MetalLb](https://metallb.universe.tf/) as "internal load balancer":
|
||||||
* ```yaml
|
* ```yaml
|
||||||
* loadBalancerService: |
|
* loadBalancerService:
|
||||||
* annotations:
|
* annotations:
|
||||||
* metallb.universe.tf/loadBalancerIPs: 192.168.168.1
|
* metallb.universe.tf/loadBalancerIPs: 192.168.168.1
|
||||||
* metallb.universe.tf/ip-allocated-from-pool: single-common
|
* metallb.universe.tf/ip-allocated-from-pool: single-common
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue