Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
- **Namespaced Secret RBAC:** new operator flag `--secret-namespaces` and chart value
`rbac.secretNamespaces`. When set, the chart drops Secret access from the ClusterRole and grants it
through a Role + RoleBinding in each listed namespace only; the operator scopes its Secret watch to
those namespaces and refuses Secret references outside them. Empty (default) keeps cluster-wide
Secret access.
- **Import a part of a cluster:** `import cluster` takes repeatable `--topic <glob>` and
`--exclude-topic <glob>` flags (`path.Match` syntax, as in `spec.tenancy`). Only matching topics
are imported, together with the ACLs and MDS role bindings on them, their Schema Registry
Expand Down Expand Up @@ -37,6 +42,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
rejected, and an `import` round-trip. It runs in a new `cp-8.3-link` e2e matrix cell.

### Changed
- **BREAKING — Secrets must opt in (security):** the operator now only uses a referenced Secret
(KafkaCluster credentials and TLS material, KafkaTopic schema bodies, KafkaUser passwords) if it
is labelled `gitops.monedula.dev/credential-source=true`. Before, anyone who could create one of
these resources could make the operator read any Secret in the namespace and send it to an
endpoint they chose, even without RBAC to read that Secret themselves. Only someone who can write
a Secret can label it. **Upgrade:** label every Secret your resources reference
(`kubectl label secret <name> gitops.monedula.dev/credential-source=true`), or keep the old
behaviour with `--require-secret-label=false` (chart: `requireSecretLabel: false`). Unlabelled
references fail with an error naming the Secret and the label; a KafkaUser reports
`SecretNotLabeled`, and a KafkaCluster's `CredentialSourceUnwatched` condition lists them.
- Go 1.26.11 minimum (`go.mod`); all Go dependencies updated to their latest releases that support it.
- **Operator, `KafkaTopic` finalizer:** the `gitops.monedula.dev/force-finalizer-removal`
annotation now always orphans: the finalizer is removed with no topic, ACL or schema cleanup,
even when the cluster is reachable and `gitops.monedula.dev/allow-delete` is set.
Expand All @@ -53,8 +69,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **Mirror guard (CLI and operator):** for a live or stopping mirror topic, or one whose mirror
state is unknown, ACL prune (`DeleteAcl`) on the literal topic resource is now suppressed as
well as ACL creation. Prefixed and wildcard ACLs are unaffected.
- **Validated versions:** CI now also runs against Apache Kafka 4.4 (`apache/kafka:4.4.0`, new
`ak-4.4` cell). It takes over from 4.3 as the Apache cell paired with Confluent Schema Registry
and run in the end-to-end scenario suite; Apache Kafka 4.3 stays in the adapter integration
tests. The `compose.apache.yaml` overlays default to `apache/kafka:4.4.0`.

