Compare commits

...

4 Commits

Author SHA1 Message Date
8da806d657 Added filebrowser 2026-01-11 16:23:57 +01:00
10bf4567e1 README update with Matrix Synapse and Element-web 2025-12-22 10:45:34 +01:00
e3b6d23d55 Matrix synapse deployment 2025-12-22 10:45:24 +01:00
45b4768910 Element-web manifests 2025-12-22 10:45:12 +01:00
15 changed files with 652 additions and 1 deletions

77
Datastore/deployment.yaml Normal file
View File

@@ -0,0 +1,77 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: data-deployment
labels:
project: data
spec:
replicas: 1
selector:
matchLabels:
pod-project: data
template:
metadata:
labels:
pod-project: data
spec:
automountServiceAccountToken: false # Container doesn't need service account token
securityContext:
appArmorProfile:
type: RuntimeDefault
fsGroup: 101
containers:
- name: filebrowser
image: filebrowser/filebrowser
imagePullPolicy: IfNotPresent
volumeMounts:
- name: data-the-data
mountPath: /srv
- name: fb-db
mountPath: /database
- name: fb-conf
mountPath: /config
securityContext:
runAsUser: 101
runAsGroup: 101
runAsNonRoot: true
- name: data
image: nginx:alpine
imagePullPolicy: IfNotPresent
ports:
- containerPort: 52345
name: http
protocol: TCP
resources:
requests:
cpu: 10m
memory: 32Mi
volumeMounts:
- name: data-config
mountPath: /etc/nginx
- name: data-the-data
mountPath: /data
volumes:
- name: data-config
persistentVolumeClaim:
claimName: data-config-pvc
readOnly: true
- name: data-the-data
nfs:
server: 1.2.3.4
path: /path/to/mount
readOnly: false
- name: fb-db
persistentVolumeClaim:
claimName: fb-db-pvc
readOnly: false
- name: fb-conf
persistentVolumeClaim:
claimName: fb-conf-pvc
readOnly: false

68
Datastore/netPolicy.yaml Normal file
View File

@@ -0,0 +1,68 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: data-networkpolicy
labels:
project: data
spec:
podSelector:
matchLabels:
pod-project: data
egress:
# Allow all egress
# - {}
# Allow egress only to public networks
# - to:
# - namespaceSelector:
# matchLabels:
# kubernetes.io/metadata.name: kube-system
# podSelector:
# matchLabels:
# k8s-app: kube-dns
# ports:
# - protocol: UDP
# port: 53
# - protocol: TCP
# port: 53
# - to:
# - ipBlock:
# cidr: 0.0.0.0/0
# except:
# - 10.0.0.0/8
# - 172.16.0.0/12
# - 192.168.0.0/16
# ports:
# - protocol:
# ingress:
# This port is for public facing nginx for downloading
# - from:
# - namespaceSelector:
# matchLabels:
# ns-name: <NS>
# podSelector:
# matchLabels:
# podDomain: <reverseProxyPodLabel>
# ports:
# - protocol: TCP
# port: 52345
# This is only for internal data drop-in browser
# - from:
# - namespaceSelector:
# matchLabels:
# ns-name: <NS>
# podSelector:
# matchLabels:
# podDomain: <reverseProxyPodLabel>
# ports:
# - protocol: TCP
# port: 80
policyTypes:
- Ingress
- Egress

56
Datastore/pvc.yaml Normal file
View File

@@ -0,0 +1,56 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data-config-pvc
labels:
project: data
spec:
# https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes-1
accessModes:
# - ReadOnlyMany
# - ReadWriteOnce
- ReadWriteMany
resources:
requests:
storage: 32Mi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: fb-db-pvc
labels:
project: data
spec:
# https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes-1
accessModes:
# - ReadOnlyMany
- ReadWriteOnce
# - ReadWriteMany
resources:
requests:
storage: 2Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: fb-conf-pvc
labels:
project: data
spec:
# https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes-1
accessModes:
# - ReadOnlyMany
- ReadWriteOnce
# - ReadWriteMany
resources:
requests:
storage: 128Mi

30
Datastore/service.yaml Normal file
View File

