Commit Graph
113 Commits
Author SHA1 Message Date
Philip LaineandGitHub ade9a53045 Fix flaky e2e tests (#120)
This change fixes flaky e2e tests with two changes. The first is that
the manager container is checked for ready condition rather than
running. The second is that the webhook server has been registered as
part of the health check to verify it is running before reporting ready
state.

Signed-off-by: Philip Laine <philip.laine@gmail.com>
2026-03-10 21:31:54 +01:00
Philip LaineandGitHub 60ce12c74e Update Netbird dependency and Golang version (#112)
This change updates the Netbird dependency to the latest version to
enabled #111 to be implemented with future API additions. This change
requires updating the Go version as the upstream dependency requires it.

An interesting aspect that was required was to pin the dex dependency to
v2. It seems like the Netbird go.mod is doing something unexpected with
their version.

Signed-off-by: Philip Laine <philip.laine@gmail.com>
2026-03-03 10:31:38 +01:00
David FischerandGitHub e228fad4fe fix: rendering of protocols and ports in NBPolicy (#96)
Minor adjustment to the NBPolicy template to make ports and protocols
render as lists instead of strings.

Previously a values file like

```yaml
policies:
  demo-policy:
    name: "Demo Policy"
    sourceGroups:
      - demogroup
      - demogroup2
    ports:
      - 443
      - 80
    protocols:
      - tcp
      - udp
```

would result in a rendered manifest like

```yaml
spec:
  bidirectional: false
  name: Demo Policy
  ports:
    - 80 443
  protocols:
    - tcp udp
  sourceGroups:
    - demogroup
    - demogroup2
```

(.spec.ports[0]: expected numeric (int or float), got string)
2026-03-03 08:58:50 +01:00
GideonandGitHub 38affd24c5 fix: add list and watch verbs for nbroutingpeers in ClusterRole (#107)
## Problem

The `netbird-operator-config` ClusterRole only grants `get` on
`nbroutingpeers`, but the `kubernetes-service-expose` job uses a
reflector/informer internally which requires both `list` and `watch` to
establish a watch stream. This results in the following error at
runtime:

```
E0218 16:28:42.344838       1 reflector.go:204] "Failed to watch" err="failed to list *unstructured.Unstructured: nbroutingpeers.netbird.io \"router\" is forbidden: User \"system:serviceaccount:netbird:netbird-operator-config\" cannot list resource \"nbroutingpeers\" in API group \"netbird.io\" in the namespace \"netbird\""
```

I noticed this error when I enabled the `kubernetesAPI.enabled` flag in
the netbird-oberator-config helm chart.

## Fix

Add `list` and `watch` verbs to the `nbroutingpeers` rule in the
ClusterRole, consistent with how other `netbird.io` resources are
already granted in the same role.

## Related

Similar issue was reported previously in #24 for a different service
account.
2026-03-03 08:32:41 +01:00
Tamer FahmyandGitHub f6765c1cf4 Add missing envsubst utility (#101) (#102)
Fixes: #101
2026-03-03 08:30:27 +01:00
JanandGitHub cbe0e3a2a1 Add optional privileged mode to NBRoutingPeerSpec (#92)
Introduced a new optional boolean field `Privileged` in the
`NBRoutingPeerSpec` to allow deployments to specify if containers should
run in privileged mode. Updated the CRD, Helm templates, and controller
logic to support this feature.

A new function `buildSecurityContext` was added to handle the creation
of the appropriate security context based on the `Privileged` setting.
Tests were updated to cover scenarios where privileged mode is enabled,
disabled, or unspecified. This change allows more granular control over
container security settings, potentially increasing compatibility with
certain workloads that require elevated privileges.

see https://github.com/netbirdio/kubernetes-operator/issues/90

**Note:**
I am not a Go developer and have no experience with this architecture. I
may have overlooked some things.
2026-03-03 08:29:52 +01:00
Philip LaineandGitHub 8ec7c8ded8 Update Golang CI Lint to the latest version (#113)
This change updates Golang CI Lint to the latest version and fixes new
linter errors that came along with the update.

These changes were split out of #112 and are required to update the Go
version.
2026-02-27 19:07:58 +01:00
Bethuel MmbagaandGitHub de74776007 Bump kubernetes-operator chart appVersion to 0.2.2 (#110) 2026-02-26 14:06:30 +03:00
VladandGitHub 5abb241ffa fix port mapping sort (#108) 2026-02-25 16:39:29 +01:00
Bethuel MmbagaandGitHub 19650e6657 Bump kubernetes-operator chart appVersion to 0.2.1 (#100) 2026-02-12 18:45:07 +03:00
Bethuel MmbagaandGitHub 5fb144559c Add support for running as a init sidecar container (#99)
Adds support for injecting the client as a [sidecar
container](https://kubernetes.io/docs/concepts/workloads/pods/sidecar-containers/)
using the `netbird.io/init-sidecar: "true"` pod annotation.
2026-02-11 15:20:52 +03:00
Bethuel MmbagaandGitHub d548240320 Bump netbird-operator-config chart appVersion to 0.2.0 (#98) 2026-02-04 15:08:13 +01:00
Tomás MotaandGitHub 54403eb901 fix potential panic when acessing empty list (#88)
while fixing #87, noticed a couple lines down that if the containers
spec has more than 1 container, the code probably intends to set
Spec.Containers to a list with a single container, but is instead
setting it to an empty list. The very next lines are trying to access
the 1st element of this empty list, which will result in a panic
2025-12-29 21:56:37 +01:00
Tomás MotaandGitHub 54c3139ee2 Remove pod label overwriting (#87)
Pod labels are being set in line 242, and the`podLabels` variable
already contains the extra `"app.kubernetes.io/name": "netbird-router"`
label, so lines 244-246 are effectively just overwriting any labels that
have been set in the crd.

This is blocking us from using this crd because we need a label
disabling istio injection for the peer to work correctly.
2025-12-29 21:53:18 +01:00
Maycon SantosandGitHub 731a3c9ea1 Update Dockerfile.kubectl (#89) 2025-12-17 13:24:51 +01:00
M. EssamandGitHub c86ef5c530 Fix helm chart releaser multiple charts separate version (#84) 2025-12-17 11:23:52 +01:00
M. EssamandGitHub f1b131be7d Refactor uninstallation process (#74)
Docs PR: https://github.com/netbirdio/docs/pull/457

Changes:
* Split kubernetes-operator Chart to operator only chart
(kubernetes-operator) and configuration chart (netbird-operator-config)
* Remove delete validation webhooks for non-needed resources
* Allow abandoning Groups when still linked to a resource for over a
minute after deletion
* Fix duplciate Network Resource retrying heavily
* Fix SetupKey creation duplication
* Skip deleting routing peer since deleting network automatically
deletes it anyway
2025-11-25 20:36:17 +02:00
Christian De LeonandGitHub 6c855c5d4e Fix: extra-dns-labels not being applied to pods (#82)
# Fix: NetBird extra-dns-labels not being applied to pods

## Problem

The `netbird.io/extra-dns-labels` annotation was not working when
applied to pods. Despite the webhook detecting the annotation and adding
it to the NetBird container configuration, the extra DNS labels were not
appearing in the NetBird UI or being applied to registered peers.

## Root Cause

The pod webhook had two issues:

1. **Invalid setup key argument**: The webhook was passing
`--setup-key-file /etc/nbkey` to the NetBird client, but this file path
was never created. The setup key was already being passed via the
`NB_SETUP_KEY` environment variable, making the file-based approach
unnecessary and causing confusion in the client startup.

2. **NetBird CLI flag bug**: The webhook was using the
`--extra-dns-labels` command line flag, but NetBird has a known issue
([netbirdio/netbird#4282](https://github.com/netbirdio/netbird/issues/4282))
where this flag is not properly processed. The workaround is to use the
`NB_EXTRA_DNS_LABELS` environment variable instead.

## Solution

- Removed the `--setup-key-file` argument entirely since the setup key
is provided via environment variable
- Removed all command line arguments from the NetBird container
- Added `NB_EXTRA_DNS_LABELS` environment variable when the
`netbird.io/extra-dns-labels` annotation is present
- NetBird client now uses only environment variables for configuration,
which is more reliable and matches the pattern used by the NBRoutingPeer
controller

## Changes

**Before:**
```go
args := []string{
    "--setup-key-file", "/etc/nbkey",
    "-m", managementURL,
}
// ... add extra-dns-labels to args
```

**After:**
```go
envVars := []corev1.EnvVar{
    {Name: "NB_SETUP_KEY", ValueFrom: ...},
    {Name: "NB_MANAGEMENT_URL", Value: managementURL},
}
// ... conditionally add NB_EXTRA_DNS_LABELS to envVars
```

## Testing

1. Create a deployment with the `netbird.io/setup-key` and
`netbird.io/extra-dns-labels` annotations:
```yaml
annotations:
  netbird.io/setup-key: my-setup-key
  netbird.io/extra-dns-labels: "my-label,another-label"
```

2. Verify the environment variable is set:
```bash
kubectl get pod <pod-name> -o jsonpath='{.spec.containers[?(@.name=="netbird")].env[*]}' | jq .
```

3. Check the NetBird UI to confirm the extra DNS labels appear on the
registered peer

4. Verify the NetBird container logs show successful registration
without errors

## References

- NetBird issue: https://github.com/netbirdio/netbird/issues/4282
- Documentation: [Extra DNS
Labels](https://docs.netbird.io/how-to/routing-traffic-to-private-networks#extra-dns-labels)

---

This fix ensures that the `netbird.io/extra-dns-labels` annotation works
as documented and provides a more robust configuration method by using
environment variables consistently across all NetBird deployments in the
operator.
2025-11-24 19:00:58 +02:00
M. EssamandGitHub d8eb7cb513 Bump Helm appVersion to 0.1.5 (#81) 2025-11-23 12:05:26 +02:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
408e20f999 Bump golang.org/x/net from 0.33.0 to 0.38.0 (#75)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.33.0 to
0.38.0.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/golang/net/commit/e1fcd82abba34df74614020343be8eb1fe85f0d9"><code>e1fcd82</code></a>
html: properly handle trailing solidus in unquoted attribute value in
foreign...</li>
<li><a
href="https://github.com/golang/net/commit/ebed060e8f30f20235f74808c22125fd86b15edd"><code>ebed060</code></a>
internal/http3: fix build of tests with GOEXPERIMENT=nosynctest</li>
<li><a
href="https://github.com/golang/net/commit/1f1fa29e0a46fffe18c43a9da8daa5a0b180dfa9"><code>1f1fa29</code></a>
publicsuffix: regenerate table</li>
<li><a
href="https://github.com/golang/net/commit/12150816f701c912a32a376754ab28dd3878833a"><code>1215081</code></a>
http2: improve error when server sends HTTP/1</li>
<li><a
href="https://github.com/golang/net/commit/312450e473eae9f9e6173ad895c80bc5ea2f79ad"><code>312450e</code></a>
html: ensure &lt;search&gt; tag closes &lt;p&gt; and update tests</li>
<li><a
href="https://github.com/golang/net/commit/09731f9bf919b00b344c763894cd1920b3d96d90"><code>09731f9</code></a>
http2: improve handling of lost PING in Server</li>
<li><a
href="https://github.com/golang/net/commit/55989e24b972a90ab99308fdc7ea1fb58a96fef1"><code>55989e2</code></a>
http2/h2c: use ResponseController for hijacking connections</li>
<li><a
href="https://github.com/golang/net/commit/2914f46773171f4fa13e276df1135bafef677801"><code>2914f46</code></a>
websocket: re-recommend gorilla/websocket</li>
<li><a
href="https://github.com/golang/net/commit/99b3ae0643f9a2f9d820fcbba5f9e4c83b23bd48"><code>99b3ae0</code></a>
go.mod: update golang.org/x dependencies</li>
<li><a
href="https://github.com/golang/net/commit/85d1d54551b68719346cb9fec24b911da4e452a1"><code>85d1d54</code></a>
go.mod: update golang.org/x dependencies</li>
<li>Additional commits viewable in <a
href="https://github.com/golang/net/compare/v0.33.0...v0.38.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=golang.org/x/net&package-manager=go_modules&previous-version=0.33.0&new-version=0.38.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/netbirdio/kubernetes-operator/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-10-31 15:03:54 +01:00
M. EssamandGitHub 4b98bf9ff9 Add feature to add default labels to all resources (#62)
Fixes #41 
Thanks to @mhartmann-jaconi for the Helm changes in #42
2025-10-07 13:59:50 +03:00
dependabot[bot]andGitHub 1b36287705 Bump golang.org/x/oauth2 from 0.23.0 to 0.27.0 (#64)
Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from
0.23.0 to 0.27.0
2025-08-19 16:21:15 +03:00
M Essam Hamed 20b3ba60ba Add optional Volume mounting for Client containers 2025-08-10 10:25:13 +03:00
M Essam Hamed 2606b87173 Add uninstallation doc to README 2025-08-08 14:14:25 +03:00
athulandM. Essam c38b37202b fix(template): properly indent all spec fields using toYaml and nindent 4 in routingpeers.yaml 2025-08-08 13:26:04 +03:00
athulandM. Essam 877c894248 Add support for tolerations, nodeSelector, and resources in NBRoutingPeer deployment spec 2025-08-07 21:58:39 +03:00
rarroubaandM. Essam a24beb58d9 fix: typo in spec of Job kubernetes-service-expose 2025-08-05 19:39:20 +03:00
Maycon SantosandGitHub 43065a2ade chart version 0.1.12 (#56) 2025-07-17 15:10:37 +02:00
David FryandGitHub 2dbe491081 customize failure policy for webhooks (#55) 2025-07-17 09:35:35 +02:00
Maycon SantosandGitHub 48c2f42b00 add support to routing client image (#49) 2025-07-10 12:57:12 +02:00
M. EssamandGitHub 09249b6b62 Fix returning ctrl.Result and error preventing backoff (#50) 2025-07-10 10:52:48 +02:00
Frederic RoggonandGitHub 0cf1dbafd4 [Docs] Typo Fix - removed sentence that does not belong there (#45)
typo fix - removed sentence that does not belong there
2025-05-24 17:08:03 +02:00
M. EssamandGitHub 7b08362a37 Bump chart version to 0.1.10 (#39) 2025-05-02 19:37:36 +02:00
David FryandM. Essam 00d8a6ddfb fix keyfromsecret structure 2025-05-02 14:46:57 +03:00
Maycon SantosandGitHub 6c6557b2fd Bump chart version to 0.1.9 (#37) 2025-05-01 20:53:57 +02:00
David FryandGitHub 18a5b55839 use env entries instead of envFrom (#36)
The reason for this PR is that currently if the secret doesn’t have the
key NB_API_KEY yet at deployment time, the deployment will still run and
pull in an env list that doesn’t include NB_API_KEY since the envFrom
will just pull any and all keys it finds in the secret and makes env
vars out of them. then at a later point, once the NB_API_KEY key is
populated in the secret, one has to bounce the pod to get the key to be
picked up.

if you use the env: valueFrom syntax using a named key, if that named
key doesn’t exist, the deployment should give an error and retry until
the secret key is available
2025-05-01 14:52:03 +02:00
M Essam Hamed 8ff64b433c Add documentation 2025-04-16 14:45:23 +02:00
M Essam Hamed 38445c58fa Add support for policy auto-creation 2025-04-16 14:45:23 +02:00
Mykola DzhamandM. Essam 924f17f525 Fix Job field name 2025-04-13 22:36:59 +02:00
M. EssamandGitHub 3f4137a153 Fix conditional RBAC to be added on NetBird key existence (#26)
Operator checks for existence of NetBird API key to create controllers
for Service, NBResource, NBPolicy ...etc, while the Helm chart checks
for Values.ingress.enabled, this causes crashes if NetBird API Key is
provided but ingress.enabled is set to `false`.

This fixes this discrepancy by checking NetBird API key in Helm instead
of ingress enabled value.

resolves #13
2025-04-07 08:05:39 +02:00
M. EssamandGitHub b06e9b1de2 Add docs for Kubernetes API (#27)
Add simple instruction for exposing kubernetes API as a Network
Resource.
2025-04-07 08:05:26 +02:00
Maycon SantosandGitHub f98f0d7d61 Update chart version 2025-04-01 14:33:12 +02:00
Maycon SantosandGitHub c37b8f7432 fix kubernetes api resource template (#20) 2025-03-31 17:27:42 +02:00
Maycon SantosandGitHub 08ce0a06c9 Update Chart.yaml 2025-03-30 22:58:49 +02:00
Maycon SantosandGitHub d7991ebcf3 Update app version 2025-03-30 22:58:37 +02:00
Maycon SantosandGitHub 3596e902e2 Update Chart.yaml (#19) 2025-03-30 22:15:42 +02:00
c4d73d83b1 Feature/kubernetes api access (#17)
Co-authored-by: M Essam Hamed <github@messam.xyz>
2025-03-30 21:16:44 +02:00
219ee9a0b6 Add support for multiple policies (#16)
Change policy annotation to support comma-separated list of policies.

---------

Co-authored-by: Maycon Santos <mlsmaycon@gmail.com>
2025-03-28 13:50:09 +01:00
M. EssamandGitHub 6a33bffb65 Add unit tests to new controllers and fix minor bugs (#12) 2025-03-28 08:55:41 +01:00
Misha BraginandGitHub ac8348cda6 Add CLA (#15) 2025-03-19 15:12:18 +01:00