From 0c5cf29f832c8570172ce252788d52eac3c59dcb Mon Sep 17 00:00:00 2001 From: mr-forust Date: Sun, 7 Jun 2026 19:41:28 +0200 Subject: [PATCH] feat: add userbot k8s deployment method - Kustomize: base + overlays/dev + overlays/prod --- userbot/.env.account.example | 3 + userbot/.env.example | 14 +++ userbot/.gitignore | 3 + userbot/k8s/base/common-config.yaml | 7 ++ userbot/k8s/base/kustomization.yaml | 9 ++ userbot/k8s/base/userbots.yaml | 114 ++++++++++++++++++ userbot/k8s/overlays/dev/kustomization.yaml | 8 ++ userbot/k8s/overlays/dev/patch-downloads.yaml | 35 ++++++ userbot/k8s/overlays/prod/kustomization.yaml | 8 ++ .../k8s/overlays/prod/patch-downloads.yaml | 35 ++++++ 10 files changed, 236 insertions(+) create mode 100644 userbot/.env.account.example create mode 100644 userbot/.env.example create mode 100644 userbot/k8s/base/common-config.yaml create mode 100644 userbot/k8s/base/kustomization.yaml create mode 100644 userbot/k8s/base/userbots.yaml create mode 100644 userbot/k8s/overlays/dev/kustomization.yaml create mode 100644 userbot/k8s/overlays/dev/patch-downloads.yaml create mode 100644 userbot/k8s/overlays/prod/kustomization.yaml create mode 100644 userbot/k8s/overlays/prod/patch-downloads.yaml diff --git a/userbot/.env.account.example b/userbot/.env.account.example new file mode 100644 index 0000000..583a44e --- /dev/null +++ b/userbot/.env.account.example @@ -0,0 +1,3 @@ +API_ID="" +API_HASH="" +STRINGSESSION="" \ No newline at end of file diff --git a/userbot/.env.example b/userbot/.env.example new file mode 100644 index 0000000..b1ba859 --- /dev/null +++ b/userbot/.env.example @@ -0,0 +1,14 @@ +# apiflash api key only for webshot plugin +APIFLASH_KEY="" +# gemini api key only for gemini plugin +GEMINI_KEY="" +# VT api key only for VirusTotal plugin +VT_KEY="" +# rmbg api key only for removebg plugin +RMBG_KEY="" +# cohere api key only for cohere plugin +COHERE_KEY="" +# sqlite/sqlite3 or mongo/mongodb +DATABASE_TYPE="" +# file name for sqlite3, database name for mongodb +DATABASE_NAME="" diff --git a/userbot/.gitignore b/userbot/.gitignore index fccd91b..b166610 100644 --- a/userbot/.gitignore +++ b/userbot/.gitignore @@ -14,3 +14,6 @@ __pycache__/ /downloads/ /Downloads/ config.ini + +k8s/*/*secret*.yaml +!k8s/account-secrets.yaml.example \ No newline at end of file diff --git a/userbot/k8s/base/common-config.yaml b/userbot/k8s/base/common-config.yaml new file mode 100644 index 0000000..4a11507 --- /dev/null +++ b/userbot/k8s/base/common-config.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: userbot-common-config +data: + DATABASE_TYPE: "" + DATABASE_NAME: "" diff --git a/userbot/k8s/base/kustomization.yaml b/userbot/k8s/base/kustomization.yaml new file mode 100644 index 0000000..4af250f --- /dev/null +++ b/userbot/k8s/base/kustomization.yaml @@ -0,0 +1,9 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- userbots.yaml +- common-secret.yaml +- common-config.yaml +- forust-secrets.yaml +- anna-secrets.yaml diff --git a/userbot/k8s/base/userbots.yaml b/userbot/k8s/base/userbots.yaml new file mode 100644 index 0000000..7d35212 --- /dev/null +++ b/userbot/k8s/base/userbots.yaml @@ -0,0 +1,114 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: forust-userbot-deployment + labels: + app: forust-userbot +spec: + replicas: 1 + selector: + matchLabels: + app: forust-userbot + template: + metadata: + labels: + app: forust-userbot + spec: + containers: + - name: forust-userbot + image: gcr.forust.xyz/forust/userbot:latest + imagePullPolicy: Always + resources: + limits: + memory: "512Mi" + cpu: "500m" + requests: + memory: "256Mi" + cpu: "100m" + envFrom: + - secretRef: + name: userbot-common-secrets + - configMapRef: + name: userbot-common-config + - secretRef: + name: userbot-forust-secrets + volumeMounts: + - name: forust-storage + mountPath: /app/data + subPath: data + - name: forust-storage + mountPath: /app/logs + subPath: logs + volumes: + - name: forust-storage + persistentVolumeClaim: + claimName: forust-pvc +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: forust-pvc +spec: + resources: + requests: + storage: 1Gi + accessModes: + - ReadWriteOnce + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: anna-userbot-deployment + labels: + app: anna-userbot +spec: + replicas: 1 + selector: + matchLabels: + app: anna-userbot + template: + metadata: + labels: + app: anna-userbot + spec: + containers: + - name: anna-userbot + image: gcr.forust.xyz/forust/userbot:latest + imagePullPolicy: Always + resources: + limits: + memory: "512Mi" + cpu: "500m" + requests: + memory: "256Mi" + cpu: "100m" + envFrom: + - secretRef: + name: userbot-common-secrets + - configMapRef: + name: userbot-common-config + - secretRef: + name: userbot-anna-secrets + volumeMounts: + - name: anna-storage + mountPath: /app/data + subPath: data + - name: anna-storage + mountPath: /app/logs + subPath: logs + volumes: + - name: anna-storage + persistentVolumeClaim: + claimName: anna-pvc +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: anna-pvc +spec: + resources: + requests: + storage: 1Gi + accessModes: + - ReadWriteOnce diff --git a/userbot/k8s/overlays/dev/kustomization.yaml b/userbot/k8s/overlays/dev/kustomization.yaml new file mode 100644 index 0000000..a06a318 --- /dev/null +++ b/userbot/k8s/overlays/dev/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- ../../base + +patches: +- path: patch-downloads.yaml diff --git a/userbot/k8s/overlays/dev/patch-downloads.yaml b/userbot/k8s/overlays/dev/patch-downloads.yaml new file mode 100644 index 0000000..bf80f37 --- /dev/null +++ b/userbot/k8s/overlays/dev/patch-downloads.yaml @@ -0,0 +1,35 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: forust-userbot-deployment +spec: + template: + spec: + containers: + - name: forust-userbot + volumeMounts: + - name: downloads + mountPath: /app/downloads + volumes: + - name: downloads + hostPath: + path: /home/user/projects/homelab/userbot/Downloads + type: DirectoryOrCreate +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: anna-userbot-deployment +spec: + template: + spec: + containers: + - name: anna-userbot + volumeMounts: + - name: downloads + mountPath: /app/downloads + volumes: + - name: downloads + hostPath: + path: /home/user/projects/homelab/userbot/Downloads + type: DirectoryOrCreate diff --git a/userbot/k8s/overlays/prod/kustomization.yaml b/userbot/k8s/overlays/prod/kustomization.yaml new file mode 100644 index 0000000..a06a318 --- /dev/null +++ b/userbot/k8s/overlays/prod/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- ../../base + +patches: +- path: patch-downloads.yaml diff --git a/userbot/k8s/overlays/prod/patch-downloads.yaml b/userbot/k8s/overlays/prod/patch-downloads.yaml new file mode 100644 index 0000000..b691a80 --- /dev/null +++ b/userbot/k8s/overlays/prod/patch-downloads.yaml @@ -0,0 +1,35 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: forust-userbot-deployment +spec: + template: + spec: + containers: + - name: forust-userbot + volumeMounts: + - name: downloads + mountPath: /app/downloads + volumes: + - name: downloads + hostPath: + path: /srv/homelab/userbot/Downloads + type: DirectoryOrCreate +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: anna-userbot-deployment +spec: + template: + spec: + containers: + - name: anna-userbot + volumeMounts: + - name: downloads + mountPath: /app/downloads + volumes: + - name: downloads + hostPath: + path: /srv/homelab/userbot/Downloads + type: DirectoryOrCreate