From 1da9bd84c63e907c548fd4871d1b1351d7f8cb3f Mon Sep 17 00:00:00 2001 From: Alomerry Wu Date: Sun, 11 Feb 2024 04:41:15 +0800 Subject: [PATCH] vm: add k8s apps --- vm/scripts/pve/k8s/apply/alomerry.yml | 5 + vm/scripts/pve/k8s/apps/mysql/config.yml | 13 ++ vm/scripts/pve/k8s/apps/mysql/mysql.yml | 172 +++++++++++++++++++++++ vm/scripts/pve/k8s/apps/umami/README.md | 14 ++ vm/scripts/pve/k8s/apps/umami/config.yml | 18 +++ vm/scripts/pve/k8s/apps/umami/umami.yml | 64 +++++++++ 6 files changed, 286 insertions(+) create mode 100644 vm/scripts/pve/k8s/apply/alomerry.yml create mode 100644 vm/scripts/pve/k8s/apps/mysql/config.yml create mode 100644 vm/scripts/pve/k8s/apps/mysql/mysql.yml create mode 100644 vm/scripts/pve/k8s/apps/umami/README.md create mode 100644 vm/scripts/pve/k8s/apps/umami/config.yml create mode 100644 vm/scripts/pve/k8s/apps/umami/umami.yml diff --git a/vm/scripts/pve/k8s/apply/alomerry.yml b/vm/scripts/pve/k8s/apply/alomerry.yml new file mode 100644 index 00000000..e892fb18 --- /dev/null +++ b/vm/scripts/pve/k8s/apply/alomerry.yml @@ -0,0 +1,5 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: alomerry \ No newline at end of file diff --git a/vm/scripts/pve/k8s/apps/mysql/config.yml b/vm/scripts/pve/k8s/apps/mysql/config.yml new file mode 100644 index 00000000..50f2af80 --- /dev/null +++ b/vm/scripts/pve/k8s/apps/mysql/config.yml @@ -0,0 +1,13 @@ +$ANSIBLE_VAULT;1.1;AES256 +66363136376431333266346465623332623464613633643239653934313330643063353730613936 +3430316636636531623562613763643965373264663333370a396361396233373461373266666638 +33643365656164656436663634326563323631643661646430373235626362353163366133376464 +3933373465346664640a346565643564313732383530383963393661316437613737643831333965 +36366564373232626531306434386338656431643038633563356434306665376162633763376163 +31386365653131383133343430643166373535333364383661333864333635656233623465383431 +64316261376436616639653364306234303138336162373766633466393966396632616236323665 +34656433636537643532343834386162656530323765323338663766313438306564616539376238 +65356636396533386665663935643531663839623565396634313734353034623934383664656134 +38323263353137326266376664636664326130623063306439613562643033363230666436316265 +33643531393661376361346236376631396134323466363831353138623438643330623864306630 +65613935393333306437 diff --git a/vm/scripts/pve/k8s/apps/mysql/mysql.yml b/vm/scripts/pve/k8s/apps/mysql/mysql.yml new file mode 100644 index 00000000..909e013e --- /dev/null +++ b/vm/scripts/pve/k8s/apps/mysql/mysql.yml @@ -0,0 +1,172 @@ +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: mysql-8-pvc-alomerry + namespace: alomerry +spec: + resources: + requests: + storage: 10G + volumeMode: Filesystem + storageClassName: nfs-csi + accessModes: + - ReadWriteOnce +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: mysql-5-pvc-alomerry + namespace: alomerry +spec: + resources: + requests: + storage: 10G + volumeMode: Filesystem + storageClassName: nfs-csi + accessModes: + - ReadWriteOnce +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: mysql-8-config + namespace: alomerry + labels: + app: mysql8 +data: + my.cnf: | + [mysql] + default-character-set=utf8mb4 + [mysqld] + max_connections = 2000 + skip_ssl + ssl=0 +--- +apiVersion: v1 +kind: Service +metadata: + name: mysql-8-service + namespace: alomerry +spec: + ports: + - name: mysql + port: 3306 + targetPort: mysql + protocol: TCP + selector: + app: mysql8 +--- +apiVersion: v1 +kind: Service +metadata: + name: mysql-5-service + namespace: alomerry +spec: + ports: + - name: mysql + port: 3306 + targetPort: mysql + protocol: TCP + selector: + app: mysql8 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mysql-8-deployment + namespace: alomerry +spec: + replicas: 1 + selector: + matchLabels: + app: mysql8 + strategy: + type: Recreate + template: + metadata: + labels: + app: mysql8 + spec: + containers: + - image: mysql:8.0 + name: mysql8 + env: + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: mysql-secret + key: rootPasswd_8 + - name: MYSQL_ROOT_HOST + value: "" + ports: + - containerPort: 3306 + protocol: TCP + name: mysql + volumeMounts: + - name: mysql-8-config + mountPath: /etc/mysql/conf.d/my.cnf + subPath: my.cnf + - name: localtime + readOnly: true + mountPath: /etc/localtime + - name: mysql-8-pv + mountPath: /var/lib/mysql + volumes: + - name: mysql-8-config + configMap: + name: mysql-8-config + - name: mysql-8-pv + persistentVolumeClaim: + claimName: mysql-8-pvc-alomerry + - name: localtime + hostPath: + type: File + path: /etc/localtime +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mysql-5-deployment + namespace: alomerry +spec: + replicas: 1 + selector: + matchLabels: + app: mysql5 + strategy: + type: Recreate + template: + metadata: + labels: + app: mysql5 + spec: + containers: + - image: mysql:5.7 + name: mysql5 + env: + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: mysql-secret + key: rootPasswd_5 + - name: MYSQL_ROOT_HOST + value: "" + ports: + - containerPort: 3306 + protocol: TCP + name: mysql + volumeMounts: + - name: localtime + readOnly: true + mountPath: /etc/localtime + - name: mysql-5-pv + mountPath: /var/lib/mysql + volumes: + - name: mysql-5-pv + persistentVolumeClaim: + claimName: mysql-5-pvc-alomerry + - name: localtime + hostPath: + type: File + path: /etc/localtime diff --git a/vm/scripts/pve/k8s/apps/umami/README.md b/vm/scripts/pve/k8s/apps/umami/README.md new file mode 100644 index 00000000..57f93f3d --- /dev/null +++ b/vm/scripts/pve/k8s/apps/umami/README.md @@ -0,0 +1,14 @@ +# 创建数据库 + +```sql +CREATE DATABASE `umami` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; +CREATE USER umami IDENTIFIED BY 'password'; +grant all privileges on umami.* to 'umami'@'%'; +FLUSH PRIVILEGES; +``` + + +CREATE USER umami IDENTIFIED BY 'JdsVEewaa23IF8u8qFDS1'; + +ALTER USER 'umami'@'localhost' IDENTIFIED WITH mysql_native_password BY 'JdsVEewaa23IF8u8qFDS1'; + diff --git a/vm/scripts/pve/k8s/apps/umami/config.yml b/vm/scripts/pve/k8s/apps/umami/config.yml new file mode 100644 index 00000000..a60b0370 --- /dev/null +++ b/vm/scripts/pve/k8s/apps/umami/config.yml @@ -0,0 +1,18 @@ +$ANSIBLE_VAULT;1.1;AES256 +63373366636430303064353431653630383763376430333766613163653132353864616636626361 +3863373366373761326435656166373238323433356262320a643538333737363561613636343933 +35373633653833616535356138393630373862613530313632336630363334323037643762383839 +3666313864643734360a353730623632633665306262343637623663336131333061633065336632 +39303839623761666630306634643038663239633236646565393535633634303163633432303635 +33386231376633336364633261373839396536393434623131353966336330383732626461346639 +36623333363463663539343832646537393463343163613062616166343833653737356238653238 +30343239336334616132353064316631323261393936393464613362346233303236613938633561 +38386332646262666539623366333137613132383638643862323564623566326662373261656332 +62363464363938623464323031396365633866363162373261333234643839363136623863346638 +38663830636630636238393661663165383539656463363866376533336330393234623534636534 +31643039623237653065623237653866366636356464373161396665376131646666396264363236 +66353963646666613132326430313937356636303036376331303664343337363534623033326335 +37343431643662653965663632663762343462643939333564646230646233666332393935313833 +65623063613535386536646432376133303661316430623663323166313136313932623138633965 +36363738366533303564663166663362313664323462316261646335373930353039336335396337 +3562 diff --git a/vm/scripts/pve/k8s/apps/umami/umami.yml b/vm/scripts/pve/k8s/apps/umami/umami.yml new file mode 100644 index 00000000..9e5f77a1 --- /dev/null +++ b/vm/scripts/pve/k8s/apps/umami/umami.yml @@ -0,0 +1,64 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: umami-service + namespace: alomerry +spec: + ports: + - name: umami + port: 3000 + targetPort: umami + protocol: TCP + selector: + app: umami +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: umami-deployment + namespace: alomerry +spec: + replicas: 1 + selector: + matchLabels: + app: umami + strategy: + type: Recreate + template: + metadata: + labels: + app: umami + spec: + containers: + # ghcr.lank8s.cn/umami-software/umami:mysql-latest + # registry.cn-hangzhou.aliyuncs.com/alomerry/k8s-umami:latest + - image: registry.cn-hangzhou.aliyuncs.com/alomerry/k8s-umami:latest + imagePullPolicy: Always + name: umami + env: + - name: DATABASE_URL + valueFrom: + secretKeyRef: + name: mysql-umami-cfg + key: dsn + - name: APP_SECRET + valueFrom: + secretKeyRef: + name: mysql-umami-cfg + key: secret + - name: DATABASE_TYPE + value: mysql + ports: + - containerPort: 3000 + protocol: TCP + name: umami + volumeMounts: + - name: localtime + readOnly: true + mountPath: /etc/localtime + volumes: + - name: localtime + hostPath: + type: File + path: /etc/localtime