Skip to content

Commit

Permalink
doc: Kubernetes
Browse files Browse the repository at this point in the history
  • Loading branch information
nberlee committed Jul 3, 2023
1 parent dfbd2c6 commit 7deb69d
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/Kubernetes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Kubernetes deployment

## Prepare network
All vlans that need to be reflected should be tagged to the kubernetes node(s) interface. If you only want to to run the reflector exclusively on one node, you can use the `nodeName` in the deployment yaml.

## Create configmap
The configmap is created by kustomize. Please make sure to change the `config.toml` to your needs. See the [config.md](../config.md) for detailed explaination.

## Cilium
If you are running Cilium as your CNI, you need to add the following to your cilium configmap:
```yaml
vlan-bpf-bypass: "0"
```
This will prevent cilium from dropping tagged packets.
## Deploy
The manifests in manifests/ will create a namespace, deployment and configmap. The deployment will run on the host network, so it can access the vlans. The configmap is mounted as a volume in the container.
```bash
kubectl apply -k manifests/
```
13 changes: 13 additions & 0 deletions docs/Kubernetes/manifests/cnp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
name: "deny-all"
namespace: mdns
spec:
endpointSelector:
matchLabels:
app: bonjour
egress:
- {}
ingress:
- {}
34 changes: 34 additions & 0 deletions docs/Kubernetes/manifests/config/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
net_interface = "eth0"

[devices]

[devices."71:27:06:20:A7:E6"]
description = "Bedroom TV"
origin_pool = 100
shared_pools = [101, 103]

[devices."01:10:B1:E1:69:98"]
description = "Onkyo amplifier"
origin_pool = 100
shared_pools = [101, 103]

[devices."00:04:4B:5D:F2:D3"]
description = "NVidia Shield"
origin_pool = 100
shared_pools = [101, 103]

[devices."DC:A6:32:2B:31:19"]
description = "Volumio bathroom"
origin_pool = 103
shared_pools = [101]

[vlan]

[vlan.100]
ip_source = "192.168.100.2"

[vlan.101]
ip_source = "192.168.101.2"

[vlan.103]
ip_source = "192.168.103.2"
55 changes: 55 additions & 0 deletions docs/Kubernetes/manifests/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: bonjour-reflector
namespace: mdns
spec:
replicas: 1
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
selector:
matchLabels:
app: bonjour
template:
metadata:
labels:
app: bonjour
spec:
hostNetwork: true
# nodeName: talos-home-4
serviceAccountName: bonjour-reflector
containers:
- image: ghcr.io/nberlee/bonjour-reflector:main
imagePullPolicy: Always
name: bonjour-reflector
# command:
# - "/bonjour-reflector"
# - "-verbose"
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
add:
- NET_RAW
drop:
- ALL
seccompProfile:
type: RuntimeDefault
resources:
limits:
memory: 150Mi
requests:
cpu: 200m
memory: 150Mi
volumeMounts:
- name: config
mountPath: "/config.toml"
subPath: config.toml
readOnly: true
volumes:
- name: config
configMap:
name: bonjour-reflector-config
13 changes: 13 additions & 0 deletions docs/Kubernetes/manifests/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace: mdns

resources:
- namespace.yaml
- serviceaccount.yaml
- deployment.yaml
# - cnp.yaml


configMapGenerator:
- name: bonjour-reflector-config
files:
- config/config.toml
7 changes: 7 additions & 0 deletions docs/Kubernetes/manifests/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Namespace
metadata:
creationTimestamp: null
name: mdns
spec: {}
status: {}
8 changes: 8 additions & 0 deletions docs/Kubernetes/manifests/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: ServiceAccount
metadata:
creationTimestamp: null
name: bonjour-reflector
namespace: mdns

automountServiceAccountToken: false

0 comments on commit 7deb69d

Please sign in to comment.