mirror of
https://github.com/YuzuZensai/netbird-kubernetes-operator.git
synced 2026-09-13 10:49:15 +00:00
Add support for private gateway (#154)
This change adds support for TCPRoutes when using a private gateway class. This is similar to annotating services today. It also moves the gateway classes to the Helm chart as it makes things a lot simpler for the end user as they no longer have to define them. Signed-off-by: Philip Laine <philip.laine@gmail.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
# Gateway API
|
||||
|
||||
This example walks you through how to setup a Netbird Gateway API and expose Nginx through the Netbird proxy service.
|
||||
|
||||
Build image locally and load it into Kind.
|
||||
```shell
|
||||
make docker-build IMG=docker.io/netbirdio/kubernetes-operator:dev
|
||||
kind load docker-image docker.io/netbirdio/kubernetes-operator:dev
|
||||
```
|
||||
|
||||
Install the Gateway API CRDs.
|
||||
|
||||
```shell
|
||||
kubectl apply --server-side -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.5.0/experimental-install.yaml
|
||||
```
|
||||
|
||||
Create Netbird namespace and API key secret.
|
||||
|
||||
```shell
|
||||
kubectl create namespace netbird
|
||||
kubectl -n netbird create secret generic netbird-mgmt-api-key --from-literal NB_API_KEY=${NETBIRD_API_KEY}
|
||||
```
|
||||
|
||||
Install the Kubernetes Operator. Make sure to use the customized values to enable Gateway API support. This assumes you have already created a secret containing a Netbird API key.
|
||||
|
||||
```shell
|
||||
helm upgrade --install --create-namespace -f ./examples/gateway-api/values.yaml -n netbird netbird-operator ./helm/kubernetes-operator
|
||||
```
|
||||
|
||||
Create the gateway along with the routing peer. This will deploy Netbird clients that route traffic into the cluster.
|
||||
|
||||
```shell
|
||||
kubectl apply -f ./examples/gateway-api/gateway.yaml
|
||||
```
|
||||
|
||||
Deploy the test Nginx application along with a HTTPRoute. The HTTPRoute will expose the service through Netbirds public proxy.
|
||||
|
||||
```shell
|
||||
kubectl apply -f ./examples/gateway-api/nginx.yaml
|
||||
```
|
||||
|
||||
Expose the Kubernetes API server service as a network resource in Netbird.
|
||||
|
||||
```shell
|
||||
kubectl apply -f ./examples/gateway-api/kubernetes.yaml
|
||||
```
|
||||
@@ -0,0 +1,30 @@
|
||||
apiVersion: netbird.io/v1
|
||||
kind: NBRoutingPeer
|
||||
metadata:
|
||||
name: netbird
|
||||
namespace: netbird
|
||||
spec: {}
|
||||
---
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: private
|
||||
namespace: netbird
|
||||
spec:
|
||||
gatewayClassName: netbird-private
|
||||
listeners:
|
||||
- protocol: gateway.netbird.io/NBRoutingPeer
|
||||
name: netbird
|
||||
port: 1
|
||||
---
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: Gateway
|
||||
metadata:
|
||||
name: public
|
||||
namespace: netbird
|
||||
spec:
|
||||
gatewayClassName: netbird-public
|
||||
listeners:
|
||||
- protocol: gateway.netbird.io/NBRoutingPeer
|
||||
name: netbird
|
||||
port: 1
|
||||
@@ -0,0 +1,13 @@
|
||||
apiVersion: gateway.networking.k8s.io/v1alpha2
|
||||
kind: TCPRoute
|
||||
metadata:
|
||||
name: kubernetes
|
||||
namespace: default
|
||||
spec:
|
||||
parentRefs:
|
||||
- name: private
|
||||
namespace: netbird
|
||||
rules:
|
||||
- backendRefs:
|
||||
- name: kubernetes
|
||||
port: 443
|
||||
@@ -0,0 +1,61 @@
|
||||
apiVersion: gateway.networking.k8s.io/v1
|
||||
kind: HTTPRoute
|
||||
metadata:
|
||||
name: nginx
|
||||
namespace: default
|
||||
labels:
|
||||
app: nginx
|
||||
spec:
|
||||
hostnames:
|
||||
- nginx-test-app.eu1.netbird.services
|
||||
parentRefs:
|
||||
- name: public
|
||||
namespace: netbird
|
||||
rules:
|
||||
- backendRefs:
|
||||
- name: nginx
|
||||
port: 80
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: nginx
|
||||
namespace: default
|
||||
labels:
|
||||
app: nginx
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: nginx
|
||||
strategy:
|
||||
rollingUpdate:
|
||||
maxSurge: 25%
|
||||
maxUnavailable: 25%
|
||||
type: RollingUpdate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
spec:
|
||||
containers:
|
||||
- image: nginx
|
||||
imagePullPolicy: Always
|
||||
name: nginx
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: nginx
|
||||
namespace: default
|
||||
labels:
|
||||
app: nginx
|
||||
spec:
|
||||
type: ClusterIP
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
protocol: TCP
|
||||
targetPort: 80
|
||||
selector:
|
||||
app: nginx
|
||||
@@ -0,0 +1,14 @@
|
||||
gatewayAPI:
|
||||
enabled: true
|
||||
|
||||
webhook:
|
||||
enableCertManager: false
|
||||
|
||||
netbirdAPI:
|
||||
keyFromSecret:
|
||||
name: "netbird-mgmt-api-key"
|
||||
key: "NB_API_KEY"
|
||||
|
||||
operator:
|
||||
image:
|
||||
tag: dev
|
||||
Reference in New Issue
Block a user