-
Notifications
You must be signed in to change notification settings - Fork 108
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
Add: network policies to create boundaries for proxies #8340
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: restrict-egress | ||
namespace: default | ||
spec: | ||
podSelector: {} # Applies to all pods | ||
policyTypes: | ||
- Egress | ||
egress: | ||
# Internal cluster communication | ||
- to: | ||
- ipBlock: | ||
cidr: 10.11.0.0/17 # VPC CIDR - adjust as needed | ||
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. Oh so to prevent re-entering the cluster ? 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. We want to force everything to internet via the nat gateway and we only want to allow internal communication within the cluster (so you cannot access the public cluster via the private one). |
||
|
||
# DNS resolution | ||
- to: | ||
- namespaceSelector: {} | ||
- ipBlock: | ||
cidr: 8.8.8.8/32 # Google DNS primary | ||
- ipBlock: | ||
cidr: 8.8.4.4/32 # Google DNS secondary | ||
ports: | ||
- protocol: UDP | ||
port: 53 | ||
- protocol: TCP | ||
port: 53 | ||
|
||
# Kubernetes API access | ||
- to: | ||
- ipBlock: | ||
cidr: 34.44.36.75/32 # Your control plane IP | ||
ports: | ||
- port: 443 | ||
- port: 6443 | ||
|
||
# Allow metadata access for Cloud NAT | ||
- to: | ||
- ipBlock: | ||
cidr: 169.254.169.254/32 # GCP metadata server | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
|
||
# Allow external internet access through Cloud NAT | ||
- to: | ||
- ipBlock: | ||
cidr: 0.0.0.0/0 | ||
except: | ||
- 10.0.0.0/8 # RFC1918 private ranges | ||
- 172.16.0.0/12 | ||
- 192.168.0.0/16 | ||
- 169.254.0.0/16 # Link local | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: restrict-ingress | ||
namespace: default | ||
spec: | ||
podSelector: {} # Applies to all pods | ||
policyTypes: | ||
- Ingress | ||
ingress: | ||
# Allow specific ports for external access | ||
- ports: | ||
- protocol: TCP | ||
port: 80 | ||
- protocol: TCP | ||
port: 1080 | ||
|
||
# Kubernetes API Server access | ||
- from: | ||
- ipBlock: | ||
cidr: 134.44.36.75/32 # Your control plane IP | ||
ports: | ||
- port: 10250 # kubelet metrics | ||
- port: 9153 # kube-dns metrics | ||
- port: 443 # kubernetes API server | ||
|
||
# Datadog Agent communication | ||
- from: | ||
- podSelector: | ||
matchLabels: | ||
name: datadog-agent | ||
|
||
ports: | ||
- port: 10250 # kubelet | ||
- port: 4194 # cadvisor | ||
- port: 8125 # dogstatsd | ||
- port: 8126 # trace agent |
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.
FMI, what does this do ? Why do we restrict the egress on the private cluster ?