Fix operator watching an alternative namespace

This commit is contained in:
andreaTP 2022-05-18 10:58:51 +01:00 committed by Bruno Oliveira da Silva
parent 45193dba0e
commit 8882c09901
4 changed files with 5 additions and 5 deletions

View file

@ -94,7 +94,7 @@ spec:
- -jar
- quarkus-run.jar
env:
- name: WATCH_NAMESPACE
- name: QUARKUS_OPERATOR_SDK_NAMESPACES
valueFrom:
fieldRef:
fieldPath: metadata.annotations['olm.targetNamespaces']

View file

@ -53,7 +53,7 @@ public abstract class OperatorManagedResource {
setOwnerReferences(resource);
Log.debugf("Creating or updating resource: %s", resource);
resource = client.resource(resource).createOrReplace();
resource = client.resource(resource).inNamespace(getNamespace()).createOrReplace();
Log.debugf("Successfully created or updated resource: %s", resource);
} catch (Exception e) {
Log.error("Failed to create or update resource");

View file

@ -67,12 +67,12 @@ public class KeycloakController implements Reconciler<Keycloak>, EventSourceInit
.runnableInformer(0);
SharedIndexInformer<Service> servicesInformer =
client.services().inNamespace(context.getConfigurationService().getClientConfiguration().getNamespace())
client.services().inNamespace(namespace)
.withLabels(Constants.DEFAULT_LABELS)
.runnableInformer(0);
SharedIndexInformer<Ingress> ingressesInformer =
client.network().v1().ingresses().inNamespace(context.getConfigurationService().getClientConfiguration().getNamespace())
client.network().v1().ingresses().inNamespace(namespace)
.withLabels(Constants.DEFAULT_LABELS)
.runnableInformer(0);

View file

@ -44,7 +44,7 @@ public class KeycloakIngress extends OperatorManagedResource implements StatusUp
protected Optional<HasMetadata> getReconciledResource() {
var defaultIngress = newIngress();
if (keycloak.getSpec().isDisableDefaultIngress() && existingIngress != null) {
client.network().v1().ingresses().delete(existingIngress);
client.network().v1().ingresses().inNamespace(getNamespace()).delete(existingIngress);
return Optional.empty();
} else if (existingIngress == null) {
return Optional.of(defaultIngress);