Skip to content

Add global.networkPolicy.flavor with cilium support#2289

Open
tamalsaha wants to merge 1 commit into
masterfrom
cilium-network-policy
Open

Add global.networkPolicy.flavor with cilium support#2289
tamalsaha wants to merge 1 commit into
masterfrom
cilium-network-policy

Conversation

@tamalsaha
Copy link
Copy Markdown
Member

Summary

  • Adds a new helm value global.networkPolicy.flavor (default kubernetes) that selects between networking.k8s.io/v1.NetworkPolicy (current behavior) and cilium.io/v2.CiliumNetworkPolicy resources.
  • When flavor=cilium and networkPolicy.enabled=true, the existing per-chart NetworkPolicy templates are skipped (via a new security.useKubernetesNetworkPolicy helper) and new cilium-network-policy.yaml templates emit the policies a Cilium-managed default-deny environment needs:
    • Egress to remote-node/host on 6443 (kube-apiserver) from the operator namespace.
    • Egress from the operator to DB endpoints on common DB ports.
    • Ingress to the webhook server on 8443/9443 from remote-node/host.
  • kubedb-provisioner StatefulSet passes --network-policy-flavor=<flavor> to the operator so the per-DB-namespace policies are emitted in the same flavor.

Driven by a customer running KubeDB on a Cilium cluster with default-deny: the broad NetworkPolicy emitted today is too coarse for their egress rules.

Test plan

  • helm template kubedb ./charts/kubedb — no policies (disabled, current default)
  • helm template kubedb ./charts/kubedb --set global.networkPolicy.enabled=true — 5 NetworkPolicy (current behavior preserved)
  • helm template ks ./charts/kubedb-webhook-server --set networkPolicy.enabled=true --set networkPolicy.flavor=cilium — emits CiliumNetworkPolicy
  • helm template kubedb-provisioner ./charts/kubedb-provisioner --set global.networkPolicy.enabled=true --set global.networkPolicy.flavor=cilium — operator gets --network-policy-flavor=cilium
  • Re-package the bundled subchart .tgz files in charts/kubedb/charts/ so the umbrella render also picks up the new flavor wiring for kubedb-webhook-server (and sister charts).
  • Apply on a Cilium-enabled cluster, verify with Hubble that expected flows are allowed and previously over-allowed flows are tightened.

Companion PRs:

Not in this PR

  • petset and sidekick charts ship as packaged .tgz and emit their own broad NetworkPolicy — those need separate upstream PRs to the source repos.

🤖 Generated with Claude Code

Introduces a new helm value global.networkPolicy.flavor (default
"kubernetes") that selects between networking.k8s.io/v1.NetworkPolicy
(current behavior) and cilium.io/v2.CiliumNetworkPolicy resources.

When flavor=cilium and networkPolicy.enabled=true:
  - The existing per-chart NetworkPolicy templates are skipped via a
    new security.useKubernetesNetworkPolicy helper.
  - New cilium-network-policy.yaml templates emit the policies a
    Cilium-managed default-deny environment needs: egress to
    remote-node/host on 6443 (kube-apiserver), egress from the
    operator to DB endpoints on the common DB ports, and ingress to
    the webhook server on 8443/9443 from remote-node/host.

The kubedb-provisioner StatefulSet now passes
--network-policy-flavor=<flavor> to the operator so the operator-side
EnsureNetworkPolicyWithFlavor call uses the same setting.

Driven by a customer running KubeDB on a Cilium cluster with default
deny: the broad NetworkPolicy emitted today is too coarse for their
egress rules.

Signed-off-by: Tamal Saha <tamal@appscode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant