|
| 1 | +# Usage |
| 2 | + |
| 3 | +## Provision pods with NetBird access |
| 4 | + |
| 5 | +1. Create a Setup Key in your [NetBird console](https://docs.netbird.io/how-to/register-machines-using-setup-keys#using-setup-keys). |
| 6 | +1. Create a Secret object in the namespace where you need to provision NetBird access (secret name and field can be anything). |
| 7 | +```yaml |
| 8 | +apiVersion: v1 |
| 9 | +stringData: |
| 10 | + setupkey: EEEEEEEE-EEEE-EEEE-EEEE-EEEEEEEEEEEE |
| 11 | +kind: Secret |
| 12 | +metadata: |
| 13 | + name: test |
| 14 | +``` |
| 15 | +1. Create an NBSetupKey object referring to your secret. |
| 16 | +```yaml |
| 17 | +apiVersion: netbird.io/v1 |
| 18 | +kind: NBSetupKey |
| 19 | +metadata: |
| 20 | + name: test |
| 21 | +spec: |
| 22 | + # Optional, overrides management URL for this setupkey only |
| 23 | + # defaults to https://api.netbird.io |
| 24 | + managementURL: https://netbird.example.com |
| 25 | + secretKeyRef: |
| 26 | + name: test # Required |
| 27 | + key: setupkey # Required |
| 28 | +``` |
| 29 | +1. Annotate the pods you need to inject NetBird into with `netbird.io/setup-key`. |
| 30 | +```yaml |
| 31 | +kind: Deployment |
| 32 | +... |
| 33 | +spec: |
| 34 | +... |
| 35 | + template: |
| 36 | + metadata: |
| 37 | + annotations: |
| 38 | + netbird.io/setup-key: test # Must match the name of an NBSetupKey object in the same namespace |
| 39 | +... |
| 40 | + spec: |
| 41 | + containers: |
| 42 | +... |
| 43 | +``` |
| 44 | + |
| 45 | +## Provisioning Networks (Ingress Functionality) |
| 46 | + |
| 47 | +### Granting controller access to NetBird Management |
| 48 | + |
| 49 | +> [!IMPORTANT] |
| 50 | +> 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. |
| 51 | + |
| 52 | +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). |
| 53 | +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). |
| 54 | +1. Add access token to your helm values file under `netbirdAPI.key`. |
| 55 | + 1. Alternatively, provision secret in the same namespace as the operator and set the key `NB_API_KEY` to the access token generated. |
| 56 | + 1. Set `netbirdAPI.keyFromSecret` to the name of the secret created. |
| 57 | +1. Set `ingress.enabled` to `true`. |
| 58 | + 1. Optionally, to provision network immediately, set `ingress.router.enabled` to `true`. |
| 59 | + 1. Optionally, to provision 1 network per kubernetes namespace, set `ingress.namespacedNetworks` to `true`. |
| 60 | +1. Run `helm install` or `helm upgrade`. |
| 61 | + |
| 62 | +### Exposing a Service |
| 63 | + |
| 64 | +> [!IMPORTANT] |
| 65 | +> Ingress DNS Resolution requires DNS Wildcard Routing to be enabled, and at least one DNS Nameserver configured for clients. |
| 66 | + |
| 67 | +|Annotation|Description|Default| |
| 68 | +|---|---|---| |
| 69 | +|`netbird.io/expose`|Expose service using NetBird Network Resource|| |
| 70 | +|`netbird.io/groups`|Comma-separated list of group names to assign to Network Resource|`{ClusterName}-{Namespace}-{Service}`| |
| 71 | +|`netbird.io/resource-name`|Network Resource name|`{Namespace}-{Service}`| |
| 72 | +|`netbird.io/policy`|Name of NBPolicy to propagate service ports as destination.|| |
| 73 | +|`netbird.io/policy-ports`|Narrow down exposed ports in policy, leave empty for all ports.|| |
| 74 | +|`netbird.io/policy-protocol`|Narrow down protocol for use in policy, leave empty for all protocols.|| |
| 75 | + |
| 76 | +### Managing Policies |
| 77 | + |
| 78 | +1. Simply add policies under `ingress.policies`, for example. |
| 79 | +```yaml |
| 80 | +ingress: |
| 81 | + policies: |
| 82 | + default: |
| 83 | + name: Kubernetes Default Policy # Required |
| 84 | + description: Default # Optional |
| 85 | + sourceGroups: # Required |
| 86 | + - All |
| 87 | + ports: # Optional, resources annotated 'netbird.io/policy=default' will append to this |
| 88 | + - 443 |
| 89 | + protocols: # Optional, restricts protocols allowed to resources, defaults to ['tcp', 'udp'] |
| 90 | + - tcp |
| 91 | + - udp |
| 92 | + bidirectional: true # Optional, defaults to true |
| 93 | +``` |
| 94 | +2. Reference policy in Services using `netbird.io/policy=default`, this will add relevant ports and destination groups to Policy. |
0 commit comments