mirror of
https://github.com/keycloak/keycloak.git
synced 2026-05-07 23:50:03 -05:00
Stops the recreation of managed Keycloak Statefulset Pods when Keycloak Operator restarts occasionally. (#20187)
This commit is contained in:
committed by
GitHub
parent
025778fe9c
commit
851ecb43fc
@@ -16,6 +16,9 @@
|
||||
*/
|
||||
package org.keycloak.operator;
|
||||
|
||||
import org.keycloak.operator.crds.v2alpha1.deployment.ValueOrSecret;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -39,13 +42,14 @@ public final class Constants {
|
||||
.map(e -> e.getKey() + "=" + e.getValue())
|
||||
.collect(Collectors.joining(","));
|
||||
|
||||
public static final Map<String, String> DEFAULT_DIST_CONFIG = Map.of(
|
||||
"health-enabled","true",
|
||||
"cache", "ispn",
|
||||
"cache-stack", "kubernetes",
|
||||
"proxy", "passthrough"
|
||||
public static final List<ValueOrSecret> DEFAULT_DIST_CONFIG_LIST = List.of(
|
||||
new ValueOrSecret("health-enabled", "true"),
|
||||
new ValueOrSecret("cache", "ispn"),
|
||||
new ValueOrSecret("cache-stack", "kubernetes"),
|
||||
new ValueOrSecret("proxy", "passthrough")
|
||||
);
|
||||
|
||||
|
||||
public static final Integer KEYCLOAK_HTTP_PORT = 8080;
|
||||
public static final Integer KEYCLOAK_HTTPS_PORT = 8443;
|
||||
public static final String KEYCLOAK_SERVICE_PROTOCOL = "TCP";
|
||||
|
||||
@@ -429,19 +429,17 @@ public class KeycloakDeployment extends OperatorManagedResource implements Statu
|
||||
|
||||
private List<EnvVar> getEnvVars() {
|
||||
// default config values
|
||||
List<ValueOrSecret> serverConfig = Constants.DEFAULT_DIST_CONFIG.entrySet().stream()
|
||||
.map(e -> new ValueOrSecret(e.getKey(), e.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
List<ValueOrSecret> serverConfigsList = new ArrayList<>(Constants.DEFAULT_DIST_CONFIG_LIST);
|
||||
|
||||
// merge with the CR; the values in CR take precedence
|
||||
if (keycloakCR.getSpec().getAdditionalOptions() != null) {
|
||||
serverConfig.removeAll(keycloakCR.getSpec().getAdditionalOptions());
|
||||
serverConfig.addAll(keycloakCR.getSpec().getAdditionalOptions());
|
||||
serverConfigsList.removeAll(keycloakCR.getSpec().getAdditionalOptions());
|
||||
serverConfigsList.addAll(keycloakCR.getSpec().getAdditionalOptions());
|
||||
}
|
||||
|
||||
// set env vars
|
||||
serverConfigSecretsNames = new HashSet<>();
|
||||
List<EnvVar> envVars = serverConfig.stream()
|
||||
List<EnvVar> envVars = serverConfigsList.stream()
|
||||
.map(v -> {
|
||||
var envBuilder = new EnvVarBuilder().withName(KeycloakDistConfigurator.getKeycloakOptionEnvVarName(v.getName()));
|
||||
var secret = v.getSecret();
|
||||
|
||||
Reference in New Issue
Block a user