-
Notifications
You must be signed in to change notification settings - Fork 22
mbp-1126: Network segmentation using UDN #147
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
Draft
mlorenzofr
wants to merge
1
commit into
validatedpatterns:main
Choose a base branch
from
mlorenzofr:mbp-1126
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| {{- if and .Values.app.udn.enabled .Values.app.udn.networkPolicy.enabled }} | ||
| # AdminNetworkPolicy for qtodo UDN | ||
| # Controls traffic on the secondary (UDN) interface with explicit allow-lists | ||
| # Primary network policies (cluster network) are in qtodo-network-policy.yaml | ||
| apiVersion: policy.networking.k8s.io/v1alpha1 | ||
| kind: AdminNetworkPolicy | ||
| metadata: | ||
| annotations: | ||
| argocd.argoproj.io/sync-wave: '37' | ||
| name: qtodo-udn-policy | ||
| spec: | ||
| priority: 50 | ||
| subject: | ||
| namespaces: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: {{ .Release.Namespace }} | ||
| ingress: | ||
| {{- if .Values.app.udn.networkPolicy.ingress.router.enabled }} | ||
| # Allow ingress from OpenShift router on primary network (not UDN) | ||
| # Router traffic comes through the cluster network interface | ||
| - name: allow-router-ingress | ||
| action: Allow | ||
| from: | ||
| - namespaces: | ||
| matchLabels: | ||
| policy-group.network.openshift.io/ingress: "" | ||
| ports: | ||
| - portNumber: | ||
| protocol: TCP | ||
| port: {{ .Values.app.udn.networkPolicy.ingress.router.port }} | ||
| {{- end }} | ||
| {{- if .Values.app.udn.networkPolicy.egress.postgresql.enabled }} | ||
| # Allow ingress to PostgreSQL from qtodo pods within same namespace on UDN | ||
| - name: allow-postgresql-ingress | ||
| action: Allow | ||
| from: | ||
| - pods: | ||
| namespaceSelector: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: {{ .Release.Namespace }} | ||
| podSelector: | ||
| matchLabels: | ||
| app: qtodo | ||
| ports: | ||
| - portNumber: | ||
| protocol: TCP | ||
| port: {{ .Values.app.udn.networkPolicy.egress.postgresql.port }} | ||
| {{- end }} | ||
| # Deny all other ingress by default on UDN | ||
| - name: deny-all-ingress | ||
| action: Deny | ||
| from: | ||
| - namespaces: {} | ||
| egress: | ||
| {{- if .Values.app.udn.networkPolicy.egress.dns.enabled }} | ||
| # Allow DNS resolution via CoreDNS | ||
| - name: allow-dns | ||
| action: Allow | ||
| to: | ||
| - namespaces: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: {{ .Values.app.udn.networkPolicy.egress.dns.namespace }} | ||
| ports: | ||
| - portNumber: | ||
| protocol: UDP | ||
| port: {{ .Values.app.udn.networkPolicy.egress.dns.port }} | ||
| - portNumber: | ||
| protocol: TCP | ||
| port: {{ .Values.app.udn.networkPolicy.egress.dns.port }} | ||
| {{- end }} | ||
| {{- if .Values.app.udn.networkPolicy.egress.postgresql.enabled }} | ||
| # Allow PostgreSQL access within same namespace on UDN | ||
| - name: allow-postgresql | ||
| action: Allow | ||
| to: | ||
| - pods: | ||
| namespaceSelector: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: {{ .Release.Namespace }} | ||
| podSelector: | ||
| matchLabels: | ||
| app: qtodo-db | ||
| ports: | ||
| - portNumber: | ||
| protocol: TCP | ||
| port: {{ .Values.app.udn.networkPolicy.egress.postgresql.port }} | ||
| {{- end }} | ||
| {{- if .Values.app.udn.networkPolicy.egress.vault.enabled }} | ||
| # Allow Vault API access (SPIFFE JWT auth) via cluster network | ||
| - name: allow-vault | ||
| action: Allow | ||
| to: | ||
| - namespaces: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: {{ .Values.app.udn.networkPolicy.egress.vault.namespace }} | ||
| ports: | ||
| - portNumber: | ||
| protocol: TCP | ||
| port: {{ .Values.app.udn.networkPolicy.egress.vault.port }} | ||
| {{- end }} | ||
| {{- if .Values.app.udn.networkPolicy.egress.https.enabled }} | ||
| # Allow OIDCs (HTTPS connections) via cluster network (external route) | ||
| - name: allow-https | ||
| action: Allow | ||
| to: | ||
| - networks: | ||
| - 0.0.0.0/0 # External route, cannot match by namespace | ||
| ports: | ||
| - portNumber: | ||
| protocol: TCP | ||
| port: {{ .Values.app.udn.networkPolicy.egress.https.port }} | ||
| {{- end }} | ||
| # Deny all other egress by default on UDN | ||
| - name: deny-all-egress | ||
| action: Deny | ||
| to: | ||
| - namespaces: {} | ||
| {{- end }} | ||
23 changes: 23 additions & 0 deletions
23
charts/qtodo/templates/udn-network-attachment-definition.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| {{- if .Values.app.udn.enabled }} | ||
| apiVersion: k8s.cni.cncf.io/v1 | ||
| kind: NetworkAttachmentDefinition | ||
| metadata: | ||
| annotations: | ||
| argocd.argoproj.io/sync-wave: '36' | ||
| description: "Network attachment for qtodo UDN isolation" | ||
| name: {{ .Values.app.udn.nadName }} | ||
| namespace: {{ .Release.Namespace }} | ||
| spec: | ||
| config: | | ||
| { | ||
| "cniVersion": "0.4.0", | ||
| "type": "ovn-k8s-cni-overlay", | ||
| "name": "{{ .Values.app.udn.name }}", | ||
| "topology": "{{ lower .Values.app.udn.topology }}", | ||
| "netAttachDefName": "{{ .Release.Namespace }}/{{ .Values.app.udn.nadName }}", | ||
| {{- if eq .Values.app.udn.topology "Layer2" }} | ||
| "subnets": "{{ .Values.app.udn.subnet }}", | ||
| {{- end }} | ||
| "mtu": {{ .Values.app.udn.mtu }} | ||
| } | ||
| {{- end }} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| {{- if .Values.app.udn.enabled }} | ||
| apiVersion: k8s.ovn.org/v1 | ||
| kind: UserDefinedNetwork | ||
| metadata: | ||
| annotations: | ||
| argocd.argoproj.io/sync-wave: '35' | ||
| name: {{ .Values.app.udn.name }} | ||
| namespace: {{ .Release.Namespace }} | ||
| spec: | ||
| topology: {{ .Values.app.udn.topology }} | ||
| {{- if eq .Values.app.udn.topology "Layer2" }} | ||
| layer2: | ||
| role: Primary | ||
| subnets: | ||
| - {{ .Values.app.udn.subnet }} | ||
| {{- if .Values.app.udn.mtu }} | ||
| mtu: {{ .Values.app.udn.mtu }} | ||
| {{- end }} | ||
| {{- else if eq .Values.app.udn.topology "Layer3" }} | ||
| layer3: | ||
| role: Primary | ||
| subnets: | ||
| - {{ .Values.app.udn.subnet }} | ||
| {{- if .Values.app.udn.joinSubnet }} | ||
| joinSubnets: | ||
| - {{ .Values.app.udn.joinSubnet }} | ||
| {{- end }} | ||
| {{- if .Values.app.udn.mtu }} | ||
| mtu: {{ .Values.app.udn.mtu }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,6 +91,59 @@ app: | |
| # QTodo truststore password path (app-level isolation) | ||
| vaultPath: "secret/data/apps/qtodo/qtodo-truststore" | ||
|
|
||
| # User-Defined Network (UDN) configuration for network isolation | ||
| # Provides layer 2/3 network segmentation following Zero Trust principles | ||
| udn: | ||
| enabled: false | ||
| # Network name | ||
| name: qtodo-isolated-network | ||
| # NetworkAttachmentDefinition name | ||
| nadName: qtodo-udn-nad | ||
| # Topology: Layer2 or Layer3 | ||
| # Layer2: Same subnet, pods can communicate directly | ||
| # Layer3: Different subnets per node, requires routing | ||
| topology: Layer2 | ||
| # CIDR for the UDN subnet (Layer2 only) | ||
| subnet: "10.100.0.0/16" | ||
| # Join subnet (for Layer3, optional) | ||
| # joinSubnet: "100.64.0.0/16" | ||
| # MTU for the network (default: 1400 to avoid fragmentation) | ||
| mtu: 1400 | ||
| # IPAM configuration | ||
| ipam: | ||
| type: static | ||
|
Collaborator
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. ipam is defined but not referenced by templates |
||
| # Network Policy for UDN | ||
| # UDN requires policies on both primary (cluster network) and secondary (UDN) interfaces | ||
| networkPolicy: | ||
| # Enable network policies on the UDN | ||
| enabled: true | ||
| # Allowed egress destinations from qtodo pods on the UDN | ||
| egress: | ||
| # DNS resolution | ||
| dns: | ||
| enabled: true | ||
| port: 5353 | ||
| namespace: openshift-dns | ||
| # PostgreSQL database | ||
| postgresql: | ||
| enabled: true | ||
| port: 5432 | ||
| # Vault for secrets (via primary network, not UDN) | ||
| vault: | ||
| enabled: true | ||
| port: 8200 | ||
| namespace: vault | ||
| # Allow HTTPS connections to any destination, used for OIDCs (via primary network for external route) | ||
| https: | ||
| enabled: true | ||
| port: 443 | ||
| # Allowed ingress sources to qtodo pods on the UDN | ||
| ingress: | ||
| # OpenShift router (via primary network, not UDN) | ||
| router: | ||
| enabled: true | ||
| port: 8080 | ||
|
|
||
| # PostgreSQL database configuration | ||
| postgresql: | ||
| name: qtodo-db | ||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
The flag used here is for
egress