Repository: kroxylicious/kroxylicious (java)

Issue:
Broker address used by proxy uses relative DNS name
**Describe the bug**

I've been experimenting with the proxy.

The broker address used by the proxy assumes the client will run within the same namespace as the proxy. In other words, it uses a relative DNS rather than an absolute one.

```
kubectl -n my-proxy run node-list -ti --image=quay.io/kroxylicious/kaf --rm=true --restart=Never -- kaf node ls -b my-cluster.my-proxy.svc.cluster.local:9292
ID    ADDRESS           CONTROLLER
0     my-cluster:9293   true
```


**To Reproduce**
Steps to reproduce the behavior:
1. Deploy the proxy operator as per kroxylicious-operator/DEV_GUIDE.md
2. Use Strimzi [quickstart](https://strimzi.io/quickstarts/) to deploy Strimzi operator and create `kafka-single-node`.
3. Create a proxy using the following:
```yaml
metadata:
  name: simple
  namespace: my-proxy
spec:
  clusters:
  - name: my-cluster
    upstream:
      bootstrapServers: my-cluster-kafka-bootstrap.kafka.svc:9092
```
4. Create a topic running the client in the same namespace as the proxy (works)
```
kubectl -n my-proxy run node-list -ti --image=quay.io/kroxylicious/kaf --rm=true --restart=Never -- kaf topic create  -b my-cluster.my-proxy.svc.cluster.local:9292  foo
```
5. Create a topic running the client in the different namespace as the proxy (**fails**)
```
kubectl -n kafka run node-list -ti --image=quay.io/kroxylicious/kaf --rm=true --restart=Never -- kaf topic create  -b my-cluster.my-proxy.svc.cluster.local:9292  bar
Could not create topic bar: dial tcp: lookup my-cluster on 10.96.0.10:53: no such host

pod "node-list" deleted
pod kafka/node-list terminated (Error)
```
**Expected behavior**

I should be able to run the client anywhere on the cluster (assuming sufficient RBAC of course).

**YAML files and logs**

Attach or copy paste your kroxylicious configuration YAML (with sensitive details
like broker address redacted).
Attach or copy and paste relevant logs.

**Additional context**
Add any other context about the problem here.


io.kroxylicious.kubernetes.operator.ClusterService#serviceName should be generating a FQDN.


Pull request description:
operator: Use absolute service host for brokerAddressPattern
### Type of change

- Bugfix

### Description

Enables client pods in arbitrary namespaces to connect to the proxy via the service created by the operator.

The brokerAddressPattern was previously the service name, which is resolved relative to the client pod namespace. So after clients retrieved cluster metadata via the proxy they could not connect to the brokers as they attempted to resolve the broker relative to their own namespace.

ie bootstrapping with `my-cluster.my-proxy.svc.cluster.local:9292` returned node addresses like `my-cluster:${brokerPort}` and the resolution failed in the client.

Closes #1606

### Checklist

_Please go through this checklist and make sure all applicable tasks have been done_

- [ ] Write tests
- [ ] Update documentation
- [ ] Make sure all unit/integration tests pass
- [ ] Make sure all Sonarcloud warnings are addressed or are justifiably ignored.
- [ ] If applicable to the change, [trigger the system test suite](../blob/main/DEV_GUIDE.md#jenkins-pipeline-for-system-tests).  Make sure tests pass.
- [ ] If applicable to the change, [trigger the performance test suite](../blob/main/PERFORMANCE.md#jenkins-pipeline-for-performance). Ensure that any degradations to performance numbers are understood and justified.
- [ ] Ensure the PR references relevant issue(s) so they are closed on merging.
- [ ] For user facing changes, update CHANGELOG.md (remember to include changes affecting the API of the test artefacts too).

> **_NOTE:_**  You must be a member of `@kroxylicious/developers` to trigger the system test and performance test suites.  If you are not part of this group, comment on the PR requesting a trigger, tagging `@kroxylicious/developers`.


Patch:
diff --git a/kroxylicious-operator/src/main/java/io/kroxylicious/kubernetes/operator/ClusterService.java b/kroxylicious-operator/src/main/java/io/kroxylicious/kubernetes/operator/ClusterService.java
index c52a9a25..57b8f3ba 100644
--- a/kroxylicious-operator/src/main/java/io/kroxylicious/kubernetes/operator/ClusterService.java
+++ b/kroxylicious-operator/src/main/java/io/kroxylicious/kubernetes/operator/ClusterService.java
@@ -48,6 +48,13 @@ public class ClusterService
         return cluster.getName();
     }
 
+    /**
+     * @return the fully qualified service hostname
+     */
+    static String absoluteServiceHost(KafkaProxy primary, Clusters cluster) {
+        return serviceName(cluster) + "." + primary.getMetadata().getNamespace() + ".svc.cluster.local";
+    }
+
     /**
      * The inverse of {@link #serviceName(Clusters)}
      * @param service A service
diff --git a/kroxylicious-operator/src/main/java/io/kroxylicious/kubernetes/operator/ProxyConfigSecret.java b/kroxylicious-operator/src/main/java/io/kroxylicious/kubernetes/operator/ProxyConfigSecret.java
index 75e5ddc3..f79910ca 100644
--- a/kroxylicious-operator/src/main/java/io/kroxylicious/kubernetes/operator/ProxyConfigSecret.java
+++ b/kroxylicious-operator/src/main/java/io/kroxylicious/kubernetes/operator/ProxyConfigSecret.java
@@ -200,7 +200,7 @@ public class ProxyConfigSecret
                         "PortPerBrokerClusterNetworkAddressConfigProvider",
                         new PortPerBrokerClusterNetworkAddressConfigProvider.PortPerBrokerClusterNetworkAddressConfigProviderConfig(
                                 new HostPort("localhost", 9292 + (100 * clusterNum)),
-                                ClusterService.serviceName(cluster),
+                                ClusterService.absoluteServiceHost(primary, cluster),
                                 null,
                                 null,
                                 null)),


Test patch:
diff --git a/kroxylicious-operator/src/test/java/io/kroxylicious/kubernetes/operator/DerivedResourcesTest.java b/kroxylicious-operator/src/test/java/io/kroxylicious/kubernetes/operator/DerivedResourcesTest.java
index c0c7d650..28853cf0 100644
--- a/kroxylicious-operator/src/test/java/io/kroxylicious/kubernetes/operator/DerivedResourcesTest.java
+++ b/kroxylicious-operator/src/test/java/io/kroxylicious/kubernetes/operator/DerivedResourcesTest.java
@@ -198,6 +198,7 @@ class DerivedResourcesTest {
         var unusedFiles = childFilesMatching(testDir, "*");
         Path input = testDir.resolve("in-KafkaProxy.yaml");
         KafkaProxy kafkaProxy = kafkaProxyFromFile(input);
+        assertMinimalMetadataPresent(kafkaProxy);
         unusedFiles.remove(input);
         unusedFiles.remove(testDir.resolve("operator-config.yaml"));
         unusedFiles.removeAll(childFilesMatching(testDir, "in-*"));
@@ -259,6 +260,12 @@ class DerivedResourcesTest {
         return tests;
     }
 
+    // sanity check since we can omit fields that the k8s API will ensure are present in reality
+    private static void assertMinimalMetadataPresent(HasMetadata resource) {
+        assertThat(resource.getMetadata().getName()).isNotNull().isNotEmpty();
+        assertThat(resource.getMetadata().getNamespace()).isNotNull().isNotEmpty();
+    }
+
     private static <T> void assertSameYaml(T actualResource, T expected) throws JsonProcessingException {
         if (!expected.equals(actualResource)) {
             // Failing with a String-based assert makes it **much** easier to understand what the diffs are
@@ -300,7 +307,9 @@ class DerivedResourcesTest {
         for (var filterApi : runtimeDecl.filterApis()) {
             try (var dirStream = Files.newDirectoryStream(testDir, "in-" + filterApi.kind() + "-*.yaml")) {
                 for (Path p : dirStream) {
-                    filterInstances.add(YAML_MAPPER.readValue(p.toFile(), GenericKubernetesResource.class));
+                    GenericKubernetesResource resource = YAML_MAPPER.readValue(p.toFile(), GenericKubernetesResource.class);
+                    assertMinimalMetadataPresent(resource);
+                    filterInstances.add(resource);
                 }
             }
         }
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/in-KafkaProxy.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/in-KafkaProxy.yaml
index 0b08e58d..be2f45c7 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/in-KafkaProxy.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/in-KafkaProxy.yaml
@@ -9,6 +9,7 @@ kind: KafkaProxy
 apiVersion: kroxylicious.io/v1alpha1
 metadata:
   name: example
+  namespace: proxy-ns
 spec:
   clusters:
   - name: "foo"
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/in-One-filter-one.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/in-One-filter-one.yaml
index 1ec2e21c..6050e477 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/in-One-filter-one.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/in-One-filter-one.yaml
@@ -9,5 +9,6 @@ kind: One
 apiVersion: org.example.one/v1
 metadata:
   name: filter-one
+  namespace: proxy-ns
 spec:
   filterOneConfig: true
\ No newline at end of file
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/in-Two-filter-two.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/in-Two-filter-two.yaml
index a892aebb..3421009b 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/in-Two-filter-two.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/in-Two-filter-two.yaml
@@ -9,5 +9,6 @@ kind: Two
 apiVersion: com.example.two/v1beta42
 metadata:
   name: filter-two
+  namespace: proxy-ns
 spec:
   filterTwoConfig: 42
\ No newline at end of file
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/out-Deployment-example.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/out-Deployment-example.yaml
index 963a5a7e..b17fb71d 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/out-Deployment-example.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/out-Deployment-example.yaml
@@ -16,6 +16,7 @@ metadata:
     app.kubernetes.io/instance: "example"
     app.kubernetes.io/component: "proxy"
   name: "example"
+  namespace: "proxy-ns"
   ownerReferences:
     - apiVersion: "kroxylicious.io/v1alpha1"
       kind: "KafkaProxy"
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/out-Secret-example.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/out-Secret-example.yaml
index 9f5100c6..c6726f49 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/out-Secret-example.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/out-Secret-example.yaml
@@ -15,6 +15,7 @@ metadata:
     app.kubernetes.io/instance: "example"
     app.kubernetes.io/component: "proxy"
   name: "example"
+  namespace: "proxy-ns"
   ownerReferences:
     - apiVersion: "kroxylicious.io/v1alpha1"
       kind: "KafkaProxy"
@@ -35,7 +36,7 @@ stringData:
           type: "PortPerBrokerClusterNetworkAddressConfigProvider"
           config:
             bootstrapAddress: "localhost:9392"
-            brokerAddressPattern: "bar"
+            brokerAddressPattern: "bar.proxy-ns.svc.cluster.local"
             brokerStartPort: 9393
             numberOfBrokerPorts: 3
     filters:
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/out-Service-bar.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/out-Service-bar.yaml
index cba93387..8562b159 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/out-Service-bar.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-api-not-declared/out-Service-bar.yaml
@@ -15,6 +15,7 @@ metadata:
     app.kubernetes.io/instance: "example"
     app.kubernetes.io/component: "proxy"
   name: "bar"
+  namespace: "proxy-ns"
   ownerReferences:
     - apiVersion: "kroxylicious.io/v1alpha1"
       kind: "KafkaProxy"
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/in-KafkaProxy.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/in-KafkaProxy.yaml
index 0156b54a..8750469c 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/in-KafkaProxy.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/in-KafkaProxy.yaml
@@ -9,6 +9,7 @@ kind: KafkaProxy
 apiVersion: kroxylicious.io/v1alpha1
 metadata:
   name: example
+  namespace: proxy-ns
 spec:
   clusters:
     - name: "foo"
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/in-One-filter-one.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/in-One-filter-one.yaml
index 1ec2e21c..6050e477 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/in-One-filter-one.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/in-One-filter-one.yaml
@@ -9,5 +9,6 @@ kind: One
 apiVersion: org.example.one/v1
 metadata:
   name: filter-one
+  namespace: proxy-ns
 spec:
   filterOneConfig: true
\ No newline at end of file
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/in-Two-filter-two.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/in-Two-filter-two.yaml
index a892aebb..3421009b 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/in-Two-filter-two.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/in-Two-filter-two.yaml
@@ -9,5 +9,6 @@ kind: Two
 apiVersion: com.example.two/v1beta42
 metadata:
   name: filter-two
+  namespace: proxy-ns
 spec:
   filterTwoConfig: 42
\ No newline at end of file
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/out-Deployment-example.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/out-Deployment-example.yaml
index 72e85af3..73cf5164 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/out-Deployment-example.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/out-Deployment-example.yaml
@@ -16,6 +16,7 @@ metadata:
     app.kubernetes.io/instance: "example"
     app.kubernetes.io/component: "proxy"
   name: "example"
+  namespace: "proxy-ns"
   ownerReferences:
     - apiVersion: "kroxylicious.io/v1alpha1"
       kind: "KafkaProxy"
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/out-Secret-example.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/out-Secret-example.yaml
index 3793f0a5..82db10de 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/out-Secret-example.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/out-Secret-example.yaml
@@ -15,6 +15,7 @@ metadata:
     app.kubernetes.io/instance: "example"
     app.kubernetes.io/component: "proxy"
   name: "example"
+  namespace: "proxy-ns"
   ownerReferences:
     - apiVersion: "kroxylicious.io/v1alpha1"
       kind: "KafkaProxy"
@@ -35,7 +36,7 @@ stringData:
           type: "PortPerBrokerClusterNetworkAddressConfigProvider"
           config:
             bootstrapAddress: "localhost:9392"
-            brokerAddressPattern: "bar"
+            brokerAddressPattern: "bar.proxy-ns.svc.cluster.local"
             brokerStartPort: 9393
             numberOfBrokerPorts: 3
     filters:
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/out-Service-bar.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/out-Service-bar.yaml
index cba93387..8562b159 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/out-Service-bar.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/filter-resource-not-found/out-Service-bar.yaml
@@ -15,6 +15,7 @@ metadata:
     app.kubernetes.io/instance: "example"
     app.kubernetes.io/component: "proxy"
   name: "bar"
+  namespace: "proxy-ns"
   ownerReferences:
     - apiVersion: "kroxylicious.io/v1alpha1"
       kind: "KafkaProxy"
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/minimal/in-KafkaProxy.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/minimal/in-KafkaProxy.yaml
index e77f1446..d1ec19c4 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/minimal/in-KafkaProxy.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/minimal/in-KafkaProxy.yaml
@@ -9,6 +9,7 @@ kind: KafkaProxy
 apiVersion: kroxylicious.io/v1alpha1
 metadata:
   name: minimal
+  namespace: proxy-ns
 spec:
   clusters:
   - name: "one"
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/minimal/out-Deployment-minimal.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/minimal/out-Deployment-minimal.yaml
index e1b15f5b..b0f3a639 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/minimal/out-Deployment-minimal.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/minimal/out-Deployment-minimal.yaml
@@ -16,6 +16,7 @@ metadata:
     app.kubernetes.io/instance: "minimal"
     app.kubernetes.io/component: "proxy"
   name: "minimal"
+  namespace: "proxy-ns"
   ownerReferences:
     - apiVersion: "kroxylicious.io/v1alpha1"
       kind: "KafkaProxy"
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/minimal/out-Secret-minimal.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/minimal/out-Secret-minimal.yaml
index 2888ffd6..7d8d56d8 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/minimal/out-Secret-minimal.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/minimal/out-Secret-minimal.yaml
@@ -15,6 +15,7 @@ metadata:
     app.kubernetes.io/instance: "minimal"
     app.kubernetes.io/component: "proxy"
   name: "minimal"
+  namespace: "proxy-ns"
   ownerReferences:
     - apiVersion: "kroxylicious.io/v1alpha1"
       kind: "KafkaProxy"
@@ -35,6 +36,6 @@ stringData:
           type: "PortPerBrokerClusterNetworkAddressConfigProvider"
           config:
             bootstrapAddress: "localhost:9292"
-            brokerAddressPattern: "one"
+            brokerAddressPattern: "one.proxy-ns.svc.cluster.local"
             brokerStartPort: 9293
             numberOfBrokerPorts: 3
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/minimal/out-Service-one.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/minimal/out-Service-one.yaml
index 112bab6e..7d56827f 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/minimal/out-Service-one.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/minimal/out-Service-one.yaml
@@ -15,6 +15,7 @@ metadata:
     app.kubernetes.io/instance: "minimal"
     app.kubernetes.io/component: "proxy"
   name: "one"
+  namespace: "proxy-ns"
   ownerReferences:
     - apiVersion: "kroxylicious.io/v1alpha1"
       kind: "KafkaProxy"
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/in-KafkaProxy.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/in-KafkaProxy.yaml
index 98f02d0e..d3648983 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/in-KafkaProxy.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/in-KafkaProxy.yaml
@@ -9,6 +9,7 @@ kind: KafkaProxy
 apiVersion: kroxylicious.io/v1alpha1
 metadata:
   name: twocluster
+  namespace: proxy-ns
 spec:
   clusters:
     - name: foo
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/out-Deployment-twocluster.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/out-Deployment-twocluster.yaml
index b04076b8..b756fb0a 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/out-Deployment-twocluster.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/out-Deployment-twocluster.yaml
@@ -16,6 +16,7 @@ metadata:
     app.kubernetes.io/instance: "twocluster"
     app.kubernetes.io/component: "proxy"
   name: "twocluster"
+  namespace: "proxy-ns"
   ownerReferences:
     - apiVersion: "kroxylicious.io/v1alpha1"
       kind: "KafkaProxy"
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/out-Secret-twocluster.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/out-Secret-twocluster.yaml
index eb38aafd..b940eeb3 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/out-Secret-twocluster.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/out-Secret-twocluster.yaml
@@ -15,6 +15,7 @@ metadata:
     app.kubernetes.io/instance: "twocluster"
     app.kubernetes.io/component: "proxy"
   name: "twocluster"
+  namespace: "proxy-ns"
   ownerReferences:
     - apiVersion: "kroxylicious.io/v1alpha1"
       kind: "KafkaProxy"
@@ -35,7 +36,7 @@ stringData:
           type: "PortPerBrokerClusterNetworkAddressConfigProvider"
           config:
             bootstrapAddress: "localhost:9292"
-            brokerAddressPattern: "foo"
+            brokerAddressPattern: "foo.proxy-ns.svc.cluster.local"
             brokerStartPort: 9293
             numberOfBrokerPorts: 3
       bar:
@@ -45,6 +46,6 @@ stringData:
           type: "PortPerBrokerClusterNetworkAddressConfigProvider"
           config:
             bootstrapAddress: "localhost:9392"
-            brokerAddressPattern: "bar"
+            brokerAddressPattern: "bar.proxy-ns.svc.cluster.local"
             brokerStartPort: 9393
             numberOfBrokerPorts: 3
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/out-Service-bar.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/out-Service-bar.yaml
index 3ab491b3..49d71261 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/out-Service-bar.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/out-Service-bar.yaml
@@ -15,6 +15,7 @@ metadata:
     app.kubernetes.io/instance: "twocluster"
     app.kubernetes.io/component: "proxy"
   name: "bar"
+  namespace: "proxy-ns"
   ownerReferences:
     - apiVersion: "kroxylicious.io/v1alpha1"
       kind: "KafkaProxy"
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/out-Service-foo.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/out-Service-foo.yaml
index e688b46a..f0c38184 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/out-Service-foo.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-clusters/out-Service-foo.yaml
@@ -15,6 +15,7 @@ metadata:
     app.kubernetes.io/instance: "twocluster"
     app.kubernetes.io/component: "proxy"
   name: "foo"
+  namespace: "proxy-ns"
   ownerReferences:
     - apiVersion: "kroxylicious.io/v1alpha1"
       kind: "KafkaProxy"
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/in-KafkaProxy.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/in-KafkaProxy.yaml
index 91e8af28..b6befb48 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/in-KafkaProxy.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/in-KafkaProxy.yaml
@@ -9,6 +9,7 @@ kind: KafkaProxy
 apiVersion: kroxylicious.io/v1alpha1
 metadata:
   name: example
+  namespace: proxy-ns
 spec:
   clusters:
   - name: "foo"
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/in-One-filter-one.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/in-One-filter-one.yaml
index 1ec2e21c..6050e477 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/in-One-filter-one.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/in-One-filter-one.yaml
@@ -9,5 +9,6 @@ kind: One
 apiVersion: org.example.one/v1
 metadata:
   name: filter-one
+  namespace: proxy-ns
 spec:
   filterOneConfig: true
\ No newline at end of file
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/in-Two-filter-two.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/in-Two-filter-two.yaml
index a892aebb..3421009b 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/in-Two-filter-two.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/in-Two-filter-two.yaml
@@ -9,5 +9,6 @@ kind: Two
 apiVersion: com.example.two/v1beta42
 metadata:
   name: filter-two
+  namespace: proxy-ns
 spec:
   filterTwoConfig: 42
\ No newline at end of file
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/out-Deployment-example.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/out-Deployment-example.yaml
index f8b0d5f4..2a6c3f87 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/out-Deployment-example.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/out-Deployment-example.yaml
@@ -16,6 +16,7 @@ metadata:
     app.kubernetes.io/instance: "example"
     app.kubernetes.io/component: "proxy"
   name: "example"
+  namespace: "proxy-ns"
   ownerReferences:
     - apiVersion: "kroxylicious.io/v1alpha1"
       kind: "KafkaProxy"
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/out-Secret-example.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/out-Secret-example.yaml
index 3e9299bb..15fd70e0 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/out-Secret-example.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/out-Secret-example.yaml
@@ -15,6 +15,7 @@ metadata:
     app.kubernetes.io/instance: "example"
     app.kubernetes.io/component: "proxy"
   name: "example"
+  namespace: "proxy-ns"
   ownerReferences:
     - apiVersion: "kroxylicious.io/v1alpha1"
       kind: "KafkaProxy"
@@ -35,7 +36,7 @@ stringData:
           type: "PortPerBrokerClusterNetworkAddressConfigProvider"
           config:
             bootstrapAddress: "localhost:9292"
-            brokerAddressPattern: "foo"
+            brokerAddressPattern: "foo.proxy-ns.svc.cluster.local"
             brokerStartPort: 9293
             numberOfBrokerPorts: 3
     filters:
diff --git a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/out-Service-foo.yaml b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/out-Service-foo.yaml
index 2bf45204..a33313fe 100644
--- a/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/out-Service-foo.yaml
+++ b/kroxylicious-operator/src/test/resources/DerivedResourcesTest/two-filters/out-Service-foo.yaml
@@ -15,6 +15,7 @@ metadata:
     app.kubernetes.io/instance: "example"
     app.kubernetes.io/component: "proxy"
   name: "foo"
+  namespace: "proxy-ns"
   ownerReferences:
     - apiVersion: "kroxylicious.io/v1alpha1"
       kind: "KafkaProxy"