When starting the Red Hat build of Keycloak (RHBK) Operator, "Failure in creating proxy URL. Proxy port is required!" is returned

Solution Verified - Updated -

Environment

  • Red Hat Build of Keycloak (RHBK)
  • RHBK operator
  • Cluster Wide Proxy

Issue

RHBK Operator is failing when these two variables called HTTP_PROXY and HTTPS_PROXY do not use port number in cluster-Wide proxy configuration. The setting is like the following:

apiVersion: config.openshift.io/v1
kind: Proxy
metadata:
  name: cluster
spec:
  httpProxy: http://myproxy
  httpsProxy: https://myproxy
  noProxy: example.com 
  trustedCA:
    name: user-ca-bundle 

Resolution

Upstream issue was opened: https://github.com/keycloak/keycloak/issues/30165

As a workaround, Cluster-wide proxy should be configured using the port number as described below:

apiVersion: config.openshift.io/v1
kind: Proxy
metadata:
  name: cluster
spec:
  httpProxy: http://myproxy:port
  httpsProxy: https://myproxy:port
  noProxy: example.com 
  trustedCA:
    name: user-ca-bundle 

Root Cause

The Operator should correctly handle proxy related env vars: HTTP_PROXY, HTTPS_PROXY and NO_PROXY. Those env vars are de facto a standard.

The Operator should take one of the following approaches:

  • Ignore the env vars as it might not make much sense for the Operator to use proxy. Only outgoing requests are toward the Kube API.
  • Properly support the env vars and use the specified proxy setting for all potential outgoing requests (incl. Kube API).
    • A best practice is also considered for the Operator to pass down the env vars to the Operand pods.

Diagnostic Steps

Step 1:
Configure cluster-wide proxyas described below:
You can follow this part of the documentation to do so 33.2. Enabling the cluster-wide proxy

apiVersion: config.openshift.io/v1
kind: Proxy
metadata:
  name: cluster
spec:
  httpProxy: http://myproxy
  httpsProxy: https://myproxy
  noProxy: example.com 
  trustedCA:
    name: user-ca-bundle 

Step 2:
Install the RHBK Operator using the procedure described in the documentation: Chapter 1. Red Hat build of Keycloak Operator installation

Step 3:
Check the pod logs and find the following error:

ERROR [io.qua.run.Application] (main) Failed to start application (with profile [prod]): java.lang.RuntimeException: Failed to start quarkus
    at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
    at io.quarkus.runtime.Application.start(Application.java:101)
    at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:111)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
    at io.quarkus.runner.GeneratedMain.main(Unknown Source)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:62)
    at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:33)
Caused by: java.lang.IllegalArgumentException: Failure in creating proxy URL. Proxy port is required!
    at io.fabric8.kubernetes.client.utils.HttpClientUtils.getProxyUri(HttpClientUtils.java:91)
    at io.fabric8.kubernetes.client.utils.HttpClientUtils.configureProxy(HttpClientUtils.java:210)
    at io.fabric8.kubernetes.client.utils.HttpClientUtils.applyCommonConfiguration(HttpClientUtils.java:185)
    at io.fabric8.kubernetes.client.http.HttpClient$Factory.newBuilder(HttpClient.java:51)
    at io.quarkus.kubernetes.client.runtime.QuarkusHttpClientFactory.newBuilder(QuarkusHttpClientFactory.java:57)
    at io.fabric8.kubernetes.client.KubernetesClientBuilder.getHttpClient(KubernetesClientBuilder.java:90)
    at io.fabric8.kubernetes.client.KubernetesClientBuilder.build(KubernetesClientBuilder.java:79)
    at io.javaoperatorsdk.operator.api.config.ConfigurationService.getKubernetesClient(ConfigurationService.java:97)
    at io.javaoperatorsdk.operator.api.config.AbstractConfigurationService.getKubernetesClient(AbstractConfigurationService.java:159)
    at io.javaoperatorsdk.operator.Operator.initConfigurationService(Operator.java:86)
    at io.javaoperatorsdk.operator.Operator.<init>(Operator.java:78)
    at io.javaoperatorsdk.operator.Operator.<init>(Operator.java:38)
    at io.javaoperatorsdk.operator.Operator.<init>(Operator.java:34)
    at io.javaoperatorsdk.operator.OperatorProducer_ProducerMethod_operator_4a13E9CyUpNLli_Z-91F5zETApk_ClientProxy.<init>(Unknown Source)
    at io.quarkiverse.operatorsdk.runtime.OperatorProducer_ProducerMethod_operator_4a13E9CyUpNLli_Z-91F5zETApk_Bean.proxy(Unknown Source)
    at io.quarkiverse.operatorsdk.runtime.OperatorProducer_ProducerMethod_operator_4a13E9CyUpNLli_Z-91F5zETApk_Bean.get(Unknown Source)
    at io.quarkiverse.operatorsdk.runtime.OperatorProducer_ProducerMethod_operator_4a13E9CyUpNLli_Z-91F5zETApk_Bean.get(Unknown Source)
    at io.quarkiverse.operatorsdk.runtime.AppEventListener_Bean.doCreate(Unknown Source)
    at io.quarkiverse.operatorsdk.runtime.AppEventListener_Bean.create(Unknown Source)
    at io.quarkiverse.operatorsdk.runtime.AppEventListener_Bean.create(Unknown Source)
    at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:119)
    at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:38)
    at io.quarkus.arc.impl.AbstractSharedContext$1.get(AbstractSharedContext.java:35)
    at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:32)
    at io.quarkus.arc.impl.ComputingCache.computeIfAbsent(ComputingCache.java:69)
    at io.quarkus.arc.impl.ComputingCacheContextInstances.computeIfAbsent(ComputingCacheContextInstances.java:19)
    at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:35)
    at io.quarkiverse.operatorsdk.runtime.AppEventListener_Observer_onStartup_lQpwZkDdRQXLkHyaStWxDBo99eQ.notify(Unknown Source)
    at io.quarkus.arc.impl.EventImpl$Notifier.notifyObservers(EventImpl.java:346)
    at io.quarkus.arc.impl.EventImpl$Notifier.notify(EventImpl.java:328)
    at io.quarkus.arc.impl.EventImpl.fire(EventImpl.java:82)
    at io.quarkus.arc.runtime.ArcRecorder.fireLifecycleEvent(ArcRecorder.java:155)
    at io.quarkus.arc.runtime.ArcRecorder.handleLifecycleEvents(ArcRecorder.java:106)
    at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent1144526294.deploy_0(Unknown Source)
    at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent1144526294.deploy(Unknown Source)
    ... 13 more

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments