|
1 | | -# Network Policies (Beta) |
| 1 | +# Set Network Policies (Beta) |
2 | 2 |
|
3 | | -This topic describes how to use network policies and Air Gap features for Replicated Compatibility Matrix Clusters and VMs. |
| 3 | +This topic describes how to change the network policy of a virtual machine (VM) or a VM-based cluster with Replicated Compatibility Matrix. |
4 | 4 |
|
5 | 5 | ## About Network Policies |
6 | 6 |
|
7 | | -Test and verify your application in an Air Gap environment. Particularly useful to test [Replicated Embedded Cluster](https://docs.replicated.com/enterprise/installing-embedded-air-gap) or [Helm CLI install](https://docs.replicated.com/vendor/helm-install-airgap) intended for install in an Air Gap environment. |
| 7 | +VMs and VM-based clusters created with Compatibility Matrix can use one of the following network policies: |
8 | 8 |
|
9 | | -## Prerequisites |
| 9 | +| Network Policy | Description | |
| 10 | +| :---- | :---- | |
| 11 | +| `open` | No restrictions on network traffic. | |
| 12 | +| `airgap` | Restrict all network traffic. | |
10 | 13 |
|
11 | | -* You must be using Replicated CLI 0.109.0 or higher |
12 | | -* You must have the Admin or Developer role. Read Only users cannot change network settings |
| 14 | +By default, all VMs and clusters are created with an `open` network policy. You can change the network policy to `airgap` to create an _air-gapped_ environment with no outbound internet access. |
| 15 | + |
| 16 | +The `airgap` network policy is particularly useful for testing air gap installations for your application. For information about installing with Embedded Cluster in an air-gapped environment, see [Air Gap Installation with Embedded Cluster](/enterprise/installing-embedded-air-gap). For information about installing with the Helm CLI in an air-gapped environment, see [Install and Update with Helm in Air Gap Environments](/vendor/helm-install-airgap). |
| 17 | + |
| 18 | +## Requirements |
| 19 | + |
| 20 | +* Replicated CLI 0.109.0 or later |
| 21 | +* The user must have the Admin or Developer role. Read Only users cannot change network settings. |
13 | 22 |
|
14 | 23 | ## Limitations |
15 | 24 |
|
16 | | -* Currently only open and air gapped policies are supported. For feedback, contact Replicated support. |
17 | | -* Air Gap networks cannot yet be set within the Compatibility Matrix UI |
| 25 | +* Network policies are a beta feature. For feedback on this feature, including requests for additional types of network policies, contact Replicated support. |
| 26 | +* Setting network policies is only supported through the Replicated CLI. You cannot make changes to the network policy through the Compatibility Matrix UI in the Vendor Portal. |
| 27 | +* Network policies are supported only for VMs and VM-based clusters (K3s, RKE2, Embedded Cluster, kURL, Kind, OpenShift). Network policies are not supported for cloud-based clusters (EKS, GKE, AKE, OKE). |
| 28 | + |
| 29 | +## Set the Network Policy to `airgap` |
18 | 30 |
|
19 | | -## For Clusters |
| 31 | +### For VM-Based Clusters |
20 | 32 |
|
21 | | -:::important |
| 33 | +To set the network policy of a VM-based cluster: |
22 | 34 |
|
23 | | -* Only for VM-base K8s clusters: K3s, RKE2, Embedded Cluster, kURL, Kind, OpenShift |
24 | | -* Not yet for Cloud-based K8s clusters: EKS, GKE, AKE, OKE |
| 35 | +1. Create a cluster: |
25 | 36 |
|
26 | | -::: |
| 37 | + ```bash |
| 38 | + replicated cluster create --distribution VM_BASED_DISTRIBUTION |
| 39 | + ``` |
| 40 | + Where `VM_BASED_DISTRIBUTION` is the target VM-based cluster distribution. For a list of supported distributions, see [VM Clusters](/vendor/testing-supported-clusters#vm-clusters). |
27 | 41 |
|
28 | | -### Create Cluster |
| 42 | +1. Watch until the cluster status is `running`: |
29 | 43 |
|
30 | | -```bash |
31 | | -replicated cluster create --distribution [K8s DISTRIBUTION] |
32 | | -``` |
| 44 | + ```bash |
| 45 | + replicated cluster ls --watch |
| 46 | + ``` |
33 | 47 |
|
34 | | -**Example:** `replicated cluster create --distribution k3s` |
| 48 | +1. (Optional) Verify the initial outbound network connectivity for the cluster: |
35 | 49 |
|
36 | | -### Option: Verify Initial Network Connectivity |
| 50 | + 1. Access the cluster in a shell: |
37 | 51 |
|
38 | | -1. Check the cluster is running ( `replicated cluster ls --watch` ) |
| 52 | + ``` |
| 53 | + replicated cluster shell CLUSTER_ID |
| 54 | + ``` |
| 55 | + Where `CLUSTER_ID` is the ID of the cluster that you created from the output of the `cluster ls` command. |
39 | 56 |
|
40 | | -2. Access the cluster ( `replicated cluster shell [CLUSTER ID] )` |
| 57 | + 1. In the cluster, install a networking testing tool. For example, [netshoot](https://github.com/nicolaka/netshoot). |
41 | 58 |
|
42 | | -3. Optional: Install a networking testing tool like a [netshoot](https://github.com/nicolaka/netshoot) pod: |
| 59 | + **Example:** |
43 | 60 |
|
44 | | -```bash |
45 | | -kubectl run tmp-shell --rm -i --tty --image nicolaka/netshoot |
46 | | -``` |
| 61 | + ```bash |
| 62 | + kubectl run tmp-shell --rm -i --tty --image nicolaka/netshoot |
| 63 | + ``` |
47 | 64 |
|
48 | | -4. Curl an endpoint (e.g., `curl www.google.com` ), confirm success. |
| 65 | + 1. Curl an endpoint to confirm a successful response. For example, `curl www.google.com`. |
49 | 66 |
|
50 | | -### Set Network Policy to Air Gap |
| 67 | +1. Open a new shell to access the cluster: |
51 | 68 |
|
52 | | -Using a different shell, update the network to `airgap`: |
| 69 | + ``` |
| 70 | + replicated cluster shell CLUSTER_ID |
| 71 | + ``` |
| 72 | + Where `CLUSTER_ID` is the ID of the cluster that you created from the output of the `cluster ls` command. |
53 | 73 |
|
54 | | -| Open | Air Gap | Custom / Allowlist | |
55 | | -| :---- | :---- | :---- | |
56 | | -| No restrictions on network traffic | Restrict all network traffic | Restrict all except Allowlist | |
57 | | -| `open` | `airgap` | Coming Soon | |
| 74 | +1. Change the network policy to `airgap`: |
58 | 75 |
|
59 | | -```bash |
60 | | -replicated network update [NETWORK ID] --policy airgap |
61 | | -``` |
| 76 | + ```bash |
| 77 | + replicated network update NETWORK_ID --policy airgap |
| 78 | + ``` |
| 79 | + Where `NETWORK_ID` is the ID of the network from the output of the `cluster ls` command. |
62 | 80 |
|
63 | | -If successful, you’ll see network status transition from `updating` to `running`: |
| 81 | +1. Verify that the cluster's policy is `airgap` and the status is `running`: |
64 | 82 |
|
65 | | -```bash |
66 | | -ID NAME STATUS CREATED EXPIRES POLICY REPORTING |
67 | | -bdeb3515 gifted_antonelli running 2025-01-28 18:45 PST 2025-01-28 19:45 PST airgap off |
68 | | -``` |
| 83 | + ```bash |
| 84 | + replicated cluster ls |
| 85 | + ``` |
69 | 86 |
|
70 | | -### Option: Verify Air Gap |
| 87 | + ```bash |
| 88 | + ID NAME STATUS CREATED EXPIRES POLICY REPORTING |
| 89 | + bdeb3515 gifted_antonelli running 2025-01-28 18:45 PST 2025-01-28 19:45 PST airgap off |
| 90 | + ``` |
71 | 91 |
|
72 | | -1. In the netshoot container, check outbound connectivity. (e.g., `curl www.google.com` ) |
| 92 | + The air gap network is enabled when the status is `running`. |
73 | 93 |
|
74 | | -2. Request will eventually time out: |
| 94 | +1. (Optional) Use a networking testing tool such as [netshoot](https://github.com/nicolaka/netshoot) to curl an endpoint and verify that there is no outbound connectivity from the cluster. |
75 | 95 |
|
76 | | -```bash |
77 | | -curl: (28) Failed to connect to www.google.com port 80 after 129976 ms: Couldn't connect to server |
78 | | -``` |
| 96 | + If the air gap was successful, a request to curl an endpoint will time out. For example: |
79 | 97 |
|
80 | | -## For Virtual Machines (VMs) |
| 98 | + ```bash |
| 99 | + curl: (28) Failed to connect to www.google.com port 80 after 129976 ms: Couldn't connect to server |
| 100 | + ``` |
81 | 101 |
|
82 | | -### Create VM |
| 102 | +1. (Optional) Test an air gap installation of your application in the cluster. See [Install and Update with Helm in Air Gap Environments](/vendor/helm-install-airgap). |
83 | 103 |
|
84 | | -```bash |
85 | | -replicated vm create --distribution ubuntu |
86 | | -``` |
| 104 | +### For VMs |
87 | 105 |
|
88 | | -If successful, you’ll see something like. When ready, STATUS will change queued → running |
| 106 | +To set the network policy of a VM-based cluster: |
89 | 107 |
|
90 | | -```bash |
91 | | -ID NAME DISTRIBUTION VERSION STATUS NETWORK CREATED EXPIRES COST |
92 | | -067ddbd3 eloquent_sal ubuntu 24.04 queued 85eb50a8 2025-01-28 16:18 PST - $0.60 |
93 | | -``` |
| 108 | +1. Create a VM: |
94 | 109 |
|
95 | | -### Option: Verify Initial Network Connectivity |
| 110 | + ```bash |
| 111 | + replicated vm create --distribution ubuntu |
| 112 | + ``` |
96 | 113 |
|
97 | | -1. SSH into the VM ( `ssh [VMID]@replicatedvm.com` ) |
98 | | - More options: [Connect to a VM](https://docs.replicated.com/vendor/testing-vm-create#connect-to-a-vm) |
| 114 | +1. Wait until the VM status is running: |
99 | 115 |
|
100 | | -2. Curl an endpoint (e.g., `curl www.google.com` ) |
| 116 | + ```bash |
| 117 | + replicated vm ls |
| 118 | + ``` |
101 | 119 |
|
102 | | -### Set Network Policy to Air Gap |
| 120 | +1. SSH onto the VM: |
103 | 121 |
|
104 | | -Optional: Confirm the VM is running (`replicated vm ls`) |
| 122 | + ```bash |
| 123 | + |
| 124 | + ``` |
| 125 | + Where `VM_ID` is the ID of the VM from the output of the `vm ls` command. |
105 | 126 |
|
106 | | -Then, set the network policy to `airgap` |
| 127 | + For more information and additional options, see [Connect to a VM](/vendor/testing-vm-create#connect-to-a-vm). |
107 | 128 |
|
108 | | -| Open | Air Gap | Custom / Allowlist | |
109 | | -| :---- | :---- | :---- | |
110 | | -| No restrictions on network traffic | Restrict all network traffic | Restrict all except Allowlist | |
111 | | -| `open` | `airgap` | Coming Soon | |
| 129 | +1. (Optional) Curl an endpoint to verify the network connectivity of the VM. For example, `curl www.google.com`. |
112 | 130 |
|
113 | | -```bash |
114 | | -replicated network update [NETWORK ID] --policy airgap |
115 | | -``` |
| 131 | +1. Set the network policy to `airgap`: |
116 | 132 |
|
117 | | -**Example:** `replicated network update 85eb50a8 --policy airgap` |
| 133 | + ```bash |
| 134 | + replicated network update NETWORK_ID --policy airgap |
| 135 | + ``` |
| 136 | + Where `NETWORK_ID` is the ID of the network from the output of the `vm ls` command. |
118 | 137 |
|
119 | | -If successful, you’ll see the network STATUS change from `updating` → `running` |
120 | | -Note: it may take a few seconds for the setting to apply. |
| 138 | + **Example:** |
121 | 139 |
|
122 | | -```bash |
123 | | -ID NAME STATUS CREATED EXPIRES POLICY REPORTING |
124 | | -85eb50a8 silly_rosalind updating 2025-01-28 16:16 PST 2025-01-28 17:18 PST airgap off |
125 | | -``` |
| 140 | + ```bash |
| 141 | + replicated network update 85eb50a8 --policy airgap |
| 142 | + ``` |
126 | 143 |
|
127 | | -### Option: Verify Air Gap |
| 144 | + :::note |
| 145 | + It can take a few seconds for the setting to apply. |
| 146 | + ::: |
128 | 147 |
|
129 | | -Confirm there is no outbound connectivity on your VM. |
| 148 | + ```bash |
| 149 | + ID NAME STATUS CREATED EXPIRES POLICY REPORTING |
| 150 | + 85eb50a8 silly_rosalind updating 2025-01-28 16:16 PST 2025-01-28 17:18 PST airgap off |
| 151 | + ``` |
130 | 152 |
|
131 | | -1. SSH into the VM ( `ssh [VMID]@replicatedvm.com` ) |
132 | | - More options: [Connect to a VM](https://docs.replicated.com/vendor/testing-vm-create#connect-to-a-vm) |
| 153 | +1. (Optional) Curl an endpoint to verify that there is no outbound connectivity from the VM. For example, `curl www.google.com`. |
133 | 154 |
|
134 | | -2. Curl an endpoint (e.g., `curl www.google.com` ) |
| 155 | + If the air gap was successful, a request to curl an endpoint will time out. For example: |
135 | 156 |
|
136 | | -The connection will eventually time out: |
| 157 | + ```bash |
| 158 | + curl: (28) Failed to connect to www.google.com port 80 after 129976 ms: Couldn't connect to server |
| 159 | + ``` |
137 | 160 |
|
138 | | -```bash |
139 | | -curl: (28) Failed to connect to www.google.com port 80 after 129976 ms: Couldn't connect to server |
140 | | -``` |
| 161 | +1. (Optional) Test an air gap installation of your application on the VM. See [Air Gap Installation with Embedded Cluster](/enterprise/installing-embedded-air-gap). |
0 commit comments