### Fixed
- **Security — tenancy:** an empty-string `spec.tenancy.topicPrefixes[].prefixes` entry is now
rejected by validation and ignored by enforcement; previously it matched every name and lifted the
namespace's prefix restriction. A namespace matched by a rule stays restricted even if no usable
prefix is left.
- **Security — Schema Registry subjects:** subjects a `KafkaTopic` manages (Custom and RecordName
strategies name them independently of the topic) are now checked against the namespace's
tenancy prefixes on reconcile and before finalizer deletion (`TenancyDenied`).
- **Security — finalizers:** the `KafkaTopic`, `KafkaAccessPolicy`, `KafkaQuota` and `KafkaUser`
finalizers only run destructive cleanup for a spec the operator applied (current generation
reconciled, not refused by validation or tenancy) and that the current tenancy policy still
allows. Otherwise they leave broker state in place and emit a `CleanupSkipped` event. This closes
edits to a terminating CR redirecting cleanup, and refused CRs deleting state they never managed.
- **Security — ACL conflicts:** a cross-resource Allow/Deny conflict on one ACL tuple now resolves
to the Deny, and every owner's `spec.prune` consent (including the conflict loser's) takes part
in the prune veto, so an Allow policy can no longer override or prune another resource's Deny.
- **Security — non-root manifests:** the quickstart and scenario Kafka / Schema Registry workloads
and the webhook patch run as non-root with a pinned UID, `RuntimeDefault` seccomp, no privilege
escalation and all capabilities dropped; the operator pins UID/GID 65532.
- **CLI, `KafkaMirrorTopic` apply:** a mirror create that Kafka REST rejects with a 4xx (for
example a missing source topic, 404) is reported as `rejected by Kafka REST (<status>)`
instead of "outcome unknown, re-run diff before retrying".
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ CI runs the adapter integration tests against every cell below on each pull requ
|---|---|---|---|---|
| `ak-3.9` | `apache/kafka:3.9.2` | `—` | integration | topics, acls, quotas, scram |
| `ak-4.0` | `apache/kafka:4.0.2` | `—` | integration | topics, acls, quotas, scram |
| `ak-4.3` | `apache/kafka:4.3.1` | `confluentinc/cp-schema-registry:8.3.1` | integration, e2e | topics, acls, quotas, scram, schemaregistry |
| `ak-4.3` | `apache/kafka:4.3.1` | `—` | integration | topics, acls, quotas, scram |
| `ak-4.4` | `apache/kafka:4.4.0` | `confluentinc/cp-schema-registry:8.3.1` | integration, e2e | topics, acls, quotas, scram, schemaregistry |
| `cp-7.6` | `confluentinc/cp-kafka:7.6.13` | `confluentinc/cp-schema-registry:7.6.13` | integration | topics, acls, quotas, scram, schemaregistry |
| `cp-7.9` | `confluentinc/cp-kafka:7.9.9` | `confluentinc/cp-schema-registry:7.9.9` | integration, e2e | topics, acls, quotas, scram, schemaregistry |
| `cp-8.0` | `confluentinc/cp-kafka:8.0.7` | `confluentinc/cp-schema-registry:8.0.7` | integration | topics, acls, quotas, scram, schemaregistry |
Expand Down
2 changes: 2 additions & 0 deletions charts/monedula-gitops/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ rules:
- get
- list
- watch
{{- if not .Values.rbac.secretNamespaces }}
- apiGroups:
- ""
resources:
Expand All @@ -25,6 +26,7 @@ rules:
- list
- update
- watch
{{- end }}
- apiGroups:
- authentication.k8s.io
resources:
Expand Down
6 changes: 6 additions & 0 deletions charts/monedula-gitops/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ spec:
{{- with .Values.clusterNamespace }}
- --cluster-namespace={{ . }}
{{- end }}
{{- with .Values.rbac.secretNamespaces }}
- --secret-namespaces={{ join "," . }}
{{- end }}
{{- if not .Values.requireSecretLabel }}
- --require-secret-label=false
{{- end }}
{{- with .Values.resyncInterval }}
- --resync-interval={{ . }}
{{- end }}
Expand Down
42 changes: 42 additions & 0 deletions charts/monedula-gitops/templates/secret-roles.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- /* Namespaced Secret access (rbac.secretNamespaces): replaces the ClusterRole's
cluster-wide Secret rule with a Role + RoleBinding per listed namespace. Verbs
mirror the ClusterRole's Secret rule (config/rbac/role.yaml). */ -}}
{{- if .Values.rbac.create }}
{{- range .Values.rbac.secretNamespaces }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "monedula-gitops.fullname" $ }}-secrets
namespace: {{ . }}
labels:
{{- include "monedula-gitops.labels" $ | nindent 4 }}
rules:
- apiGroups:
- ""
resources:
- secrets
verbs:
- create
- get
- list
- update
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "monedula-gitops.fullname" $ }}-secrets
namespace: {{ . }}
labels:
{{- include "monedula-gitops.labels" $ | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ include "monedula-gitops.fullname" $ }}-secrets
subjects:
- kind: ServiceAccount
name: {{ include "monedula-gitops.serviceAccountName" $ }}
namespace: {{ $.Release.Namespace }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/monedula-gitops/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ serviceAccount:

rbac:
create: true
# Namespaces the operator may read, write and watch Secrets in (--secret-namespaces).
# Empty (default): Secret access is granted cluster-wide in the ClusterRole. Non-empty: the
# ClusterRole carries NO Secret rule; a Role + RoleBinding is rendered in each listed namespace
# instead, and the operator refuses Secret references outside them. List every namespace whose
# KafkaCluster / KafkaTopic / KafkaUser resources reference Secrets (with clusterNamespace set,
# that is the cluster namespace plus the namespaces of topics and users that reference Secrets).
secretNamespaces: []

# Use only Secrets labelled gitops.monedula.dev/credential-source=true (--require-secret-label).
# Keep this on: without it, anyone who can create a KafkaCluster, KafkaTopic or KafkaUser can make
# the operator read any Secret in that namespace and send it to an endpoint they choose.
requireSecretLabel: true

crds:
enabled: true # render CRDs into templates/
Expand Down Expand Up @@ -67,6 +79,9 @@ podAnnotations: {}
podLabels: {}
podSecurityContext:
runAsNonRoot: true
# distroless "nonroot" user; pinned so the kubelet can verify non-root.
runAsUser: 65532
runAsGroup: 65532
seccompProfile:
type: RuntimeDefault
securityContext:
Expand Down
13 changes: 13 additions & 0 deletions config/components/webhook/manager_webhook_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,21 @@ metadata:
spec:
template:
spec:
# Restated from config/manager so this patch is non-root on its own too.
securityContext:
runAsNonRoot: true
runAsUser: 65532
runAsGroup: 65532
seccompProfile:
type: RuntimeDefault
containers:
- name: manager
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
args:
- operator
- --metrics-bind-address=:8080
Expand Down
3 changes: 3 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ spec:
serviceAccountName: monedula-manager
securityContext:
runAsNonRoot: true
# distroless "nonroot" user; pinned so the kubelet can verify non-root.
runAsUser: 65532
runAsGroup: 65532
seccompProfile:
type: RuntimeDefault
containers:
Expand Down
Loading
Loading