|
| 1 | +# Network Policies (Beta) |
| 2 | + |
| 3 | +This topic describes how to use network policies and Air Gap features for Replicated Compatibility Matrix Clusters and VMs. |
| 4 | + |
| 5 | +## About Network Policies |
| 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. |
| 8 | + |
| 9 | +## Prerequisites |
| 10 | + |
| 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 |
| 13 | + |
| 14 | +## Limitations |
| 15 | + |
| 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 |
| 18 | + |
| 19 | +## For Clusters |
| 20 | + |
| 21 | +:::important |
| 22 | + |
| 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 |
| 25 | + |
| 26 | +::: |
| 27 | + |
| 28 | +### Create Cluster |
| 29 | + |
| 30 | +```bash |
| 31 | +replicated cluster create --distribution [K8s DISTRIBUTION] |
| 32 | +``` |
| 33 | + |
| 34 | +**Example:** `replicated cluster create --distribution k3s` |
| 35 | + |
| 36 | +### Option: Verify Initial Network Connectivity |
| 37 | + |
| 38 | +1. Check the cluster is running ( `replicated cluster ls --watch` ) |
| 39 | + |
| 40 | +2. Access the cluster ( `replicated cluster shell [CLUSTER ID] )` |
| 41 | + |
| 42 | +3. Optional: Install a networking testing tool like a [netshoot](https://github.com/nicolaka/netshoot) pod: |
| 43 | + |
| 44 | +```bash |
| 45 | +kubectl run tmp-shell --rm -i --tty --image nicolaka/netshoot |
| 46 | +``` |
| 47 | + |
| 48 | +4. Curl an endpoint (e.g., `curl www.google.com` ), confirm success. |
| 49 | + |
| 50 | +### Set Network Policy to Air Gap |
| 51 | + |
| 52 | +Using a different shell, update the network to `airgap`: |
| 53 | + |
| 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 | |
| 58 | + |
| 59 | +```bash |
| 60 | +replicated network update [NETWORK ID] --policy airgap |
| 61 | +``` |
| 62 | + |
| 63 | +If successful, you’ll see network status transition from `updating` to `running`: |
| 64 | + |
| 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 | +``` |
| 69 | + |
| 70 | +### Option: Verify Air Gap |
| 71 | + |
| 72 | +1. In the netshoot container, check outbound connectivity. (e.g., `curl www.google.com` ) |
| 73 | + |
| 74 | +2. Request will eventually time out: |
| 75 | + |
| 76 | +```bash |
| 77 | +curl: (28) Failed to connect to www.google.com port 80 after 129976 ms: Couldn't connect to server |
| 78 | +``` |
| 79 | +
|
| 80 | +## For Virtual Machines (VMs) |
| 81 | +
|
| 82 | +### Create VM |
| 83 | +
|
| 84 | +```bash |
| 85 | +replicated vm create --distribution ubuntu |
| 86 | +``` |
| 87 | +
|
| 88 | +If successful, you’ll see something like. When ready, STATUS will change queued → running |
| 89 | +
|
| 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 | +``` |
| 94 | +
|
| 95 | +### Option: Verify Initial Network Connectivity |
| 96 | +
|
| 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) |
| 99 | +
|
| 100 | +2. Curl an endpoint (e.g., `curl www.google.com` ) |
| 101 | +
|
| 102 | +### Set Network Policy to Air Gap |
| 103 | +
|
| 104 | +Optional: Confirm the VM is running (`replicated vm ls`) |
| 105 | +
|
| 106 | +Then, set the network policy to `airgap` |
| 107 | +
|
| 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 | |
| 112 | +
|
| 113 | +```bash |
| 114 | +replicated network update [NETWORK ID] --policy airgap |
| 115 | +``` |
| 116 | +
|
| 117 | +**Example:** `replicated network update 85eb50a8 --policy airgap` |
| 118 | +
|
| 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. |
| 121 | +
|
| 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 | +``` |
| 126 | +
|
| 127 | +### Option: Verify Air Gap |
| 128 | +
|
| 129 | +Confirm there is no outbound connectivity on your VM. |
| 130 | +
|
| 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) |
| 133 | +
|
| 134 | +2. Curl an endpoint (e.g., `curl www.google.com` ) |
| 135 | +
|
| 136 | +The connection will eventually time out: |
| 137 | +
|
| 138 | +```bash |
| 139 | +curl: (28) Failed to connect to www.google.com port 80 after 129976 ms: Couldn't connect to server |
| 140 | +``` |
0 commit comments