Add global.networkPolicy.flavor with cilium support#2289
Open
tamalsaha wants to merge 1 commit into
Open
Conversation
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>
5 tasks
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.
Summary
global.networkPolicy.flavor(defaultkubernetes) that selects betweennetworking.k8s.io/v1.NetworkPolicy(current behavior) andcilium.io/v2.CiliumNetworkPolicyresources.flavor=ciliumandnetworkPolicy.enabled=true, the existing per-chartNetworkPolicytemplates are skipped (via a newsecurity.useKubernetesNetworkPolicyhelper) and newcilium-network-policy.yamltemplates emit the policies a Cilium-managed default-deny environment needs:remote-node/hoston6443(kube-apiserver) from the operator namespace.8443/9443fromremote-node/host.kubedb-provisionerStatefulSet 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 CiliumNetworkPolicyhelm template kubedb-provisioner ./charts/kubedb-provisioner --set global.networkPolicy.enabled=true --set global.networkPolicy.flavor=cilium— operator gets--network-policy-flavor=cilium.tgzfiles incharts/kubedb/charts/so the umbrella render also picks up the new flavor wiring forkubedb-webhook-server(and sister charts).Companion PRs:
EnsureNetworkPolicyWithFlavorandcontroller.Config.NetworkPolicyFlavor--network-policy-flavorflag and calls the flavor-aware variantNot in this PR
petsetandsidekickcharts ship as packaged.tgzand emit their own broadNetworkPolicy— those need separate upstream PRs to the source repos.🤖 Generated with Claude Code