@@ -0,0 +1,30 @@
apiVersion: v1
kind: Service
metadata:
name: data-service
labels:
project: data
spec:
selector:
pod-project: data
# This isn't used as Ingress is doing TLS termination
# type: LoadBalancer
type: ClusterIP
ports:
- name: data-ngx
protocol: TCP
port: 52345 # <- port that will be exposed
# targetPort: 3000
# - name: anubis-data
# protocol: TCP
# port: 8080 # <- port that will be exposed
# targetPort: 8080
# # targetPort: 3000
- name: filebrowser-webgui
protocol: TCP
port: 80 # <- port that will be exposed
# targetPort: 3000

View File

@@ -0,0 +1,21 @@
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: matrix-landing-page-autoscaler
labels:
matrix-service: webclient
scaleThing: matrix-webpage
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: matrix-landing-page-deployment
minReplicas: 1
maxReplicas: 4
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50

View File

@@ -0,0 +1,19 @@
apiVersion: v1
kind: Pod
metadata:
name: config-uploader-matrix-landing-page
spec:
containers:
- name: uploader-matrix-landing-page
image: alpine:latest
command: [ "sleep", "6000" ]
stdin: true
tty: true
volumeMounts:
- mountPath: /data
name: config-volume
volumes:
- name: config-volume
persistentVolumeClaim:
claimName: matrix-landing-page-pvc

View File

@@ -0,0 +1,44 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: matrix-landing-page-deployment
labels:
matrix-service: webclient
spec:
replicas: 1
selector:
matchLabels:
matrix-service: webclient
template:
metadata:
labels:
matrix-service: webclient
spec:
containers:
- name: matrix-landing-page
image: nginx:stable
ports:
- containerPort: 80
name: http
protocol: TCP
# imagePullPolicy: IfNotPresent
volumeMounts:
- name: nginx-root
mountPath: /usr/share/nginx/html
resources:
requests:
memory: "64Mi"
cpu: "25m"
limits:
memory: "96Mi"
cpu: "75m"
volumes:
- name: nginx-root
persistentVolumeClaim:
claimName: matrix-landing-page-pvc
readOnly: true

View File

@@ -0,0 +1,37 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: matrix-landing-page-networkpolicy
spec:
podSelector:
matchLabels:
matrix-service: webclient
egress:
# Allow all egress
# - {}
# Allow egress only to public networks
# - to:
# - ipBlock:
# cidr: 0.0.0.0/0
# except:
# - 10.0.0.0/8
# - 172.16.0.0/12
# - 192.168.0.0/16
ingress:
# - from:
# - namespaceSelector:
# matchLabels:
# ns-name: <NS>
# podSelector:
# matchLabels:
# podDomain: <reverseProxyPodLabel>
# ports:
# - protocol: TCP
# port: 80
policyTypes:
- Ingress
- Egress

16
MatrixLanding/pvc.yaml Normal file
View File

@@ -0,0 +1,16 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: matrix-landing-page-pvc
labels:
matrix-page: landing-page
matrix-page-domain: your.domain.example
spec:
# https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes-1
accessModes:
# - ReadOnlyMany
# - ReadWriteOnce
- ReadWriteMany
resources:
requests:
storage: 356Mi

View File

@@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
name: matrix-landing-page-service
labels:
matrix-service: webclient
spec:
selector:
matrix-service: webclient
# This isn't used as Ingress is doing TLS termination
# type: LoadBalancer
type: ClusterIP
ports:
- name: matrix-landing-page-http
appProtocol: TCP
port: 80 # <- port that will be exposed

View File

@@ -0,0 +1,58 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: matrix-server-deployment
labels:
matrix-service: server
spec:
replicas: 1
selector:
matchLabels:
matrix-service: server
template:
metadata:
labels:
matrix-service: server
spec:
containers:
- name: matrix-server
image: matrixdotorg/synapse:latest
# imagePullPolicy: IfNotPresent
ports:
- containerPort: 8008
name: http-matrix
protocol: TCP
readinessProbe:
failureThreshold: 3
httpGet:
path: /_matrix/static
port: 8008
scheme: HTTP
initialDelaySeconds: 5
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 2
livenessProbe:
failureThreshold: 3
initialDelaySeconds: 45
periodSeconds: 5
successThreshold: 1
httpGet:
path: /_matrix/static
port: 8008
scheme: HTTP
timeoutSeconds: 1
volumeMounts:
- name: matrix-synapse-data
mountPath: /data
volumes:
- name: matrix-synapse-data
persistentVolumeClaim:
claimName: matrix-synapse-data-pvc
readOnly: false

