-
Notifications
You must be signed in to change notification settings - Fork 156
CNTRLPLANE-2663: Add network policies #1538
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
Open
dusk125
wants to merge
10
commits into
openshift:main
Choose a base branch
from
dusk125:network-policy
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.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1691367
Add network policies
dusk125 19024b5
combine policies into a single file
dusk125 3de4152
add egress to monitoring
dusk125 7200a51
add port 53 to dns entry
dusk125 51b0e2e
Add readyz
dusk125 23682a9
add default deny
dusk125 9a3fc79
update api NP
dusk125 63fab10
add namespace selector to etcd egress
dusk125 72a6e5f
get rid of some erroneous fields
dusk125 e1e006f
move default deny to last applied
dusk125 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
171 changes: 171 additions & 0 deletions
171
manifests/0000_20_etcd-operator_11_networkpolicies.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,171 @@ | ||
| --- | ||
| # Allow egress to DNS for the etcd-operator. | ||
| # The operator needs DNS resolution to resolve service names and API endpoints. | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: NetworkPolicy | ||
| metadata: | ||
| name: allow-to-dns | ||
| namespace: openshift-etcd-operator | ||
| annotations: | ||
| include.release.openshift.io/self-managed-high-availability: "true" | ||
| include.release.openshift.io/single-node-developer: "true" | ||
| spec: | ||
| podSelector: {} | ||
| egress: | ||
| - to: | ||
| - namespaceSelector: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: openshift-dns | ||
| ports: | ||
| - protocol: TCP | ||
| port: 5353 | ||
| - protocol: UDP | ||
| port: 5353 | ||
| - protocol: TCP | ||
| port: 53 | ||
| - protocol: UDP | ||
| port: 53 | ||
| policyTypes: | ||
| - Egress | ||
| --- | ||
| # Allow egress to the Kubernetes API server. | ||
| # The etcd-operator needs to communicate with the API server to: | ||
| # - Watch and update etcd resources | ||
| # - Manage pods, services, and other resources in the openshift-etcd namespace | ||
| # - Update cluster operator status | ||
| # - Watch nodes and other cluster resources | ||
| # | ||
| # Note: We allow all egress because the API server IP address and port can vary | ||
| # depending on cluster configuration (external load balancer, internal service, etc.). | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: NetworkPolicy | ||
| metadata: | ||
| name: allow-to-apiserver | ||
| namespace: openshift-etcd-operator | ||
| annotations: | ||
| include.release.openshift.io/self-managed-high-availability: "true" | ||
| include.release.openshift.io/single-node-developer: "true" | ||
| spec: | ||
| podSelector: {} | ||
| egress: | ||
| - {} | ||
| policyTypes: | ||
| - Egress | ||
| --- | ||
| # Allow ingress to the metrics endpoint from Prometheus. | ||
| # The etcd-operator exposes metrics on port 8443 (containerPort) which is mapped | ||
| # to port 443 via the "metrics" service. | ||
| # | ||
| # This policy allows Prometheus (and other monitoring components) running in namespaces | ||
| # with the host-network policy group label to scrape metrics from the operator. | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: NetworkPolicy | ||
| metadata: | ||
| name: allow-to-metrics | ||
| namespace: openshift-etcd-operator | ||
| annotations: | ||
| include.release.openshift.io/self-managed-high-availability: "true" | ||
| include.release.openshift.io/single-node-developer: "true" | ||
| spec: | ||
| podSelector: | ||
| matchLabels: | ||
| app: etcd-operator | ||
| ingress: | ||
| - ports: | ||
| - protocol: TCP | ||
| port: 8443 | ||
| policyTypes: | ||
| - Ingress | ||
| --- | ||
| # Allow egress to etcd endpoints. | ||
| # The etcd-operator needs to communicate with etcd pods to: | ||
| # - Manage the etcd cluster (add/remove members) | ||
| # - Check etcd health and status | ||
| # - Perform backup and restore operations | ||
| # | ||
| # etcd pods run with hostNetwork: true, which means they bypass | ||
| # NetworkPolicy entirely. We restrict egress to the openshift-etcd namespace | ||
| # on specific ports for defense in depth, even though etcd itself runs on | ||
| # the host network and is accessed via node IPs. | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: NetworkPolicy | ||
| metadata: | ||
| name: allow-to-etcd | ||
| namespace: openshift-etcd-operator | ||
| annotations: | ||
| include.release.openshift.io/self-managed-high-availability: "true" | ||
| include.release.openshift.io/single-node-developer: "true" | ||
| spec: | ||
| podSelector: | ||
| matchLabels: | ||
| app: etcd-operator | ||
| egress: | ||
| - to: | ||
| - namespaceSelector: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: openshift-etcd | ||
| ports: | ||
| - protocol: TCP | ||
| port: 2379 | ||
| - protocol: TCP | ||
| port: 9978 | ||
| - protocol: TCP | ||
| port: 9979 | ||
| - protocol: TCP | ||
| port: 9980 | ||
| policyTypes: | ||
| - Egress | ||
| --- | ||
| # Allow egress to monitoring services (Thanos/Prometheus). | ||
| # The etcd-operator's FSyncController needs to query Thanos for etcd disk fsync metrics | ||
| # to monitor disk performance and detect issues. | ||
| # | ||
| # The controller queries thanos-querier.openshift-monitoring.svc:9091 to get | ||
| # histogram data about etcd disk write performance. | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: NetworkPolicy | ||
| metadata: | ||
| name: allow-to-monitoring | ||
| namespace: openshift-etcd-operator | ||
| annotations: | ||
| include.release.openshift.io/self-managed-high-availability: "true" | ||
| include.release.openshift.io/single-node-developer: "true" | ||
| spec: | ||
| podSelector: | ||
| matchLabels: | ||
| app: etcd-operator | ||
| egress: | ||
| - to: | ||
| - namespaceSelector: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: openshift-monitoring | ||
| ports: | ||
| - protocol: TCP | ||
| port: 9091 | ||
| policyTypes: | ||
| - Egress | ||
| --- | ||
| # Default-deny policy for the openshift-etcd-operator namespace. | ||
| # This policy selects all pods in the namespace and enables default-deny for both | ||
| # ingress and egress by specifying policyTypes without any allow rules. | ||
| # | ||
| # NetworkPolicies are additive (use OR logic): | ||
| # - This policy enables default-deny for all pods | ||
| # - Subsequent policies add specific allow rules | ||
| # - If any policy allows traffic, that traffic is permitted | ||
| # - Policies cannot override or block traffic allowed by other policies | ||
| # | ||
| # Without this policy, all pods would have unrestricted network access (allow-all). | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: NetworkPolicy | ||
| metadata: | ||
| name: default-deny | ||
| namespace: openshift-etcd-operator | ||
| annotations: | ||
| include.release.openshift.io/self-managed-high-availability: "true" | ||
| include.release.openshift.io/single-node-developer: "true" | ||
| spec: | ||
| podSelector: {} | ||
| policyTypes: | ||
| - Ingress | ||
| - Egress | ||
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.
Uh oh!
There was an error while loading. Please reload this page.