use of io.fabric8.kubernetes.api.model.EnvVarBuilder in project keycloak by keycloak.
the class KeycloakDeployment method createBaseDeployment.
private Deployment createBaseDeployment() {
var is = this.getClass().getResourceAsStream("/base-keycloak-deployment.yaml");
Deployment baseDeployment = Serialization.unmarshal(is, Deployment.class);
baseDeployment.getMetadata().setName(getName());
baseDeployment.getMetadata().setNamespace(getNamespace());
baseDeployment.getSpec().getSelector().setMatchLabels(Constants.DEFAULT_LABELS);
baseDeployment.getSpec().setReplicas(keycloakCR.getSpec().getInstances());
baseDeployment.getSpec().getTemplate().getMetadata().setLabels(Constants.DEFAULT_LABELS);
Container container = baseDeployment.getSpec().getTemplate().getSpec().getContainers().get(0);
container.setImage(Optional.ofNullable(keycloakCR.getSpec().getImage()).orElse(config.keycloak().image()));
var serverConfig = new HashMap<>(Constants.DEFAULT_DIST_CONFIG);
if (keycloakCR.getSpec().getServerConfiguration() != null) {
serverConfig.putAll(keycloakCR.getSpec().getServerConfiguration());
}
container.setImagePullPolicy(config.keycloak().imagePullPolicy());
container.setEnv(serverConfig.entrySet().stream().map(e -> new EnvVarBuilder().withName(e.getKey()).withValue(e.getValue()).build()).collect(Collectors.toList()));
addInitContainer(baseDeployment, keycloakCR.getSpec().getExtensions());
mergePodTemplate(baseDeployment.getSpec().getTemplate());
return baseDeployment;
}
Aggregations