Skip to content

Commit

Permalink
feat(EgressFirewall): Incept (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurVardevanyan committed Dec 24, 2024
1 parent 98a246c commit b6b60a7
Show file tree
Hide file tree
Showing 116 changed files with 2,014 additions and 132 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@
"pipelinerun",
"pipelineruns",
"pipelinesascode",
"pipelinesghubeus",
"pnfs",
"poddisruptionbudgets",
"podsecuritypolicies",
Expand Down
33 changes: 33 additions & 0 deletions kubernetes/argocd/base/egress-firewall.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: k8s.ovn.org/v1
kind: EgressFirewall
metadata:
name: default
namespace: argocd
spec:
egress:
# Control Plane
- type: Allow
to:
nodeSelector:
matchLabels:
node-role.kubernetes.io/control-plane: ""
# MicroShift
- type: Allow
to:
cidrSelector: 10.0.0.99/32
- type: Allow
to:
dnsName: microshift.arthurvardevanyan.com
# https://api.github.com/meta
- type: Allow
to:
dnsName: github.com
- type: Allow
to:
dnsName: api.github.com
- type: Allow
to:
cidrSelector: 140.82.112.0/20
- type: Deny
to:
cidrSelector: 0.0.0.0/0
1 change: 1 addition & 0 deletions kubernetes/argocd/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ resources:
- dragonfly/network-policy.yaml
- k3s-cluster.yaml
- microshift-cluster.yaml
- ./egress-firewall.yaml
48 changes: 24 additions & 24 deletions kubernetes/argocd/base/network-policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -259,27 +259,27 @@ spec:
- namespaceSelector:
matchLabels:
network.openshift.io/policy-group: ingress
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-internet-egress
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "0"
labels:
app.kubernetes.io/instance: argocd
spec:
policyTypes:
- Egress
podSelector:
matchLabels:
app.kubernetes.io/name: argocd-repo-server
egress:
- to:
- ipBlock:
cidr: 0.0.0.0/0
except:
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
# ---
# apiVersion: networking.k8s.io/v1
# kind: NetworkPolicy
# metadata:
# name: allow-internet-egress
# namespace: argocd
# annotations:
# argocd.argoproj.io/sync-wave: "0"
# labels:
# app.kubernetes.io/instance: argocd
# spec:
# policyTypes:
# - Egress
# podSelector:
# matchLabels:
# app.kubernetes.io/name: argocd-repo-server
# egress:
# - to:
# - ipBlock:
# cidr: 0.0.0.0/0
# except:
# - 10.0.0.0/8
# - 172.16.0.0/12
# - 192.168.0.0/16
11 changes: 6 additions & 5 deletions kubernetes/argocd/base/notifications/network-policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ spec:
app.kubernetes.io/name: argocd-notifications-controller
egress:
- to:
# https://api.github.com/meta
- ipBlock:
cidr: 0.0.0.0/0
except:
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
cidr: 140.82.112.0/20
# except:
# - 10.0.0.0/8
# - 172.16.0.0/12
# - 192.168.0.0/16
10 changes: 10 additions & 0 deletions kubernetes/bitwarden/overlays/okd/egress-firewall.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: k8s.ovn.org/v1
kind: EgressFirewall
metadata:
name: default
namespace: bitwarden
spec:
egress:
- type: Deny
to:
cidrSelector: 0.0.0.0/0
3 changes: 2 additions & 1 deletion kubernetes/bitwarden/overlays/okd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
- ingress.yaml
- ./ingress.yaml
- ./egress-firewall.yaml
1 change: 1 addition & 0 deletions kubernetes/blackbox-exporter/components/probes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ spec:
staticConfig:
static:
- https://1.1.1.1/
- https://1.0.0.1/
- http://192.168.100.1/
- https://api.okd.arthurvardevanyan.com:6443/healthz
- https://console-openshift-console.apps.okd.arthurvardevanyan.com/
Expand Down
50 changes: 50 additions & 0 deletions kubernetes/blackbox-exporter/overlays/okd/egress-firewall.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
apiVersion: k8s.ovn.org/v1
kind: EgressFirewall
metadata:
name: default
namespace: blackbox-exporter
spec:
egress:
# Cloudflare DNS
- type: Allow
to:
cidrSelector: 1.1.1.1/32
- type: Allow
to:
cidrSelector: 1.0.0.1/32
# Cloudflare API Ips (arthurvardevanyan.com)
# https://www.cloudflare.com/ips/
- type: Allow
to:
cidrSelector: 104.16.0.0/13
- type: Allow
to:
cidrSelector: 172.64.0.0/13
# Modem
- type: Allow
to:
cidrSelector: 192.168.100.1/32
- type: Allow
to:
dnsName: truenas.arthurvardevanyan.com
- type: Allow
to:
dnsName: www.arthurvardevanyan.com
- type: Allow
to:
dnsName: truenas.arthurvardevanyan.com
- type: Allow
to:
dnsName: unifi.arthurvardevanyan.com
- type: Allow
to:
dnsName: pihole.arthurvardevanyan.com
- type: Allow
to:
dnsName: api.okd.arthurvardevanyan.com
- type: Allow
to:
dnsName: apps.okd.arthurvardevanyan.com
- type: Deny
to:
cidrSelector: 0.0.0.0/0
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
- ./egress-firewall.yaml
components:
- ../../components
16 changes: 16 additions & 0 deletions kubernetes/ceph/overlays/okd/egress-firewall.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: k8s.ovn.org/v1
kind: EgressFirewall
metadata:
name: default
namespace: rook-ceph
spec:
egress:
# Control Plane
- type: Allow
to:
nodeSelector:
matchLabels:
node-role.kubernetes.io/control-plane: ""
- type: Deny
to:
cidrSelector: 0.0.0.0/0
1 change: 1 addition & 0 deletions kubernetes/ceph/overlays/okd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
- ./egress-firewall.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ resources:
- ./gcp-credentials-request.yaml
- ./cluster-issuer.yaml
- ./kyverno.yaml
- ./network-policy.yaml
26 changes: 26 additions & 0 deletions kubernetes/cert-manager/components/cloud-dns/network-policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-google-cloud-egress
namespace: cert-manager
annotations:
argocd.argoproj.io/sync-wave: "0"
labels:
app.kubernetes.io/instance: certificate-manager
spec:
policyTypes:
- Egress
podSelector: {}
egress:
# Google Range
# https://support.google.com/a/answer/10026322?hl=en
# https://www.gstatic.com/ipranges/goog.json
# Cloud DNS API?
- to:
- ipBlock:
cidr: 172.217.0.0/16
# Cloud DNS DNS LookUp?
- to:
- ipBlock:
cidr: 216.239.32.0/19
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-internet-egress
name: allow-cloudflare-egress
namespace: cert-manager
annotations:
argocd.argoproj.io/sync-wave: "0"
Expand All @@ -53,9 +53,15 @@ spec:
podSelector: {}
egress:
- to:
# - ipBlock:
# cidr: 0.0.0.0/0
# except:
# - 10.0.0.0/8
# - 172.16.0.0/12
# - 192.168.0.0/16
# CloudFlare API IP Ranges
# https://www.cloudflare.com/ips/
- ipBlock:
cidr: 0.0.0.0/0
except:
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
cidr: 104.16.0.0/13
- ipBlock:
cidr: 172.64.0.0/13
41 changes: 41 additions & 0 deletions kubernetes/cert-manager/overlays/okd/egress-firewall.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apiVersion: k8s.ovn.org/v1
kind: EgressFirewall
metadata:
name: default
namespace: cert-manager
spec:
egress:
# Control Plane
- type: Allow
to:
nodeSelector:
matchLabels:
node-role.kubernetes.io/control-plane: ""
# Cloudflare API Ips
# https://www.cloudflare.com/ips/
- type: Allow
to:
dnsName: api.cloudflare.com
- type: Allow
to:
cidrSelector: 104.16.0.0/13
- type: Allow
to:
cidrSelector: 172.64.0.0/13
# Google Range
# https://support.google.com/a/answer/10026322?hl=en
# https://www.gstatic.com/ipranges/goog.json
# Cloud DNS API?
- type: Allow
to:
dnsName: dns.googleapis.com
- type: Allow
to:
cidrSelector: 172.217.0.0/16
# Cloud DNS DNS LookUp?
- type: Allow
to:
cidrSelector: 216.239.32.0/19
- type: Deny
to:
cidrSelector: 0.0.0.0/0
1 change: 1 addition & 0 deletions kubernetes/cert-manager/overlays/okd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ resources:
- ../../components/network-policy/base
- ../../components/network-policy/okd
- ./service-monitor.yaml
- ./egress-firewall.yaml
components:
- ../../components/trust-manager
- ../../components/cloud-dns
28 changes: 28 additions & 0 deletions kubernetes/cloudflare-ddns/overlays/okd/egress-firewall.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: k8s.ovn.org/v1
kind: EgressFirewall
metadata:
name: default
namespace: cloudflare-ddns
spec:
egress:
# Cloudflare DNS
- type: Allow
to:
cidrSelector: 1.1.1.1/32
- type: Allow
to:
cidrSelector: 1.0.0.1/32
# Cloudflare API Ips
# https://www.cloudflare.com/ips/
- type: Allow
to:
dnsName: api.cloudflare.com
- type: Allow
to:
cidrSelector: 104.16.0.0/13
- type: Allow
to:
cidrSelector: 172.64.0.0/13
- type: Deny
to:
cidrSelector: 0.0.0.0/0
1 change: 1 addition & 0 deletions kubernetes/cloudflare-ddns/overlays/okd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
- ./egress-firewall.yaml
16 changes: 16 additions & 0 deletions kubernetes/cockroachdb/overlays/okd/egress-firewall.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: k8s.ovn.org/v1
kind: EgressFirewall
metadata:
name: default
namespace: cockroach-operator-system
spec:
egress:
# Control Plane
- type: Allow
to:
nodeSelector:
matchLabels:
node-role.kubernetes.io/control-plane: ""
- type: Deny
to:
cidrSelector: 0.0.0.0/0
1 change: 1 addition & 0 deletions kubernetes/cockroachdb/overlays/okd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
- ./egress-firewall.yaml
Loading

0 comments on commit b6b60a7

Please sign in to comment.