-
Notifications
You must be signed in to change notification settings - Fork 11
Adds the network policy for operator #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,24 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
apiVersion: networking.k8s.io/v1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
kind: NetworkPolicy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
metadata: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name: allow-operator-traffic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
namespace: external-secrets-operator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
spec: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
podSelector: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
matchLabels: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
app: external-secrets-operator | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
policyTypes: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- Ingress | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- Egress | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
egress: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- protocol: TCP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
port: 6443 # Required: Kubernetes API server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ingress: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+10
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Egress rule is too restrictive; will break DNS and external provider access Allowing only TCP 6443 egress blocks DNS (53) and external APIs (443), which external-secrets-operator typically needs to fetch secrets. If you must keep egress policy, add DNS and 443 (and any others you require). Otherwise, remove egress from policyTypes and drop the egress block. Two options:
policyTypes:
- - Ingress
- - Egress
+ - Ingress
- egress:
- - ports:
- - protocol: TCP
- port: 6443 # Required: Kubernetes API server
egress:
- - ports:
- - protocol: TCP
- port: 6443 # Required: Kubernetes API server
+ - to:
+ - namespaceSelector:
+ matchLabels:
+ kubernetes.io/metadata.name: kube-system
+ podSelector:
+ matchLabels:
+ k8s-app: kube-dns
+ ports:
+ - protocol: UDP
+ port: 53
+ - protocol: TCP
+ port: 53
+ - ports:
+ - protocol: TCP
+ port: 443 📝 Committable suggestion
Suggested change
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Optional: expose metrics (8443 and 8080 based on user configuration) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- protocol: TCP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
port: 8443 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
- protocol: TCP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
port: 8080 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+18
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ingress is overly permissive; it allows any source to metrics ports Without a from selector, any pod can scrape 8443/8080. Either:
Also, 8080 may be unused if HTTPS metrics are enabled. Preferred fix (de-duplicate and restrict): ingress:
- # Optional: expose metrics (8443 and 8080 based on user configuration)
- - ports:
- - protocol: TCP
- port: 8443
- - ports:
- - protocol: TCP
- port: 8080
+ - from:
+ - namespaceSelector:
+ matchLabels:
+ metrics: "enabled"
+ ports:
+ - protocol: TCP
+ port: 8443 If you keep 8080, mirror the same from selector. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,16 @@ | ||||||||||||||||||||||||||||
apiVersion: networking.k8s.io/v1 | ||||||||||||||||||||||||||||
kind: NetworkPolicy | ||||||||||||||||||||||||||||
metadata: | ||||||||||||||||||||||||||||
labels: | ||||||||||||||||||||||||||||
app: external-secrets-operator | ||||||||||||||||||||||||||||
app.kubernetes.io/name: external-secrets-operator | ||||||||||||||||||||||||||||
app.kubernetes.io/managed-by: kustomize | ||||||||||||||||||||||||||||
name: deny-all-traffic | ||||||||||||||||||||||||||||
namespace: system | ||||||||||||||||||||||||||||
spec: | ||||||||||||||||||||||||||||
podSelector: | ||||||||||||||||||||||||||||
matchLabels: | ||||||||||||||||||||||||||||
app: external-secrets-operator | ||||||||||||||||||||||||||||
policyTypes: | ||||||||||||||||||||||||||||
- Ingress | ||||||||||||||||||||||||||||
- Egress | ||||||||||||||||||||||||||||
Comment on lines
+10
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Default deny egress will likely break the operator (DNS, cloud providers, webhooks) Denying all egress without explicit exceptions will block:
If the goal is to “protect metrics/webhook,” prefer ingress-only default deny. Otherwise, explicitly add egress allows (DNS + required external endpoints). Suggested minimal fix (ingress-only deny): spec:
podSelector:
matchLabels:
app: external-secrets-operator
policyTypes:
- Ingress
- - Egress 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
resources: | ||
- allow-metrics-traffic.yaml | ||
- allow-network-traffic.yaml | ||
- deny-all.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Enabling network policies: verify selector alignment and traffic impact
Including ../network-policy will enforce the new deny/allow rules. Ensure the podSelector labels in those policies match the operator Deployment labels; otherwise, policies won’t apply or, worse, could over/under-block traffic.
Run this to inspect Deployment labels and reconcile with the NetworkPolicy podSelectors:
🏁 Script executed:
Length of output: 46592
🏁 Script executed:
Length of output: 11582
NetworkPolicy namespace mismatch — policies won't apply to the Deployment
Deployment runs in namespace "system" with label app: external-secrets-operator (config/manager/manager.yaml). deny-all.yaml and allow-network-traffic.yaml are scoped to namespace "external-secrets-operator" (config/network-policy/*) so they will NOT affect the Deployment; allow-metrics-traffic.yaml is in "system" and will apply.
🤖 Prompt for AI Agents