operator: Cross-namespace Console clusterRef support#1448
operator: Cross-namespace Console clusterRef support#1448
Conversation
Adds an optional `namespace` field to ClusterRef, enabling Console
resources to reference a Redpanda cluster in a different namespace.
This is gated to global scope mode only: when the operator runs with
--namespace (single-namespace mode), cross-namespace references are
rejected at reconcile time with a clear error message.
Changes:
- Add Namespace field to ClusterRef with GetNamespace()/IsCrossNamespace() helpers
- Console controller: use ClusterRef namespace for cluster lookup
- Client factory: use ClusterRef namespace in getV2Cluster()
- Index functions: use ClusterRef namespace for cross-namespace indexing
- Console controller: validate cross-namespace refs rejected in namespaced mode
- Regenerate CRDs with namespace field on all ClusterRef-using resources
Example:
apiVersion: cluster.redpanda.com/v1alpha2
kind: Console
metadata:
name: console
namespace: monitoring
spec:
cluster:
clusterRef:
name: redpanda
namespace: redpanda-cluster # cross-namespace reference
Closes #1198
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The gci formatter expects github.com/redpanda-data/common-go imports in the third-party group, not the internal group. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…test staticcheck flagged vectorizedv1alpha1.AddToScheme as deprecated. Switch to Install to match the v2 scheme registration on the line above and to silence SA1019 in CI. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
This PR is stale because it has been open 5 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
|
This PR is stale because it has been open 5 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
E2E test on GKE — passes; safe to use for blue/greenBuilt the operator from the PR head (commit Setup
ResultsBoth Console pods reached The seed broker DNS contains Question 1: Two Console deployments in different namespaces, same cluster — issues?No issues observed. The PR only changes the lookup namespace for the
Question 2: Useful for blue/green Console upgrades?Yes — this is essentially the migration flow already documented in the PR description, and the same pattern works for version-to-version upgrades. Demonstrated by scaling
Two preconditions worth documenting:
Negative pathI did not re-test the namespaced-mode rejection path on GKE — the unit test CleanupTest namespaces, operator install, CRDs, the GAR repo for the test image, and the GKE cluster have all been torn down. |
Summary
Adds an optional
namespacefield toClusterRef, enabling Console resources to reference a Redpanda cluster in a different namespace. This is gated to global scope mode only (operator running without--namespace).Closes #1198
Step-by-Step Usage
Prerequisites
The operator must be running in global scope mode (the default). If you installed with
--set scope.namespace=""or simply omitted the scope flag, you are in global mode. Cross-namespace references are rejected when the operator runs with--namespace.Step 1: Deploy a Redpanda cluster in its own namespace
Or via the operator:
Step 2: Create a Console namespace
Step 3: Deploy Console with a cross-namespace clusterRef
Apply it:
The operator resolves the Redpanda resource from the
redpanda-clusternamespace, extracts connection parameters (broker addresses, admin API endpoints, TLS configuration), and deploys Console in theconsolenamespace with those settings.Step 4: (If using NetworkPolicies) Allow cross-namespace traffic
If your cluster enforces NetworkPolicies, Console pods need ingress to the Redpanda namespace:
Step 5: Verify Console is connected
Console should show successful connections to the Redpanda brokers in the
redpanda-clusternamespace.Using StaticConfiguration instead (alternative)
If you prefer explicit connection strings over clusterRef, you can use
staticConfigurationwhich already supports cross-namespace connections without any operator changes:The
clusterRef.namespaceapproach is simpler because the operator automatically resolves all connection details from the Redpanda resource.Design
How it works
ClusterRefgains an optionalnamespacefieldnamespaceis set, the Console controller looks up the Redpanda resource in that namespace instead of the Console's own namespace--namespace=X), cross-namespace references are rejected at reconcile time with a clear errorScope gating
--namespace)namespace: other-ns--namespace=my-ns)namespace: other-nsnamespacefieldMigrating Console from Same Namespace to Separate Namespace
For users who currently run Console and Redpanda in the same namespace and want to separate them. Console is stateless, so this is a zero-downtime migration using parallel deployments.
Starting state
Step 1: Verify operator is in global scope mode
If the operator is running with
--namespace, you must first reconfigure it for global scope:helm upgrade redpanda-operator redpanda/operator --set scope.namespace=""Step 2: Create the target namespace
Step 3: Copy any required Secrets to the new namespace
If Console uses TLS or SASL authentication, copy the relevant Secrets:
Alternatively, use a Secret mirroring solution (e.g., Reflector, ExternalSecrets) to keep them in sync.
Step 4: Deploy Console in the new namespace with cross-namespace clusterRef
Export your existing Console configuration as a starting point:
kubectl get console console -n redpanda -o yaml > console-new.yamlEdit
console-new.yaml:Apply it:
Step 5: Verify the new Console is working
At this point, both Console instances are running — old in
redpanda, new inconsole.Step 6: Update DNS, Ingress, or port-forwards to the new namespace
If you have an Ingress or Service pointing to Console:
Step 7: Delete the old Console
Once traffic is fully migrated:
Final state
Security Considerations
Cross-namespace Console deployment introduces several security implications that operators should evaluate:
1. RBAC and Secret access
When Console references a cluster in another namespace, the operator's ServiceAccount needs read access to Secrets in the target namespace (for TLS certificates, SASL credentials, etc.). In global scope mode, the operator already has cluster-wide permissions, so this is not a new escalation. However, operators should audit:
secretsaccess across all namespaces in global mode2. Credential exposure across namespace boundaries
The operator reads connection details (Kafka brokers, admin API endpoints, TLS config) from the Redpanda resource in the target namespace and injects them into Console's ConfigMap/Deployment in the Console namespace. This means:
ReferenceGrantor mirrored Secret may be needed depending on your network policy setup3. Network policy implications
Console pods in namespace A need network access to Redpanda pods in namespace B. If you use NetworkPolicies to isolate namespaces, you must explicitly allow cross-namespace ingress as shown in Step 4 above.
4. Blast radius
If the Console namespace is compromised, an attacker gains:
This is the same blast radius as running Console in the same namespace, except the compromise of the Console namespace no longer automatically compromises other workloads co-located with Redpanda.
5. Recommendation
Cross-namespace deployment is appropriate when:
It is NOT recommended when:
Files changed
operator/api/redpanda/v1alpha2/common.goNamespacetoClusterRef,GetNamespace(),IsCrossNamespace()helpersoperator/internal/controller/console/controller.gooperator/pkg/client/factory.gogetV2Cluster()operator/internal/controller/index.gooperator/config/crd/bases/*.yaml.changes/unreleased/operator-Added-*.yamlTest plan
go build ./operator/...🤖 Generated with Claude Code