View File

@@ -0,0 +1,60 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: matrix-server-networkpolicy
spec:
podSelector:
matchLabels:
matrix-service: server
egress:
# Allow all egress
# - {}
- to:
- ipBlock:
# Address of a PSQL server
cidr: 1.2.3.4/32
ports:
- protocol: TCP
port: 5432
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kube-system
podSelector:
matchLabels:
k8s-app: kube-dns
ports:
- protocol: UDP
port: 53
- protocol: TCP
port: 53
- to:
- ipBlock:
cidr: 0.0.0.0/0
except:
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
ingress:
# optional reverse proxy
# - from:
# - namespaceSelector:
# matchLabels:
# ns-name: <NS>
# podSelector:
# matchLabels:
# podDomain: <podLabel>
# ports:
# - protocol: TCP
# port: 8008
policyTypes:
- Ingress
- Egress

15
MatrixSynapse/pvc.yaml Normal file
View File

@@ -0,0 +1,15 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: matrix-synapse-data-pvc
labels:
matrix-server-domain: example.me
spec:
# https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes-1
accessModes:
# - ReadOnlyMany
- ReadWriteOnce
# - ReadWriteMany
resources:
requests:
storage: 16Gi

View File

@@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
name: matrix-server-service
labels:
matrix-service: server
spec:
selector:
matrix-service: server
# This isn't used as Ingress is doing TLS termination
# type: LoadBalancer
type: ClusterIP
ports:
- name: matrix-server-http
appProtocol: TCP
port: 8008 # <- port that will be exposed

114
README.md
View File

@@ -8,6 +8,10 @@ run ```kubectl apply -f /path/to/files/. -n <yourNameSpace>```
1. [Unbound](#Unbound)
2. [ConvertX](#ConvertX)
3. [PiHole StatefullSet](#PiHole)
4. [Matrix Synapse](#MatrixSynapse)
5. [Element](#MatrixElement)
6. [Datastore](#Data)
### Unbound
@@ -59,3 +63,113 @@ What to change:
Note that dnsmasq-extra-data-pvc is for storing extra data about local domains to redirect a domain and all subdomain. It works like so
Redirect int.example.me and *.int.example.me to 4.3.2.1
### MatrixSynapse
What to change:
1. in pvc.yaml change line 6 to you domain or remove that label.
2. in service.yaml set loadBalancerIP if you don't use reverse proxy.
3. in netPolicy.yaml set correct Postgresql databate address on line 17.
4. also in netPolicy.yaml adjust or remove lines 45 to 55
### MatrixElement
Here there is a bit of work to do to get everything working.
First of all download the latest [element-web](https://github.com/element-hq/element-web) version and unpack it. Thereafter configure config.json.
After doing that start temporary pod for copying over files with ``` kubectl -f copyFilesToPVCDeploy.yaml```
After it starts run ```kubectl cp ./YourElementWebFolder/ YourNameSpace/uploader-matrix-landing-page:/data/```
after that you can remove the copyFilesToPVCDeploy.yaml file and run ```kubectl apply -f /path/to/files/. -n <yourNameSpace>```
### Data
You need to change NFS share for storing shared files. Do this in deployment.yaml on line 65 and 66
This is a combination of Nginx for serving static content like files or images, and filebrowser which is a container that has a webGUI for browsing, adding and/or removing images from a folder.
Combined together webGUI for filebrowser can be placed behind an internal-only reverse proxy with internal-only domain. Nginx on the other hand can be published on the internet.
Port 80 is used for filebrowser webGUI. Port 52345 is used for exposing Nginx to the internet.
#### Data-nginx-config
Here is how a nginx-config can look like
´´´
user nginx;
worker_processes auto;
worker_cpu_affinity auto;
pid /run/nginx.pid;
error_log /var/log/nginx/error.log;
events {
worker_connections 4096;
multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
##
# Gzip Settings
##
gzip on;
application/javascript text/xml application/xml application/xml+rss text/javascript;
server {
listen 52345;
server_name _;
root /etc/nginx/html;
location / {
index index.html;
}
location /assets {
alias /data/;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}
}
}
´´´