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)
|
||||
throws IOException, TemplateException, ApiException {
|
||||
// Check if to be generated
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({ "unchecked", "PMD.AvoidDuplicateLiterals" })
|
||||
var lbs = Optional.of(model)
|
||||
.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;
|
||||
}
|
||||
if (!(lbs instanceof String)) {
|
||||
if (!(lbs instanceof Map)) {
|
||||
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() + ".");
|
||||
return;
|
||||
}
|
||||
|
|
@ -110,9 +110,8 @@ import org.yaml.snakeyaml.constructor.SafeConstructor;
|
|||
Object lbsConfig, VmChannel channel) {
|
||||
// Get metadata from config
|
||||
Map<String, Object> asmData = Collections.emptyMap();
|
||||
if (lbsConfig instanceof String config) {
|
||||
asmData = (Map<String, Object>) new Yaml(
|
||||
new SafeConstructor(new LoaderOptions())).load(config);
|
||||
if (lbsConfig instanceof Map config) {
|
||||
asmData = (Map<String, Object>) config;
|
||||
}
|
||||
var json = channel.client().getJSON();
|
||||
JsonObject cfgMeta
|
||||
|
|
|
|||
|
|
@ -106,12 +106,12 @@ import org.jgrapes.util.events.ConfigurationUpdate;
|
|||
* properties for the VM (defaults to 1.25).
|
||||
*
|
||||
* * `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
|
||||
* into the service defintion. Here's an example for using
|
||||
* [MetalLb](https://metallb.universe.tf/) as "internal load balancer":
|
||||
* ```yaml
|
||||
* loadBalancerService: |
|
||||
* loadBalancerService:
|
||||
* annotations:
|
||||
* metallb.universe.tf/loadBalancerIPs: 192.168.168.1
|
||||
* metallb.universe.tf/ip-allocated-from-pool: single-common
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue