From 3b1998f37685f06cf7c77c09d4d6df086d1f73e6 Mon Sep 17 00:00:00 2001 From: Marius Date: Sun, 28 Jun 2026 13:53:49 +0300 Subject: [PATCH] Add Kubernetes manifests for self-hosted services --- Cilium/Ingress_example.yaml | 22 +++++ Cilium/L2AnnouncementPolicy.yaml | 12 +++ Cilium/LoadBalancerIPPool.yaml | 8 ++ Cluster_admin/move _data_example.txt | 1 + Cluster_admin/nodes_restart_commands.txt | 21 +++++ DockerRegistry/UI/registry-ui-deploy.yaml | 29 +++++++ DockerRegistry/UI/registry-ui-ingress.yaml | 31 +++++++ DockerRegistry/UI/registry-ui-service.yaml | 11 +++ DockerRegistry/docker_registry_deploy.yaml | 31 +++++++ DockerRegistry/docker_registry_pvc.yaml | 13 +++ DockerRegistry/docker_registry_service.yaml | 12 +++ Gitea/gitea_deployment.yaml | 57 +++++++++++++ Gitea/gitea_ingress.yaml | 20 +++++ Gitea/gitea_namespace.yaml | 4 + Gitea/gitea_pvc.yaml | 12 +++ Gitea/gitea_service.yaml | 17 ++++ Immich/immich_config.yaml | 18 +++++ Immich/immich_machine_learning_deploy.yaml | 65 +++++++++++++++ Immich/immich_machine_learning_service.yaml | 15 ++++ Immich/immich_redis_service.txt | 12 +++ Immich/immich_server_deploy.yaml | 80 +++++++++++++++++++ Immich/redis_deploy.yaml | 25 ++++++ .../hetzner/postgres_hetzner_deployment.yaml | 30 +++++++ PostgreSQL/hetzner/postgres_hetzner_pvc.yaml | 12 +++ .../hetzner/postgres_hetzner_service.yaml | 12 +++ PostgreSQL/postgres_pvc.yaml | 12 +++ PostgreSQL/postgres_service.yaml | 12 +++ PostgreSQL/postgres_static_endpoint.yaml | 13 +++ PostgreSQL/postgress_deplay.yaml | 36 +++++++++ README.md | 40 ++++++++++ volume/persistent_volume_claim_example.yaml | 12 +++ volume/smb_volume_example.yaml | 32 ++++++++ 32 files changed, 727 insertions(+) create mode 100644 Cilium/Ingress_example.yaml create mode 100644 Cilium/L2AnnouncementPolicy.yaml create mode 100644 Cilium/LoadBalancerIPPool.yaml create mode 100644 Cluster_admin/move _data_example.txt create mode 100644 Cluster_admin/nodes_restart_commands.txt create mode 100644 DockerRegistry/UI/registry-ui-deploy.yaml create mode 100644 DockerRegistry/UI/registry-ui-ingress.yaml create mode 100644 DockerRegistry/UI/registry-ui-service.yaml create mode 100644 DockerRegistry/docker_registry_deploy.yaml create mode 100644 DockerRegistry/docker_registry_pvc.yaml create mode 100644 DockerRegistry/docker_registry_service.yaml create mode 100644 Gitea/gitea_deployment.yaml create mode 100644 Gitea/gitea_ingress.yaml create mode 100644 Gitea/gitea_namespace.yaml create mode 100644 Gitea/gitea_pvc.yaml create mode 100644 Gitea/gitea_service.yaml create mode 100644 Immich/immich_config.yaml create mode 100644 Immich/immich_machine_learning_deploy.yaml create mode 100644 Immich/immich_machine_learning_service.yaml create mode 100644 Immich/immich_redis_service.txt create mode 100644 Immich/immich_server_deploy.yaml create mode 100644 Immich/redis_deploy.yaml create mode 100644 PostgreSQL/hetzner/postgres_hetzner_deployment.yaml create mode 100644 PostgreSQL/hetzner/postgres_hetzner_pvc.yaml create mode 100644 PostgreSQL/hetzner/postgres_hetzner_service.yaml create mode 100644 PostgreSQL/postgres_pvc.yaml create mode 100644 PostgreSQL/postgres_service.yaml create mode 100644 PostgreSQL/postgres_static_endpoint.yaml create mode 100644 PostgreSQL/postgress_deplay.yaml create mode 100644 README.md create mode 100644 volume/persistent_volume_claim_example.yaml create mode 100644 volume/smb_volume_example.yaml diff --git a/Cilium/Ingress_example.yaml b/Cilium/Ingress_example.yaml new file mode 100644 index 0000000..6e6d336 --- /dev/null +++ b/Cilium/Ingress_example.yaml @@ -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 \ No newline at end of file diff --git a/Cilium/L2AnnouncementPolicy.yaml b/Cilium/L2AnnouncementPolicy.yaml new file mode 100644 index 0000000..d08a86f --- /dev/null +++ b/Cilium/L2AnnouncementPolicy.yaml @@ -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 diff --git a/Cilium/LoadBalancerIPPool.yaml b/Cilium/LoadBalancerIPPool.yaml new file mode 100644 index 0000000..6a00c2e --- /dev/null +++ b/Cilium/LoadBalancerIPPool.yaml @@ -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" diff --git a/Cluster_admin/move _data_example.txt b/Cluster_admin/move _data_example.txt new file mode 100644 index 0000000..496e836 --- /dev/null +++ b/Cluster_admin/move _data_example.txt @@ -0,0 +1 @@ +kubectl cp "C:\Users\MariusBlazys\Desktop\Temp\immich.tar" immich/data-loader-helper:/mnt/data \ No newline at end of file diff --git a/Cluster_admin/nodes_restart_commands.txt b/Cluster_admin/nodes_restart_commands.txt new file mode 100644 index 0000000..cd741f4 --- /dev/null +++ b/Cluster_admin/nodes_restart_commands.txt @@ -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 +------------------------------------------------------------------------------------------------- \ No newline at end of file diff --git a/DockerRegistry/UI/registry-ui-deploy.yaml b/DockerRegistry/UI/registry-ui-deploy.yaml new file mode 100644 index 0000000..335c8ab --- /dev/null +++ b/DockerRegistry/UI/registry-ui-deploy.yaml @@ -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 \ No newline at end of file diff --git a/DockerRegistry/UI/registry-ui-ingress.yaml b/DockerRegistry/UI/registry-ui-ingress.yaml new file mode 100644 index 0000000..52118b0 --- /dev/null +++ b/DockerRegistry/UI/registry-ui-ingress.yaml @@ -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 \ No newline at end of file diff --git a/DockerRegistry/UI/registry-ui-service.yaml b/DockerRegistry/UI/registry-ui-service.yaml new file mode 100644 index 0000000..a24d97e --- /dev/null +++ b/DockerRegistry/UI/registry-ui-service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: registry-ui + namespace: registry +spec: + selector: + app: registry-ui + ports: + - port: 80 + targetPort: 80 \ No newline at end of file diff --git a/DockerRegistry/docker_registry_deploy.yaml b/DockerRegistry/docker_registry_deploy.yaml new file mode 100644 index 0000000..1f8f66c --- /dev/null +++ b/DockerRegistry/docker_registry_deploy.yaml @@ -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 \ No newline at end of file diff --git a/DockerRegistry/docker_registry_pvc.yaml b/DockerRegistry/docker_registry_pvc.yaml new file mode 100644 index 0000000..0c07406 --- /dev/null +++ b/DockerRegistry/docker_registry_pvc.yaml @@ -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 \ No newline at end of file diff --git a/DockerRegistry/docker_registry_service.yaml b/DockerRegistry/docker_registry_service.yaml new file mode 100644 index 0000000..293bd82 --- /dev/null +++ b/DockerRegistry/docker_registry_service.yaml @@ -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 \ No newline at end of file diff --git a/Gitea/gitea_deployment.yaml b/Gitea/gitea_deployment.yaml new file mode 100644 index 0000000..b1b6893 --- /dev/null +++ b/Gitea/gitea_deployment.yaml @@ -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 \ No newline at end of file diff --git a/Gitea/gitea_ingress.yaml b/Gitea/gitea_ingress.yaml new file mode 100644 index 0000000..42ba911 --- /dev/null +++ b/Gitea/gitea_ingress.yaml @@ -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 \ No newline at end of file diff --git a/Gitea/gitea_namespace.yaml b/Gitea/gitea_namespace.yaml new file mode 100644 index 0000000..6f8f2e0 --- /dev/null +++ b/Gitea/gitea_namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: gitea diff --git a/Gitea/gitea_pvc.yaml b/Gitea/gitea_pvc.yaml new file mode 100644 index 0000000..f60e202 --- /dev/null +++ b/Gitea/gitea_pvc.yaml @@ -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 \ No newline at end of file diff --git a/Gitea/gitea_service.yaml b/Gitea/gitea_service.yaml new file mode 100644 index 0000000..e78ac53 --- /dev/null +++ b/Gitea/gitea_service.yaml @@ -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 diff --git a/Immich/immich_config.yaml b/Immich/immich_config.yaml new file mode 100644 index 0000000..e60401f --- /dev/null +++ b/Immich/immich_config.yaml @@ -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" + \ No newline at end of file diff --git a/Immich/immich_machine_learning_deploy.yaml b/Immich/immich_machine_learning_deploy.yaml new file mode 100644 index 0000000..7dad779 --- /dev/null +++ b/Immich/immich_machine_learning_deploy.yaml @@ -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: {} \ No newline at end of file diff --git a/Immich/immich_machine_learning_service.yaml b/Immich/immich_machine_learning_service.yaml new file mode 100644 index 0000000..a94dfe3 --- /dev/null +++ b/Immich/immich_machine_learning_service.yaml @@ -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 \ No newline at end of file diff --git a/Immich/immich_redis_service.txt b/Immich/immich_redis_service.txt new file mode 100644 index 0000000..c68e9b2 --- /dev/null +++ b/Immich/immich_redis_service.txt @@ -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 diff --git a/Immich/immich_server_deploy.yaml b/Immich/immich_server_deploy.yaml new file mode 100644 index 0000000..ddd0b82 --- /dev/null +++ b/Immich/immich_server_deploy.yaml @@ -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 \ No newline at end of file diff --git a/Immich/redis_deploy.yaml b/Immich/redis_deploy.yaml new file mode 100644 index 0000000..3a6f6c3 --- /dev/null +++ b/Immich/redis_deploy.yaml @@ -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 diff --git a/PostgreSQL/hetzner/postgres_hetzner_deployment.yaml b/PostgreSQL/hetzner/postgres_hetzner_deployment.yaml new file mode 100644 index 0000000..196c2f6 --- /dev/null +++ b/PostgreSQL/hetzner/postgres_hetzner_deployment.yaml @@ -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 \ No newline at end of file diff --git a/PostgreSQL/hetzner/postgres_hetzner_pvc.yaml b/PostgreSQL/hetzner/postgres_hetzner_pvc.yaml new file mode 100644 index 0000000..d250473 --- /dev/null +++ b/PostgreSQL/hetzner/postgres_hetzner_pvc.yaml @@ -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 \ No newline at end of file diff --git a/PostgreSQL/hetzner/postgres_hetzner_service.yaml b/PostgreSQL/hetzner/postgres_hetzner_service.yaml new file mode 100644 index 0000000..294d8f3 --- /dev/null +++ b/PostgreSQL/hetzner/postgres_hetzner_service.yaml @@ -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 \ No newline at end of file diff --git a/PostgreSQL/postgres_pvc.yaml b/PostgreSQL/postgres_pvc.yaml new file mode 100644 index 0000000..1ae54e1 --- /dev/null +++ b/PostgreSQL/postgres_pvc.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: postgres-pvc + namespace: database +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 39Gi + storageClassName: local-storage \ No newline at end of file diff --git a/PostgreSQL/postgres_service.yaml b/PostgreSQL/postgres_service.yaml new file mode 100644 index 0000000..04f1586 --- /dev/null +++ b/PostgreSQL/postgres_service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: postgres + namespace: database +spec: + selector: + app: postgres + ports: + - protocol: TCP + port: 5432 + targetPort: 5432 diff --git a/PostgreSQL/postgres_static_endpoint.yaml b/PostgreSQL/postgres_static_endpoint.yaml new file mode 100644 index 0000000..b2ac5b4 --- /dev/null +++ b/PostgreSQL/postgres_static_endpoint.yaml @@ -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" \ No newline at end of file diff --git a/PostgreSQL/postgress_deplay.yaml b/PostgreSQL/postgress_deplay.yaml new file mode 100644 index 0000000..2c81981 --- /dev/null +++ b/PostgreSQL/postgress_deplay.yaml @@ -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 \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..5a9c9f3 --- /dev/null +++ b/README.md @@ -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 +``` + +## 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= \ + --docker-server= \ + --docker-username= \ + --docker-password= \ + --docker-email= + ``` +- Review every manifest before applying it to a production cluster. \ No newline at end of file diff --git a/volume/persistent_volume_claim_example.yaml b/volume/persistent_volume_claim_example.yaml new file mode 100644 index 0000000..bf03c78 --- /dev/null +++ b/volume/persistent_volume_claim_example.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: immich-lib + namespace: immich +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 500Gi + storageClassName: slow diff --git a/volume/smb_volume_example.yaml b/volume/smb_volume_example.yaml new file mode 100644 index 0000000..11bf66a --- /dev/null +++ b/volume/smb_volume_example.yaml @@ -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 \ No newline at end of file