-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add NetworkPolicy documentation #78
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
Merged
bl0up
merged 1 commit into
main
from
oleksandr/eng-1343-add-documentation-about-enforce-netrowkpolicy-on-k8s
Sep 26, 2024
Merged
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -326,7 +326,7 @@ Access to services is facilitated through domain names. The setup can involve: | |
| - Wildcard DNS | ||
|
|
||
| entries for each cluster, ensuring they include TLS termination to secure the domain. | ||
| - Path-based routing as an alternative method, depending on the cluster’s setup and requirements. | ||
| - Path-based routing as an alternative method, depending on the cluster's setup and requirements. | ||
|
|
||
| Before deploying, please verify that your provided cluster includes an Ingress controller configured to handle routing. Our deployment process assumes and relies on the presence of an Ingress controller for seamless operation. We offer a straightforward "Ingress" object designed specifically for nginx-ingress, which can be easily adjusted to align with your preferred Ingress controller. | ||
|
|
||
|
|
@@ -371,4 +371,92 @@ targets: | |
| capabilities: | ||
| mixedLoadBalancers: false | ||
| ``` | ||
| Once your values file is prepared, you're all set to proceed with the installation! | ||
| Once your values file is prepared, you're all set to proceed with the installation! | ||
|
|
||
| ### 6. Network Policies enforcement on the target clusters | ||
|
|
||
| The BTP platform applies NetworkPolicies for CustomDeployment services to restrict access to services to other namespaces. However, not all cloud providers enforce NetworkPolicies by default on their Kubernetes clusters. We strongly recommend enabling NetworkPolicy enforcement on your Kubernetes cluster before creating it. | ||
|
|
||
| Here's how to enable NetworkPolicy enforcement on different cloud providers: | ||
|
|
||
| #### Google Kubernetes Engine (GKE) | ||
| When creating a new cluster or updating an existing one: | ||
|
|
||
| ```bash | ||
| gcloud container clusters create/update CLUSTER_NAME \ | ||
| --enable-network-policy | ||
| ``` | ||
|
|
||
| or enable `Dataplane V2`, which enforce NetworkPolicies. | ||
|
|
||
| ```bash | ||
| gcloud container clusters update CLUSTER_NAME \ | ||
| --enable-dataplane-v2 | ||
| ``` | ||
|
|
||
| #### Amazon Elastic Kubernetes Service (EKS) | ||
| New EKS clusters will have NetworkPolicy enforcement enabled by default. | ||
|
|
||
| If you have an existing cluster without NetworkPolicy enforcement enabled, you can update it by setting the following configuration for EKS CNI plugin: | ||
|
|
||
| ```bash | ||
| aws eks update-addon --cluster-name YOUR_CLUSTER_NAME --addon-name vpc-cni --addon-version ADDON_VERSION --configuration-values '{"enableNetworkPolicy":"true"}' | ||
| ``` | ||
|
|
||
| #### Azure Kubernetes Service (AKS) | ||
| When creating a new cluster: | ||
|
|
||
| ```bash | ||
| az aks create --resource-group myResourceGroup --name myAKSCluster --network-policy calico | ||
| ``` | ||
|
|
||
| To update an existing cluster: | ||
|
|
||
| ```bash | ||
| az aks update --resource-group myResourceGroup --name myAKSCluster --network-policy calico | ||
| ``` | ||
|
|
||
| By enforcing NetworkPolicies, you enhance the security of your BTP deployment by controlling traffic flow between pods and namespaces. | ||
|
|
||
| NetworkPolicies look like this: | ||
|
|
||
| ```yaml | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: NetworkPolicy | ||
| metadata: | ||
| name: combined-restrict-internal-allow-external | ||
| namespace: $namespace | ||
| spec: | ||
| podSelector: {} | ||
| policyTypes: | ||
| - Egress | ||
| egress: | ||
| # 1. Allow DNS resolution (covers GKE, AKS, and EKS) | ||
| - to: | ||
| - ipBlock: | ||
| cidr: 10.0.0.0/8 # For the GKE cluster | ||
| - namespaceSelector: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: kube-system | ||
| podSelector: | ||
| matchLabels: | ||
| k8s-app: kube-dns | ||
| ports: | ||
| - protocol: UDP | ||
| port: 53 | ||
| - protocol: TCP | ||
| port: 53 | ||
| # 2. Allow traffic within the same namespace (curl) | ||
| - to: | ||
| - namespaceSelector: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: $namespace | ||
| # 3. Allow traffic to all external IPs but block internal IP ranges | ||
| - to: | ||
| - ipBlock: | ||
| cidr: 0.0.0.0/0 | ||
| except: | ||
| - 10.0.0.0/8 | ||
| - 172.16.0.0/12 | ||
| - 192.168.0.0/16 | ||
|
Comment on lines
+427
to
+461
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. suggestion (documentation): Consider explaining the $namespace variable in the NetworkPolicy example It might be helpful to add a note explaining what the $namespace variable represents and how it should be replaced in the actual implementation. |
||
| ``` | ||
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.
suggestion (documentation): Consider clarifying the timing of enabling NetworkPolicy enforcement
The phrase 'before creating it' might be confusing as the cluster would already exist at this point. Consider changing to 'before deploying to it' or 'before using it with BTP' for clarity.