Add Kubernetes manifests for self-hosted services

This commit is contained in:
2026-06-28 13:53:49 +03:00
committed by ExQz
parent eaba9643a0
commit 3b1998f376
32 changed files with 727 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: immich-server-ingress
namespace: immich # Ensure this matches your app's namespace
annotations:
# Forces Cilium to assign a unique IP from your 10.1.0.x pool
ingress.cilium.io/loadbalancer-mode: "dedicated"
spec:
ingressClassName: cilium
rules:
- host: "photos.mariushome.lt"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
# CHANGE THIS to your actual internal service name
name: immich-server
port:
number: 2283
+12
View File
@@ -0,0 +1,12 @@
apiVersion: "cilium.io/v2alpha1"
kind: CiliumL2AnnouncementPolicy
metadata:
name: "l2-policy"
spec:
externalIPs: true
loadBalancerIPs: true
# Optional: Limit which nodes announce the IPs
nodeSelector:
matchExpressions:
- key: node-role.kubernetes.io/control-plane
operator: DoesNotExist
+8
View File
@@ -0,0 +1,8 @@
apiVersion: "cilium.io/v2"
kind: CiliumLoadBalancerIPPool
metadata:
name: "lan-pool"
spec:
blocks:
- start: "10.1.0.101" # Example range
stop: "10.1.0.199"
+1
View File
@@ -0,0 +1 @@
kubectl cp "C:\Users\MariusBlazys\Desktop\Temp\immich.tar" immich/data-loader-helper:/mnt/data
+21
View File
@@ -0,0 +1,21 @@
kubectl drain master-4gb-hel1-2 --ignore-daemonsets --delete-emptydir-data
sudo reboot
kubectl uncordon master-4gb-hel1-2
-------------------------------------------------------------------------------------------------
kubectl drain ubuntu-4gb-hel1-docker --ignore-daemonsets --delete-emptydir-data
sudo reboot
kubectl uncordon ubuntu-4gb-hel1-docker
-------------------------------------------------------------------------------------------------
kubectl drain woker-1-8gb-hel1-1 --ignore-daemonsets --delete-emptydir-data
sudo reboot
kubectl uncordon woker-1-8gb-hel1-1
-------------------------------------------------------------------------------------------------
+29
View File
@@ -0,0 +1,29 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: registry-ui
namespace: registry
spec:
replicas: 1
selector:
matchLabels:
app: registry-ui
template:
metadata:
labels:
app: registry-ui
spec:
containers:
- name: registry-ui
image: joxit/docker-registry-ui:latest
ports:
- containerPort: 80
env:
- name: NGINX_PROXY_PASS_URL
value: "http://docker-registry.registry.svc.cluster.local:5000"
- name: SINGLE_REGISTRY
value: "true"
- name: DELETE_IMAGES_ENABLED
value: "true" # optional, allows deleting images from UI
- name: SHOW_CONTENT_DIGEST
value: "true" # optional, shows image digests
@@ -0,0 +1,31 @@
# ingress-cilium.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: docker-registry
namespace: registry
annotations:
# Forces Cilium to assign a unique IP from your 10.1.0.x pool
ingress.cilium.io/loadbalancer-mode: "dedicated"
spec:
ingressClassName: cilium # use Cilium as the Ingress controller
rules:
- host: "rg.mariushome.lt"
http:
paths:
# Route registry API (must be before the UI catch-all)
- path: /v2
pathType: Prefix
backend:
service:
name: docker-registry
port:
number: 5000
# Route everything else to the UI
- path: /
pathType: Prefix
backend:
service:
name: registry-ui
port:
number: 80
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: registry-ui
namespace: registry
spec:
selector:
app: registry-ui
ports:
- port: 80
targetPort: 80
@@ -0,0 +1,31 @@
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: docker-registry
namespace: registry
spec:
replicas: 1
selector:
matchLabels:
app: docker-registry
template:
metadata:
labels:
app: docker-registry
spec:
containers:
- name: registry
image: registry:2
ports:
- containerPort: 5000
env:
- name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY
value: /var/lib/registry
volumeMounts:
- name: registry-storage
mountPath: /var/lib/registry
volumes:
- name: registry-storage
persistentVolumeClaim:
claimName: registry-pvc
+13
View File
@@ -0,0 +1,13 @@
# pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: registry-pvc
namespace: registry
spec:
storageClassName: slow
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Gi # adjust as needed
@@ -0,0 +1,12 @@
# service-clusterip.yaml
apiVersion: v1
kind: Service
metadata:
name: docker-registry
namespace: registry
spec:
ports:
- port: 5000
targetPort: 5000
selector:
app: docker-registry
+57
View File
@@ -0,0 +1,57 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: gitea
namespace: gitea
spec:
replicas: 1
selector:
matchLabels:
app: gitea
template:
metadata:
labels:
app: gitea
spec:
containers:
- name: gitea
image: docker.io/gitea/gitea:latest
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 3000
- name: ssh
containerPort: 2222
env:
- name: GITEA__server__HTTP_PORT
value: "3000"
- name: GITEA__server__SSH_PORT
value: "2222"
- name: GITEA__server__SSH_LISTEN_PORT
value: "2222"
- name: GITEA__server__START_SSH_SERVER
value: "true"
- name: GITEA__server__ROOT_URL
value: "https://git.mariushome.lt/"
- name: GITEA__server__DOMAIN
value: "git.mariushome.lt"
- name: GITEA__database__DB_TYPE
value: postgres
- name: GITEA__database__HOST
value: postgres.database.svc.cluster.local:5432
- name: GITEA__database__NAME
value: gitea
- name: GITEA__database__USER
value: admin
- name: GITEA__database__PASSWD
valueFrom:
secretKeyRef:
name: gitea-db-secret
key: password
volumeMounts:
- name: gitea-data
mountPath: /data
volumes:
- name: gitea-data
persistentVolumeClaim:
claimName: gitea-hetzner-pvc
+20
View File
@@ -0,0 +1,20 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: gitea
namespace: gitea
annotations:
ingress.cilium.io/loadbalancer-mode: "dedicated"
spec:
ingressClassName: cilium
rules:
- host: "git.mariushome.lt"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: gitea
port:
number: 3000
+4
View File
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: gitea
+12
View File
@@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: gitea-hetzner-pvc
namespace: gitea
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: hcloud-volumes
+17
View File
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: gitea
namespace: gitea
spec:
selector:
app: gitea
ports:
- name: http
protocol: TCP
port: 3000
targetPort: http
- name: ssh
protocol: TCP
port: 2222
targetPort: ssh
+18
View File
@@ -0,0 +1,18 @@
kind: ConfigMap
apiVersion: v1
metadata:
name: immich-env
namespace: immich
labels:
app: immich
data:
DB_DATABASE_NAME: "immich"
DB_HOSTNAME: "postgres.database.svc.cluster.local"
DB_USERNAME: "immich"
DISABLE_REVERSE_GEOCODING: "false"
IMMICH_MACHINE_LEARNING_URL: "http://immich-machine-learning.immich.svc.cluster.local:3003"
REDIS_DBINDEX: "0"
REDIS_HOSTNAME: "immich-redis.immich.svc.cluster.local"
REDIS_PASSWORD: ""
REDIS_PORT: "6379"
@@ -0,0 +1,65 @@
kind: Deployment
apiVersion: apps/v1
metadata:
name: immich-machine-learning
namespace: immich
labels:
app: immich-machine-learning
spec:
strategy:
type: Recreate
selector:
matchLabels:
app: immich-machine-learning
template:
metadata:
labels:
app: immich-machine-learning
spec:
securityContext:
fsGroup: 0
serviceAccountName: default
automountServiceAccountToken: true
dnsPolicy: ClusterFirst
enableServiceLinks: true
containers:
- name: immich-machine-learning
image: "ghcr.io/immich-app/immich-machine-learning:release"
imagePullPolicy: Always
ports:
- containerPort: 3003
env:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: immich-db-secret
key: DB_PASSWORD
- name: TRANSFORMERS_CACHE
value: /cache
envFrom:
- configMapRef:
name: immich-env
optional: false
livenessProbe:
failureThreshold: 3
httpGet:
path: /ping
port: 3003
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
readinessProbe:
failureThreshold: 3
httpGet:
path: /ping
port: 3003
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
volumeMounts:
- name: cache
mountPath: /cache
resources: {}
volumes:
- name: cache
emptyDir: {}
@@ -0,0 +1,15 @@
kind: Service
apiVersion: v1
metadata:
name: immich-machine-learning
namespace: immich
labels:
app: immich-machine-learning
spec:
type: ClusterIP
selector:
app: immich-machine-learning
ports:
- port: 3003
targetPort: 3003
protocol: TCP
+12
View File
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: immich-redis
namespace: immich
spec:
selector:
app: immich-redis
ports:
- protocol: TCP
port: 6379
targetPort: 6379
+80
View File
@@ -0,0 +1,80 @@
kind: Deployment
apiVersion: apps/v1
metadata:
name: immich-server
namespace: immich
labels:
app: immich-server
spec:
strategy:
type: Recreate
selector:
matchLabels:
app: immich-server
template:
metadata:
labels:
app: immich-server
spec:
securityContext:
fsGroup: 0
serviceAccountName: default
dnsPolicy: ClusterFirst
initContainers:
- name: postgresql-isready
image: "docker.io/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0"
imagePullPolicy: IfNotPresent
env:
- name: POSTGRES_USER
valueFrom:
configMapKeyRef:
name: immich-env
key: DB_USERNAME
- name: POSTGRES_DB
valueFrom:
configMapKeyRef:
name: immich-env
key: DB_DATABASE_NAME
command:
- /bin/sh
- -c
- until pg_isready -U "${POSTGRES_USER}" -d "${POSTGRES_DB}"
-h postgres.database.svc.cluster.local -p 5432 ; do sleep 2 ; done
containers:
- name: immich-server
image: "ghcr.io/immich-app/immich-server:release"
imagePullPolicy: IfNotPresent
securityContext:
runAsUser: 0
ports:
- containerPort: 2283
envFrom:
- configMapRef:
name: immich-env
optional: false
- secretRef:
name: immich-db-secret
optional: false
livenessProbe:
failureThreshold: 120
httpGet:
path: /server/ping
port: 2283
initialDelaySeconds: 10
periodSeconds: 120
timeoutSeconds: 1
readinessProbe:
failureThreshold: 120
httpGet:
path: /server/ping
port: 2283
initialDelaySeconds: 10
periodSeconds: 120
timeoutSeconds: 1
volumeMounts:
- name: library
mountPath: /data
volumes:
- name: library
persistentVolumeClaim:
claimName: immich-lib
+25
View File
@@ -0,0 +1,25 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: immich-redis
namespace: immich
labels:
app: immich-redis
spec:
replicas: 1
selector:
matchLabels:
app: immich-redis
template:
metadata:
labels:
app: immich-redis
spec:
imagePullSecrets:
- name: dockerhub-creds
containers:
- name: immich-redis
image: docker.io/valkey/valkey:9@sha256:3b55fbaa0cd93cf0d9d961f405e4dfcc70efe325e2d84da207a0a8e6d8fde4f9
imagePullPolicy: IfNotPresent
ports:
- containerPort: 6379
@@ -0,0 +1,30 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres-hetzner
namespace: database
spec:
replicas: 1
selector:
matchLabels:
app: postgres-hetzner
template:
metadata:
labels:
app: postgres-hetzner
spec:
containers:
- name: postgres
image: 10.0.2.119:5000/custom-postgres:latest
volumeMounts:
- name: postgres-data
mountPath: /var/lib/postgresql
env:
- name: POSTGRES_PASSWORD
value: "jd@wXseh9z7vM@9"
- name: POSTGRES_USER
value: admin
volumes:
- name: postgres-data
persistentVolumeClaim:
claimName: postgres-hetzner-pvc
@@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-hetzner-pvc
namespace: database
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 39Gi
storageClassName: hcloud-volumes
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: postgres-hetzner
namespace: database
spec:
selector:
app: postgres-hetzner
ports:
- protocol: TCP
port: 5432
targetPort: 5432
+12
View File
@@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-pvc
namespace: database
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 39Gi
storageClassName: local-storage
+12
View File
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: postgres
namespace: database
spec:
selector:
app: postgres
ports:
- protocol: TCP
port: 5432
targetPort: 5432
+13
View File
@@ -0,0 +1,13 @@
apiVersion: discovery.k8s.io/v1
kind: EndpointSlice
metadata:
name: postgres-static-service
namespace: database
labels:
kubernetes.io/service-name: postgres # Links to the Service
addressType: IPv4
ports:
- port: 5432
endpoints:
- addresses:
- "10.0.2.122"
+36
View File
@@ -0,0 +1,36 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
namespace: database
spec:
replicas: 1
selector:
matchLabels:
app: postgres
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: 10.0.2.119:5000/custom-postgres:latest
volumeMounts:
- name: postgres-data
mountPath: /var/lib/postgresql
env:
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-secret
key: POSTGRES_PASSWORD
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: postgres-secret
key: POSTGRES_USER
volumes:
- name: postgres-data
persistentVolumeClaim:
claimName: postgres-data
+40
View File
@@ -0,0 +1,40 @@
# Kubernetes Manifests
Collection of Kubernetes manifests for self-hosted services running on a
homelab cluster.
## Layout
| Directory | Description |
|------------------|---------------------------------------------------------------|
| `Cilium/` | Cilium networking: `LoadBalancerIPPool`, `L2AnnouncementPolicy`, Ingress examples |
| `Cluster_admin/` | Admin notes: node restart commands, data migration examples |
| `DockerRegistry/`| Private Docker registry deployment, service, PVC and UI |
| `Gitea/` | Gitea deployment, service, ingress, namespace, PVC, DB secret |
| `Immich/` | Immich server, machine-learning, redis, config, secret |
| `PostgreSQL/` | PostgreSQL deployment, service, PVC, static endpoint, Hetzner volume variant |
| `Secrets/` | Docker registry login credentials (gitignored) |
| `volume/` | Persistent volume claim and SMB volume examples |
## Usage
Apply a manifest with:
```bash
kubectl apply -f <path/to/manifest.yaml>
```
## Notes
- Kubernetes `Secret` resources and the `Secrets/` directory are gitignored to
avoid leaking credentials. Create secrets out-of-band, e.g.:
```bash
kubectl create secret docker-registry dockerhub-creds \
--namespace=<ns> \
--docker-server=<server> \
--docker-username=<user> \
--docker-password=<password> \
--docker-email=<email>
```
- Review every manifest before applying it to a production cluster.
@@ -0,0 +1,12 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: immich-lib
namespace: immich
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 500Gi
storageClassName: slow
+32
View File
@@ -0,0 +1,32 @@
apiVersion: v1
kind: PersistentVolume
metadata:
annotations:
pv.kubernetes.io/provisioned-by: smb.csi.k8s.io
name: immich-lib
spec:
capacity:
storage: 500Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain
storageClassName: slow
mountOptions:
- dir_mode=0777
- file_mode=0777
- uid=1001
- gid=1001
- noperm
- mfsymlinks
- cache=strict
- noserverino # required to prevent data corruption
csi:
driver: smb.csi.k8s.io
# volumeHandle format: {smb-server-address}#{sub-dir-name}#{share-name}
# make sure this value is unique for every share in the cluster
volumeHandle: u518679.your-storagebox.de/backup/kube_storage#immich-lib##
volumeAttributes:
source: //u518679.your-storagebox.de/backup/kube_storage
nodeStageSecretRef:
name: smbcreds
namespace: storage