fix: add proxy env propagation (#30741)

* fix: add proxy env propagation

closes: #30165

Signed-off-by: Steve Hawkins <shawkins@redhat.com>

* Update operator/src/main/java/org/keycloak/operator/controllers/KeycloakDeploymentDependentResource.java

Co-authored-by: Martin Bartoš <mabartos@redhat.com>

---------

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
Co-authored-by: Martin Bartoš <mabartos@redhat.com>
This commit is contained in:
Steven Hawkins 2024-06-25 12:02:27 -04:00 committed by GitHub
parent 32e3063a6d
commit bc38b5db1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -53,6 +53,7 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.LinkedHashMap;
import java.util.List;
@ -74,6 +75,8 @@ import static org.keycloak.operator.crds.v2alpha1.CRDUtils.isTlsConfigured;
@KubernetesDependent(labelSelector = Constants.DEFAULT_LABELS_AS_STRING)
public class KeycloakDeploymentDependentResource extends CRUDKubernetesDependentResource<StatefulSet, Keycloak> {
private static final List<String> COPY_ENV = Arrays.asList("HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY");
private static final String SERVICE_ACCOUNT_DIR = "/var/run/secrets/kubernetes.io/serviceaccount/";
private static final String SERVICE_CA_CRT = SERVICE_ACCOUNT_DIR + "service-ca.crt";
@ -419,7 +422,14 @@ public class KeycloakDeploymentDependentResource extends CRUDKubernetesDependent
}
return envBuilder.build();
})
.collect(Collectors.toList());
.collect(Collectors.toCollection(ArrayList::new));
for (String env : COPY_ENV) {
String value = System.getenv(env);
if (value != null) {
envVars.add(new EnvVarBuilder().withName(env).withValue(value).build());
}
}
envVars.add(
new EnvVarBuilder()