feat(security): enable chart-native network policies where charts support them - #4083
Merged
Conversation
…port them kube-state-metrics (flavor cilium: apiserver-only egress, metrics-port ingress on a pod with cluster-wide list/watch rbac) and cert-manager's three components; the only charts in the repo with a native knob
@@ spec.values @@
# helm.toolkit.fluxcd.io/v2/HelmRelease/cert-manager/cert-manager
! + two map entries added:
+ cainjector:
+ networkPolicy:
+ enabled: true
+ networkPolicy:
+ enabled: true
@@ spec.values.webhook @@
# helm.toolkit.fluxcd.io/v2/HelmRelease/cert-manager/cert-manager
! + one map entry added:
+ networkPolicy:
+ enabled: true
@@ spec.values @@
# helm.toolkit.fluxcd.io/v2/HelmRelease/observability/kube-state-metrics
! + one map entry added:
+ networkPolicy:
+ enabled: true
+ flavor: cilium
|
@@ (root level) @@
# networking.k8s.io/v1/NetworkPolicy/cert-manager/cert-manager-cainjector-allow-ingress
! + one document added:
+ apiVersion: networking.k8s.io/v1
+ kind: NetworkPolicy
+ metadata:
+ name: cert-manager-cainjector-allow-ingress
+ namespace: cert-manager
+ labels:
+ helm.toolkit.fluxcd.io/name: cert-manager
+ helm.toolkit.fluxcd.io/namespace: cert-manager
+ spec:
+ ingress:
+ - ports:
+ - port: http-metrics
+ protocol: TCP
+ podSelector:
+ matchLabels:
+ app.kubernetes.io/component: cainjector
+ app.kubernetes.io/instance: cert-manager
+ app.kubernetes.io/name: cainjector
+ policyTypes:
+ - Ingress
@@ (root level) @@
# networking.k8s.io/v1/NetworkPolicy/cert-manager/cert-manager-cainjector-allow-egress
! + one document added:
+ apiVersion: networking.k8s.io/v1
+ kind: NetworkPolicy
+ metadata:
+ name: cert-manager-cainjector-allow-egress
+ namespace: cert-manager
+ labels:
+ helm.toolkit.fluxcd.io/name: cert-manager
+ helm.toolkit.fluxcd.io/namespace: cert-manager
+ spec:
+ egress:
+ - ports:
+ - port: 80
+ protocol: TCP
+ - port: 443
+ protocol: TCP
+ - port: 53
+ protocol: TCP
+ - port: 53
+ protocol: UDP
+ - port: 6443
+ protocol: TCP
+ podSelector:
+ matchLabels:
+ app.kubernetes.io/component: cainjector
+ app.kubernetes.io/instance: cert-manager
+ app.kubernetes.io/name: cainjector
+ policyTypes:
+ - Egress
@@ (root level) @@
# networking.k8s.io/v1/NetworkPolicy/cert-manager/cert-manager-allow-ingress
! + one document added:
+ apiVersion: networking.k8s.io/v1
+ kind: NetworkPolicy
+ metadata:
+ name: cert-manager-allow-ingress
+ namespace: cert-manager
+ labels:
+ helm.toolkit.fluxcd.io/name: cert-manager
+ helm.toolkit.fluxcd.io/namespace: cert-manager
+ spec:
+ ingress:
+ - ports:
+ - port: http-metrics
+ protocol: TCP
+ - port: http-healthz
+ protocol: TCP
+ podSelector:
+ matchLabels:
+ app.kubernetes.io/component: controller
+ app.kubernetes.io/instance: cert-manager
+ app.kubernetes.io/name: cert-manager
+ policyTypes:
+ - Ingress
@@ (root level) @@
# networking.k8s.io/v1/NetworkPolicy/cert-manager/cert-manager-allow-egress
! + one document added:
+ apiVersion: networking.k8s.io/v1
+ kind: NetworkPolicy
+ metadata:
+ name: cert-manager-allow-egress
+ namespace: cert-manager
+ labels:
+ helm.toolkit.fluxcd.io/name: cert-manager
+ helm.toolkit.fluxcd.io/namespace: cert-manager
+ spec:
+ egress:
+ - ports:
+ - port: 80
+ protocol: TCP
+ - port: 443
+ protocol: TCP
+ - port: 53
+ protocol: TCP
+ - port: 53
+ protocol: UDP
+ - port: 6443
+ protocol: TCP
+ podSelector:
+ matchLabels:
+ app.kubernetes.io/component: controller
+ app.kubernetes.io/instance: cert-manager
+ app.kubernetes.io/name: cert-manager
+ policyTypes:
+ - Egress
@@ (root level) @@
# networking.k8s.io/v1/NetworkPolicy/cert-manager/cert-manager-webhook-allow-ingress
! + one document added:
+ apiVersion: networking.k8s.io/v1
+ kind: NetworkPolicy
+ metadata:
+ name: cert-manager-webhook-allow-ingress
+ namespace: cert-manager
+ labels:
+ helm.toolkit.fluxcd.io/name: cert-manager
+ helm.toolkit.fluxcd.io/namespace: cert-manager
+ spec:
+ ingress:
+ - ports:
+ - port: https
+ protocol: TCP
+ - port: healthcheck
+ protocol: TCP
+ - port: http-metrics
+ protocol: TCP
+ podSelector:
+ matchLabels:
+ app.kubernetes.io/component: webhook
+ app.kubernetes.io/instance: cert-manager
+ app.kubernetes.io/name: webhook
+ policyTypes:
+ - Ingress
@@ (root level) @@
# networking.k8s.io/v1/NetworkPolicy/cert-manager/cert-manager-webhook-allow-egress
! + one document added:
+ apiVersion: networking.k8s.io/v1
+ kind: NetworkPolicy
+ metadata:
+ name: cert-manager-webhook-allow-egress
+ namespace: cert-manager
+ labels:
+ helm.toolkit.fluxcd.io/name: cert-manager
+ helm.toolkit.fluxcd.io/namespace: cert-manager
+ spec:
+ egress:
+ - ports:
+ - port: 80
+ protocol: TCP
+ - port: 443
+ protocol: TCP
+ - port: 53
+ protocol: TCP
+ - port: 53
+ protocol: UDP
+ - port: 6443
+ protocol: TCP
+ podSelector:
+ matchLabels:
+ app.kubernetes.io/component: webhook
+ app.kubernetes.io/instance: cert-manager
+ app.kubernetes.io/name: webhook
+ policyTypes:
+ - Egress
@@ (root level) @@
# cilium.io/v2/CiliumNetworkPolicy/observability/kube-state-metrics
! + one document added:
+ apiVersion: cilium.io/v2
+ kind: CiliumNetworkPolicy
+ metadata:
+ name: kube-state-metrics
+ namespace: observability
+ labels:
+ app.kubernetes.io/component: metrics
+ app.kubernetes.io/instance: kube-state-metrics
+ app.kubernetes.io/managed-by: Helm
+ app.kubernetes.io/name: kube-state-metrics
+ app.kubernetes.io/part-of: kube-state-metrics
+ helm.toolkit.fluxcd.io/name: kube-state-metrics
+ helm.toolkit.fluxcd.io/namespace: observability
+ spec:
+ egress:
+ - toEntities:
+ - kube-apiserver
+ endpointSelector:
+ matchLabels:
+ app.kubernetes.io/instance: kube-state-metrics
+ app.kubernetes.io/name: kube-state-metrics
+ ingress:
+ - toPorts:
+ - ports:
+ - port: "8080"
+ protocol: TCP
|
AI Automated ReviewAnalysis engine: qwen-3.6-fast@http://litellm.ai.svc.cluster.local/v1 (openai) Recommendation: Approve This PR enables native network policies for Required Checks
Change-by-Change Findings
Standards Compliance
Unknowns or Needs Verification
|
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.
Follow-up to #4072 answering "can we enable network policies natively in charts?" — surveyed every pinned chart in the repo. Only two have a native knob, both enabled here; both verified rendering via
helm templateagainst the pinned versions:networkPolicy.enabled + flavor: cilium→ a real CiliumNetworkPolicy locking a pod that holds cluster-wide list/watch RBAC to kube-apiserver egress and metrics-port ingress only.networkPolicy.enabled→ upstream-scoped vanilla policies (metrics/healthz ingress; 80/443 + DNS egress, which covers apiserver via the kubernetes ClusterIP).Not done, deliberately: app-template's
networkpoliciesblock (renders vanilla-only — cannot express the kube-apiserver entity or deny rules from #4072, and per-app allowlists across ~20 media apps is the maintenance burden #4072 was designed to avoid). No other pinned chart (cnpg, dragonfly-operator, rook-ceph, coredns, external-dns, envoy-gateway, crowdsec, grafana-operator) exposes a netpol value.No interaction risk with #4072: different namespaces entirely, and Cilium deny rules always win over allows regardless.
Verification:
helm templateon both pinned charts with these exact values renders the policies; kustomization YAML parses. Post-merge: confirm cert-manager still completes an ACME order (egress 443/DNS is allowed by the chart's own policy) and KSM metrics keep scraping.