|
1 | 1 | # NetBird Kubernetes Operator |
2 | 2 | For easily provisioning access to Kubernetes resources using NetBird. |
3 | 3 |
|
| 4 | +https://github.com/user-attachments/assets/5472a499-e63d-4301-a513-ad84cfe5ca7b |
| 5 | + |
4 | 6 | ## Description |
5 | 7 |
|
6 | 8 | This operator enables easily provisioning NetBird access on kubernetes clusters, allowing users to access internal resources directly. |
7 | 9 |
|
8 | 10 | ## Getting Started |
9 | 11 |
|
10 | 12 | ### Prerequisites |
11 | | -- helm version 3+ |
| 13 | +- (Recommended) helm version 3+ |
12 | 14 | - kubectl version v1.11.3+. |
13 | 15 | - Access to a Kubernetes v1.11.3+ cluster. |
14 | | -- (Optional for Helm chart installation) Cert Manager. |
15 | | - |
16 | | -### To Deploy on the cluster |
| 16 | +- (Recommended) Cert Manager. |
17 | 17 |
|
18 | | -**Using the install.yaml** |
19 | 18 |
|
20 | | -```sh |
21 | | -kubectl create namespace netbird |
22 | | -kubectl apply -n netbird -f https://github.com/netbirdio/kubernetes-operator/releases/latest/manifests/install.yaml |
23 | | -``` |
| 19 | +### Deployment |
| 20 | +> [!NOTE] |
| 21 | +> Helm Installation method is recommended due to automation of multiple settings within the deployment. |
24 | 22 |
|
25 | | -**Using the Helm Chart** |
| 23 | +#### Using Helm |
26 | 24 |
|
| 25 | +1. Add helm repository. |
27 | 26 | ```sh |
28 | 27 | helm repo add netbirdio https://netbirdio.github.io/kubernetes-operator |
29 | | -helm install -n netbird netbird-operator netbirdio/netbird-operator |
30 | 28 | ``` |
| 29 | +2. (Recommended) Install [cert-manager](https://cert-manager.io/docs/installation/#default-static-install). |
| 30 | +1. (Recommended) Create a values.yaml file, check `helm show values netbirdio/kubernetes-operator` for more info. |
| 31 | +1. Install using `helm install --create-namespace -f values.yaml -n netbird netbird-operator netbirdio/kubernetes-operator`. |
31 | 32 |
|
32 | | -For more options, check the default values by running |
33 | | -```sh |
34 | | -helm show values netbirdio/netbird-operator |
35 | | -``` |
| 33 | +#### Using install.yaml |
36 | 34 |
|
37 | | -### To Uninstall |
38 | | -**Using install.yaml** |
| 35 | +> [!IMPORTANT] |
| 36 | +> install.yaml only includes a very basic template for deploying a stripped down version of kubernetes-operator. |
| 37 | +> This excludes any and all configuration for ingress capabilities, and requires cert-manager to be installed. |
39 | 38 |
|
40 | 39 | ```sh |
41 | | -kubectl delete -n netbird -f https://github.com/netbirdio/kubernetes-operator/releases/latest/manifests/install.yaml |
42 | | -kubectl delete namespace netbird |
| 40 | +kubectl create namespace netbird |
| 41 | +kubectl apply -n netbird -f https://raw.githubusercontent.com/netbirdio/kubernetes-operator/refs/heads/main/manifests/install.yaml |
43 | 42 | ``` |
44 | 43 |
|
45 | | -**Using helm** |
46 | | - |
47 | | -```sh |
48 | | -helm uninstall -n netbird netbird-operator |
49 | | -``` |
50 | 44 |
|
51 | 45 | ### Provision pods with NetBird access |
52 | 46 |
|
|
94 | 88 | containers: |
95 | 89 | - image: yourimage |
96 | 90 | name: container |
| 91 | +``` |
| 92 | + |
| 93 | +## Provisioning Networks (Ingress Functionality) |
| 94 | + |
| 95 | +### Granting controller access to NetBird Management |
| 96 | + |
| 97 | +> [!IMPORTANT] |
| 98 | +> NetBird kubernetes operator generates configurations using NetBird API, editing or deleting these configurations in the NetBird console may cause temporary network disconnection until the operator reconciles the configuration. |
| 99 | + |
| 100 | +1. Create a Service User on your NetBird dashboard (Must be Admin). [Doc](https://docs.netbird.io/how-to/access-netbird-public-api#creating-a-service-user). |
| 101 | +1. Create access token for the Service User (Must be Admin). [Doc](https://docs.netbird.io/how-to/access-netbird-public-api#creating-a-service-user). |
| 102 | +1. Add access token to your helm values file under `netbirdAPI.key`. |
| 103 | + 1. Alternatively, provision secret in the same namespace as the operator and set the key `NB_API_KEY` to the access token generated. |
| 104 | + 1. Set `netbirdAPI.keyFromSecret` to the name of the secret created. |
| 105 | +1. Set `ingress.enabled` to `true`. |
| 106 | + 1. Optionally, to provision network immediately, set `ingress.router.enabled` to `true`. |
| 107 | + 1. Optionally, to provision 1 network per kubernetes namespace, set `ingress.namespacedNetworks` to `true`. |
| 108 | +1. Run `helm install` or `helm upgrade`. |
97 | 109 |
|
| 110 | +### Exposing a Service |
| 111 | + |
| 112 | +> [!IMPORTANT] |
| 113 | +> Ingress DNS Resolution requires DNS Wildcard Routing to be enabled, and at least one DNS Nameserver configured for clients. |
| 114 | + |
| 115 | +|Annotation|Description|Default| |
| 116 | +|---|---|---| |
| 117 | +|`netbird.io/expose`|Expose service using NetBird Network Resource|| |
| 118 | +|`netbird.io/groups`|Comma-separated list of group names to assign to Network Resource|`{ClusterName}-{Namespace}-{Service}`| |
| 119 | +|`netbird.io/resource-name`|Network Resource name|`{Namespace}-{Service}`| |
| 120 | +|`netbird.io/policy`|Name of NBPolicy to propagate service ports as destination.|| |
| 121 | +|`netbird.io/policy-ports`|Narrow down exposed ports in policy, leave empty for all ports.|| |
| 122 | +|`netbird.io/policy-protocol`|Narrow down protocol for use in policy, leave empty for all protocols.|| |
| 123 | + |
| 124 | +### Managing Policies |
| 125 | + |
| 126 | +1. Simply add policies under `ingress.policies`, for example. |
| 127 | +```yaml |
| 128 | +ingress: |
| 129 | + policies: |
| 130 | + default: |
| 131 | + name: Kubernetes Default Policy # Required |
| 132 | + description: Default # Optional |
| 133 | + sourceGroups: # Required |
| 134 | + - All |
| 135 | + ports: # Optional, resources annotated 'netbird.io/policy=default' will append to this |
| 136 | + - 443 |
| 137 | + protocols: # Optional, restricts protocols allowed to resources, defaults to ['tcp', 'udp'] |
| 138 | + - tcp |
| 139 | + - udp |
| 140 | + bidirectional: true # Optional, defaults to true |
98 | 141 | ``` |
| 142 | +2. Reference policy in Services using `netbird.io/policy=default`, this will add relevant ports and destination groups to Policy. |
99 | 143 |
|
100 | 144 | ## Contributing |
101 | 145 |
|
|
0 commit comments