Repository navigation
fix(chart): the kates NetworkPolicy lets the API reach the Kubernetes API, Trogdor, and Kafka in networkPolicy.kafka.namespace - #384
Merged
Conversation
… API, Trogdor, and Kafka in networkPolicy.kafka.namespace On a CNI that enforces NetworkPolicy, the default kates policy cut the API off from three things it needs. It had no egress to the Kubernetes API, so every fabric8 call (chaos faults, disruption plans, pod listing, KafkaTopic CRs, the orphan reconciler) failed after its retry backoff. Its Kafka rule named the namespace `kafka` literally and never read networkPolicy.kafka.namespace, so `kates deploy --topology single -n kates-stack`, which runs Kafka in kates-stack, left Kates with no Kafka at all while the pod still went Ready on its cached Kafka check. And Trogdor's 8889 was allowed only to `monitoring`, where nothing listens on it, while the default coordinator URL is trogdor-coordinator.kafka.svc:8889. The policy now opens TCP 443 and 6443 to any address (the ports-only shape kafka-common uses; 6443 is the API server's port after the Service DNAT), takes the Kafka namespace from networkPolicy.kafka.namespace, and opens 8889 next to the brokers in that namespace. The `monitoring` 8889 rule is gone. `kates deploy` sets networkPolicy.kafka.namespace to the namespace it installs Kafka in, and the two topology tests assert it. The helm-lint job renders the policy with the value set and checks the egress follows it. The kates chart moves to 0.11.1, with README.md and the book's version matrix to match. The chart README's upgrade note and a new artifacthub.io/changes entry say what changes for a release that set the value elsewhere, and that a coordinator outside the Kafka namespace still needs an egressRules entry. The stretched-kafka lab no longer says the policy blocks the API server.
…gress # Conflicts: # .github/workflows/ci.yml # README.md # charts/kates/Chart.yaml # docs/book/appendix-d-versions.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Plan PR 14 of the audit fix plan (finding 10). Lands after #372 and #375; see Landing.
Why
On a CNI that enforces NetworkPolicy (Calico, Cilium or GKE Dataplane V2, EKS network policy), the kates chart's default policy cuts the Kates API off from three things it needs. Checked in
charts/kates/templates/networkpolicy.yamlon main:monitoring, and nothing on 443 or 6443. Every fabric8 call fails after its retry backoff: every chaos fault, disruption plan, pod listing and KafkaTopic CR, and the orphan reconciler. kates-chaos's own policy has this rule; the kates chart never did.kafka. The Kafka rule nameskubernetes.io/metadata.name: kafkaliterally and never readsnetworkPolicy.kafka.namespace, although NOTES.txt prints that value as the Kafka egress target. Withkates deploy --topology single -n kates-stack, Kafka runs in kates-stack, and Kates cannot reach it at all. The pod still goes Ready, because readiness reads a cached Kafka check, so the deploy looks healthy.monitoring. The defaulttrogdor.coordinatorUrlishttp://trogdor-coordinator.kafka.svc:8889(values.yaml:388), and nothing in the repo listens on 8889 inmonitoring. fix(kates): resolve strict network policy blocks and static init crash #35 (8eab57e) added that rule as Trogdor egress to any namespace, and feat(networkpolicy): harden all NetworkPolicies for default-deny clusters #42 (cf00a9f) narrowed it tomonitoringby mistake. This part matters only for runs on the trogdor backend;engine.defaultBackendis native.docs/stretched-kafka/04-test-and-chaos-scenarios.mddocumented the API-server gap and told the lab to disable the policy. That does not cover the chart default orkates deployon a generic cluster, and after this PR the text is wrong.Changes
charts/kates/templates/networkpolicy.yamlkafka-common.netpol.apiServerEgress, written inline because the kates chart does not depend on kafka-common.{{ .Values.networkPolicy.kafka.namespace | default "kafka" | quote }}, and it opens 8889 next to the broker port, for the Trogdor coordinator where the default URL puts it. Ashortcut:comment says a coordinator in another namespace needs anetworkPolicy.egressRulesentry.monitoring8889 rule is deleted.charts/kates/values.yaml: the# -- Kafka egress configurationcomment is reworded in place to say the rule covers the brokers onportand Trogdor on 8889, and thatkates deploysets the namespace. No key and no line is added, sovalues.schema.jsonis unchanged and no caveat ref into values.yaml moves.cli/cmd/deploy_components.go: the kates helm call setsnetworkPolicy.kafka.namespace=<kafkaNS>next tokafka.topicNamespace.kafkaNSis the namespacekates deployinstalls Kafka in, so--topology singlegets the shared namespace and the isolated topology gets the Kafka one.Chart version and docs
charts/kates/Chart.yaml: 0.11.1, with the patch comment rewritten and akind: fixedartifacthub.io/changes entry that says what changes on upgrade. appVersion stays 1.25.1.README.mdchart table anddocs/book/appendix-d-versions.md: 0.11.1.charts/kates/README.md: thenetworkPolicy.kafka.namespacerow says the namespace is where the brokers and the Trogdor coordinator run, and thatkates deploysets it. A new "Upgrading from chart 0.11.0 or earlier" note says the value now takes effect, so a release that set it to anything but where Kafka runs loses Kafka, and that a coordinator outside that namespace (kates/docs/deployment.mdruns one inkates) needs anegressRulesentry.docs/stretched-kafka/04-test-and-chaos-scenarios.md: the lab values comment and the paragraph below no longer say the policy blocks the API server. The lab still runs with the policy off, and the text says turning it on there is untested..github/workflows/ci.yml: a helm-lint step, afterTemplate validation, renders the policy withnetworkPolicy.kafka.namespace=kates-stackand checks the namespace is"kates-stack", no egress nameskafka, 6443 is there, and 8889 is open once, to the Kafka namespace. Nothing rendered and checked the value before, which is how it went unread.Tests
Added:
TestDeployCommand_SingleTopology: the kates helm call carries--set networkPolicy.kafka.namespace=kates-test, the namespace Kafka and Kates share.TestDeployCommand_IsolatedTopology: the kates helm call carries--set networkPolicy.kafka.namespace=kafka-syswhile Kates installs in app-sys.The backend is unchanged: this PR touches nothing under
kates/. The full backend suite (./mvnw verify) ran on main and passed, and gives the same result here.Run locally, passing:
git diff --name-only origin/main...HEAD: 1 commit on a128f85. The paths trigger ci.yml (helm-lint, kyverno, yaml-validation, go-tests, dependency-scan, build-and-test), lint.yml (actionlint, yamllint, golangci-lint), docs.yml (chart table, version matrix, book style, contrast, mermaid, lychee), book.yml and the ci-kafka-charts dashboards job.cd cli && go test ./...: every package ok,cli/cmdin 33 s. This covers the two new assertions andTestMCPCaveatRefAnchors.go vet ./...: no findings.golangci-lint run --new-from-rev=origin/main ./...: 0 issues.govulncheck ./...: no vulnerabilities.scripts/check-cli-style.shandscripts/check-cli-compat.sh: OK.helm lint charts/kates/: 1 chart linted, 0 failed.helm template kates charts/kates/with the defaults and with values-dev, -generic, -kind, -local, -native-local, -native and -staging: each renders. values-prod and values-corporate render onceexternalDatabase.existingSecretis set; values-corporate needs it too, like prod.kafka, 6443 present, and 8889 only in kates-stack.scripts/check-versions.sh: every pin agrees.scripts/check-chart-test-paths.sh: both chart-test/apipaths resolve.helm templatewithkyvernoPolicy.enabledpiped tokyverno apply --resource kates/k8s/deployment.yaml: 0 fail, 0 error.yamllint -c .yamllint.yaml .github config charts(the lint.yml scope): no errors.actionlint: clean, shellcheck over the new run block included.scripts/gen-chart-table.sh --check(README table at 0.11.1) andscripts/gen-version-matrix.sh --check(appendix-d matches the pins).scripts/check-book-style.sh: OK, ratchet within baseline.check-book-contrast.py: all 170 colour pairs meet WCAG AA.check-mermaid.sh: 156 diagrams, 0 invalid.prepare-book-render.sh,quarto render --to html): 38 pages, andcheck-book-fragments.pyfinds all 7,458 fragment links landing on an id.scripts/check-dashboards.py: 12 dashboards pass.Skipped locally:
gen-dashboards.py --check: PyYAML is not installed. The PR touches no dashboard or chart dashboard copy.lychee --offline --include-fragments: lychee is not installed. The docs diff adds or changes no link, only version cells and prose.config/**):config/is unchanged and PyYAML is missing.make check-help: no shell script or Makefile changed.CI only:
kates ./mvnw verify, surefire and the*ITfailsafe tests (Build & Test, triggered bycli/**and ci.yml)kates/)gen-dashboards.py --check, promtool PromQL checks, Grafana render and install bundle checkskates/**path changescharts/katesDecisions
networkPolicy.apiServer.ipBlockvalue. A new value would add values.yaml and schema lines and move the caveat ref atmcp_tools_scenario.go, which anchors values.yaml:605-673.trogdor.coordinatorUrlputs the coordinator, and themonitoring8889 rule deleted. Deriving the namespace from the URL, or a newnetworkPolicy.trogdor.namespacekey, was left out..github, which brings in actionlint.networkPolicy.enabled: false; turning it on there is untested.networkPolicy.kafka.namespaceas the Kafka egress target is true once the template reads the value."kafka"by default), because of| quote. The CI assertion's check for a leftoverkafkamatches both the quoted and the bare form.kates.networkPolicy.kafka.namespace, so installed in kates-stack, its kates policy still sends Kafka egress to"kafka". It was broken before this PR too (the literalkafka). Fixing it means setting that value at install time, because Helm values cannot read.Release.Namespace.Deliberately not done
values-kind.yamlturns the policy off, so the Kind smoke test in CI does not exercise it either; only the static render assertion guards the template.jaeger-collector.monitoring.svc:4317is still outside the egress list. A follow-up.apiServer.ipBlockvalue left out above.kates/docs/deployment.mdlays it out, is still blocked without anegressRulesentry. The chart README says so.docs/mirror-maker2-cli-migration-plan.mdcites.github/workflows/ci.yml:359forgo test -p 1, which was already at :418 on main and is at :438 after this PR.Landing
Lands after #372 (plan PR 3) and #375 (plan PR 6), which edit files this PR also edits:
.github/workflows/ci.yml,README.md,charts/kates/Chart.yaml,charts/kates/README.md,charts/kates/values.yaml,docs/book/appendix-d-versions.md. The ci.yml step (both add one afterTemplate validation), the Chart.yaml version, comment and changes entries, README.md:216 and appendix-d:25 conflict mechanically: keep both ci.yml steps and both changes entries, and take 0.11.1. The charts/kates/README.md and values.yaml hunks are in different sections.docs/stretched-kafka/04-test-and-chaos-scenarios.md, in a different hunk (:594 against :489 and :515).Rebase recipe: rebase onto main once both have merged, resolve as above, then re-point any caveat ref the merged changes moved from a diff line map (this PR moves none of its own: the values.yaml edit keeps its line count), and rerun
cd cli && go test ./cmd -run TestMCPCaveatalong withgen-chart-table.sh --check,gen-version-matrix.sh --checkand the ci.yml assertion.