From b59afc7a7c71b727ad9963104e8a68ad7965a085 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sat, 6 May 2023 13:57:56 +0800 Subject: [PATCH 001/117] Add missing replicas specification in chart template --- template/CHART_NAME/templates/deployment.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/template/CHART_NAME/templates/deployment.yaml b/template/CHART_NAME/templates/deployment.yaml index 797bdd61..172babfc 100644 --- a/template/CHART_NAME/templates/deployment.yaml +++ b/template/CHART_NAME/templates/deployment.yaml @@ -5,6 +5,7 @@ metadata: labels: {{- include "CHART_NAME.labels" . | nindent 4 }} spec: + replicas: {{ .Values.replicaCount | default 1 }} selector: matchLabels: {{- include "CHART_NAME.selectorLabels" . | nindent 6 }} From 46bdc0ae7c6fa34e2af6d9c2c88c3d88e058749d Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sat, 6 May 2023 13:59:02 +0800 Subject: [PATCH 002/117] Add missing replicas specifications in charts --- mika/clog/templates/deployment.yaml | 1 + mika/cloudflared/templates/deployment.yaml | 1 + mika/mango/README.md | 1 + mika/mango/templates/deployment.yaml | 1 + mika/postgres/README.md | 1 + mika/postgres/templates/deployment.yaml | 1 + mika/telego/README.md | 1 + mika/telego/templates/deployment.yaml | 1 + mika/vpbot/README.md | 1 + mika/vpbot/templates/deployment.yaml | 1 + mika/waktusolat/README.md | 1 + mika/waktusolat/templates/deployment.yaml | 1 + 12 files changed, 12 insertions(+) diff --git a/mika/clog/templates/deployment.yaml b/mika/clog/templates/deployment.yaml index 81ffa798..3621e2db 100644 --- a/mika/clog/templates/deployment.yaml +++ b/mika/clog/templates/deployment.yaml @@ -5,6 +5,7 @@ metadata: labels: {{- include "clog.labels" . | nindent 4 }} spec: + replicas: {{ .Values.replicaCount | default 1 }} selector: matchLabels: {{- include "clog.selectorLabels" . | nindent 6 }} diff --git a/mika/cloudflared/templates/deployment.yaml b/mika/cloudflared/templates/deployment.yaml index 310aae16..6ec127a5 100644 --- a/mika/cloudflared/templates/deployment.yaml +++ b/mika/cloudflared/templates/deployment.yaml @@ -5,6 +5,7 @@ metadata: labels: {{- include "cloudflared.labels" . | nindent 4 }} spec: + replicas: {{ .Values.replicaCount | default 1 }} selector: matchLabels: {{- include "cloudflared.selectorLabels" . | nindent 6 }} diff --git a/mika/mango/README.md b/mika/mango/README.md index 6c19e7d9..68fe7209 100644 --- a/mika/mango/README.md +++ b/mika/mango/README.md @@ -99,6 +99,7 @@ helm uninstall $release_name --namespace $namespace --wait | mango.mastodon.token | string | `""` | Mastodon token secret | | mango.secret | string | `""` | Mango secret key | | mango.support | string | `"support@mikahomelab.com"` | Support email address | +| replicaCount | int | `1` | Mango replica count | | resources.mango.limits.cpu | string | `"50m"` | Mango maximum cpu allocation | | resources.mango.limits.memory | string | `"500Mi"` | Mango maximum memory allocation | | resources.mango.requests.cpu | string | `"10m"` | Mango minimum cpu allocation | diff --git a/mika/mango/templates/deployment.yaml b/mika/mango/templates/deployment.yaml index 5c1f8776..80e54551 100644 --- a/mika/mango/templates/deployment.yaml +++ b/mika/mango/templates/deployment.yaml @@ -5,6 +5,7 @@ metadata: labels: {{- include "mango.labels" . | nindent 4 }} spec: + replicas: {{ .Values.replicaCount | default 1 }} selector: matchLabels: {{- include "mango.selectorLabels" . | nindent 6 }} diff --git a/mika/postgres/README.md b/mika/postgres/README.md index b7c48adc..11fa8f6e 100644 --- a/mika/postgres/README.md +++ b/mika/postgres/README.md @@ -70,6 +70,7 @@ helm uninstall $release_name --namespace $namespace --wait | postgres.user | string | `"root"` | Root postgres user | | pvc.data.storage | string | `"1Gi"` | Data storage size | | pvc.data.storageClassName | string | `"longhorn"` | Data storage class name | +| replicaCount | int | `1` | Postgres replica count | | resources.limits.cpu | string | `"250m"` | Maximum cpu allocation | | resources.limits.memory | string | `"250Mi"` | Maximum memory allocation | | resources.requests.cpu | string | `"10m"` | Minimum cpu allocation | diff --git a/mika/postgres/templates/deployment.yaml b/mika/postgres/templates/deployment.yaml index 08d497da..1eb89a3b 100644 --- a/mika/postgres/templates/deployment.yaml +++ b/mika/postgres/templates/deployment.yaml @@ -5,6 +5,7 @@ metadata: labels: {{- include "postgres.labels" . | nindent 4 }} spec: + replicas: {{ .Values.replicaCount | default 1 }} selector: matchLabels: {{- include "postgres.selectorLabels" . | nindent 6 }} diff --git a/mika/telego/README.md b/mika/telego/README.md index 6c92aa09..bd8a41ac 100644 --- a/mika/telego/README.md +++ b/mika/telego/README.md @@ -212,6 +212,7 @@ Install [`mika/postgres-dropdb`](../postgres-dropdb/). | imagePullSecrets[0].name | string | `"ghcr-token-secret"` | Name of the image pull secret | | pvc.logs.storage | string | `"10Mi"` | Log files storage size | | pvc.logs.storageClassName | string | `"longhorn"` | Log files storage class name | +| replicaCount | int | `1` | Telego replica count | | resources.redis.limits.cpu | string | `"15m"` | Redis maximum CPU allocation | | resources.redis.limits.memory | string | `"60Mi"` | Redis maximum memory allocation | | resources.redis.requests.cpu | string | `"5m"` | Redis minimum CPU allocation | diff --git a/mika/telego/templates/deployment.yaml b/mika/telego/templates/deployment.yaml index a63280e9..6084634d 100644 --- a/mika/telego/templates/deployment.yaml +++ b/mika/telego/templates/deployment.yaml @@ -5,6 +5,7 @@ metadata: labels: {{- include "telego.labels" . | nindent 4 }} spec: + replicas: {{ .Values.replicaCount | default 1 }} selector: matchLabels: {{- include "telego.selectorLabels" . | nindent 6 }} diff --git a/mika/vpbot/README.md b/mika/vpbot/README.md index aba975c2..e2242dd0 100644 --- a/mika/vpbot/README.md +++ b/mika/vpbot/README.md @@ -110,6 +110,7 @@ Install [`mika/postgres-dropdb`](../postgres-dropdb/). | pvc.migrations.storageClassName | string | `"longhorn"` | Migrations storage class name | | pvc.static.storage | string | `"50Mi"` | Static files storage size | | pvc.static.storageClassName | string | `"longhorn"` | Static files storage class name | +| replicaCount | int | `1` | Vpbot replica count | | resources.redis.limits.cpu | string | `"15m"` | Redis maximum CPU allocation | | resources.redis.limits.memory | string | `"60Mi"` | Redis maximum memory allocation | | resources.redis.requests.cpu | string | `"5m"` | Redis minimum CPU allocation | diff --git a/mika/vpbot/templates/deployment.yaml b/mika/vpbot/templates/deployment.yaml index abcb142c..122b0a67 100644 --- a/mika/vpbot/templates/deployment.yaml +++ b/mika/vpbot/templates/deployment.yaml @@ -5,6 +5,7 @@ metadata: labels: {{- include "vpbot.labels" . | nindent 4 }} spec: + replicas: {{ .Values.replicaCount | default 1 }} selector: matchLabels: {{- include "vpbot.selectorLabels" . | nindent 6 }} diff --git a/mika/waktusolat/README.md b/mika/waktusolat/README.md index 84e31a08..b7fd571c 100644 --- a/mika/waktusolat/README.md +++ b/mika/waktusolat/README.md @@ -92,6 +92,7 @@ helm uninstall $release_name --namespace $namespace --wait | image.waktusolat.repository | string | `"irfanhakim-as/waktusolat"` | Waktu Solat image repository | | image.waktusolat.tag | string | `""` | Waktu Solat image version | | imagePullSecrets[0].name | string | `"ghcr-token-secret"` | Image pull secret name | +| replicaCount | int | `1` | Waktu Solat replica count | | resources.redis.limits.cpu | string | `"15m"` | Redis maximum cpu allocation | | resources.redis.limits.memory | string | `"50Mi"` | Redis maximum memory allocation | | resources.redis.requests.cpu | string | `"5m"` | Redis minimum cpu allocation | diff --git a/mika/waktusolat/templates/deployment.yaml b/mika/waktusolat/templates/deployment.yaml index 4e06cd80..d385a133 100644 --- a/mika/waktusolat/templates/deployment.yaml +++ b/mika/waktusolat/templates/deployment.yaml @@ -5,6 +5,7 @@ metadata: labels: {{- include "waktusolat.labels" . | nindent 4 }} spec: + replicas: {{ .Values.replicaCount | default 1 }} selector: matchLabels: {{- include "waktusolat.selectorLabels" . | nindent 6 }} From b739d867fde6ea9c8693ce5ecf95ca79b40076f6 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sat, 6 May 2023 13:59:25 +0800 Subject: [PATCH 003/117] Remove replicaCount value from job-based charts --- mika/postgres-agent/values.yaml | 2 -- mika/postgres-createdb/values.yaml | 2 -- mika/postgres-dropdb/values.yaml | 2 -- 3 files changed, 6 deletions(-) diff --git a/mika/postgres-agent/values.yaml b/mika/postgres-agent/values.yaml index a90d655e..1ba6a009 100644 --- a/mika/postgres-agent/values.yaml +++ b/mika/postgres-agent/values.yaml @@ -2,8 +2,6 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -replicaCount: 1 - image: postgres: registry: docker.io diff --git a/mika/postgres-createdb/values.yaml b/mika/postgres-createdb/values.yaml index a4667d9e..d10aa7c7 100644 --- a/mika/postgres-createdb/values.yaml +++ b/mika/postgres-createdb/values.yaml @@ -2,8 +2,6 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -replicaCount: 1 - image: postgres: registry: docker.io diff --git a/mika/postgres-dropdb/values.yaml b/mika/postgres-dropdb/values.yaml index 6fd9f09e..06cc5872 100644 --- a/mika/postgres-dropdb/values.yaml +++ b/mika/postgres-dropdb/values.yaml @@ -2,8 +2,6 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -replicaCount: 1 - image: postgres: registry: docker.io From daf3702a5d2ac5f4ef798e50ccee3e9443493065 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sun, 7 May 2023 15:05:06 +0800 Subject: [PATCH 004/117] postgres: Move pvc settings and add default values --- mika/postgres/README.md | 4 ++-- mika/postgres/templates/pvc.yaml | 7 ++++--- mika/postgres/values.yaml | 14 ++++++++++---- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/mika/postgres/README.md b/mika/postgres/README.md index 11fa8f6e..49aa5735 100644 --- a/mika/postgres/README.md +++ b/mika/postgres/README.md @@ -65,11 +65,11 @@ helm uninstall $release_name --namespace $namespace --wait | image.postgres.registry | string | `"docker.io"` | Postgres image registry | | image.postgres.repository | string | `"postgres"` | Postgres image repository | | image.postgres.tag | string | `""` | Postgres image version | +| postgres.data.storage | string | `"1Gi"` | Data storage size. Default: `"1Gi"`. | +| postgres.data.storageClassName | string | `"longhorn"` | Data storage class name. Default: `"longhorn"`. | | postgres.name | string | `"default"` | Default database name | | postgres.pass | string | `""` | Root postgres password | | postgres.user | string | `"root"` | Root postgres user | -| pvc.data.storage | string | `"1Gi"` | Data storage size | -| pvc.data.storageClassName | string | `"longhorn"` | Data storage class name | | replicaCount | int | `1` | Postgres replica count | | resources.limits.cpu | string | `"250m"` | Maximum cpu allocation | | resources.limits.memory | string | `"250Mi"` | Maximum memory allocation | diff --git a/mika/postgres/templates/pvc.yaml b/mika/postgres/templates/pvc.yaml index b3cb0b64..93e8a4db 100644 --- a/mika/postgres/templates/pvc.yaml +++ b/mika/postgres/templates/pvc.yaml @@ -1,4 +1,5 @@ -# helm pvc +{{- $storage := .Values.postgres.data.storage | default "1Gi" | toString | quote }} +{{- $storage_class_name := .Values.postgres.data.storageClassName | default "longhorn" | toString | quote }} apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -10,5 +11,5 @@ spec: - ReadWriteMany resources: requests: - storage: {{ .Values.pvc.data.storage }} - storageClassName: {{ .Values.pvc.data.storageClassName }} + storage: {{ $storage }} + storageClassName: {{ $storage_class_name }} diff --git a/mika/postgres/values.yaml b/mika/postgres/values.yaml index 2b13942d..0476939a 100644 --- a/mika/postgres/values.yaml +++ b/mika/postgres/values.yaml @@ -15,11 +15,17 @@ postgres: name: "default" # name of default database user: "root" # database user pass: "" # database user password - -pvc: data: - storage: "1Gi" # data storage size - storageClassName: "longhorn" # data storage class name + # Data storage size. + # Default: "1Gi" + # Example: + # storage: "1Gi" + storage: "" + # Data storage class name. + # Default: "longhorn" + # Example: + # storageClassName: "longhorn" + storageClassName: "" resources: requests: From dfbef47b6a3ad867fc68c64f62fe0192bfd1c639 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sun, 7 May 2023 15:08:20 +0800 Subject: [PATCH 005/117] postgres: Move container image settings --- mika/postgres/README.md | 8 ++++---- mika/postgres/values.yaml | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/mika/postgres/README.md b/mika/postgres/README.md index 49aa5735..161f758e 100644 --- a/mika/postgres/README.md +++ b/mika/postgres/README.md @@ -61,10 +61,10 @@ helm uninstall $release_name --namespace $namespace --wait | Key | Type | Default | Description | |-----|------|---------|-------------| -| image.postgres.pullPolicy | string | `"IfNotPresent"` | Postgres image pull policy | -| image.postgres.registry | string | `"docker.io"` | Postgres image registry | -| image.postgres.repository | string | `"postgres"` | Postgres image repository | -| image.postgres.tag | string | `""` | Postgres image version | +| image.pullPolicy | string | `"IfNotPresent"` | Postgres image pull policy | +| image.registry | string | `"docker.io"` | Postgres image registry | +| image.repository | string | `"postgres"` | Postgres image repository | +| image.tag | string | `""` | Postgres image version | | postgres.data.storage | string | `"1Gi"` | Data storage size. Default: `"1Gi"`. | | postgres.data.storageClassName | string | `"longhorn"` | Data storage class name. Default: `"longhorn"`. | | postgres.name | string | `"default"` | Default database name | diff --git a/mika/postgres/values.yaml b/mika/postgres/values.yaml index 0476939a..b13dd848 100644 --- a/mika/postgres/values.yaml +++ b/mika/postgres/values.yaml @@ -5,11 +5,10 @@ replicaCount: 1 image: - postgres: - registry: docker.io - repository: postgres - tag: "" - pullPolicy: IfNotPresent + registry: docker.io + repository: postgres + tag: "" + pullPolicy: IfNotPresent postgres: name: "default" # name of default database From 51f0aba063df422c1074bc2c82c1b41603c7f7f6 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sun, 7 May 2023 15:22:57 +0800 Subject: [PATCH 006/117] postgres: Add default values for container image settings --- mika/postgres/README.md | 8 ++++---- mika/postgres/templates/deployment.yaml | 8 ++++++-- mika/postgres/values.yaml | 15 ++++++++++++--- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/mika/postgres/README.md b/mika/postgres/README.md index 161f758e..fe80b55d 100644 --- a/mika/postgres/README.md +++ b/mika/postgres/README.md @@ -61,10 +61,10 @@ helm uninstall $release_name --namespace $namespace --wait | Key | Type | Default | Description | |-----|------|---------|-------------| -| image.pullPolicy | string | `"IfNotPresent"` | Postgres image pull policy | -| image.registry | string | `"docker.io"` | Postgres image registry | -| image.repository | string | `"postgres"` | Postgres image repository | -| image.tag | string | `""` | Postgres image version | +| image.pullPolicy | string | `""` | PostgreSQL image pull policy. Default: `"IfNotPresent"`. | +| image.registry | string | `""` | PostgreSQL image registry. Default: `"docker.io"`. | +| image.repository | string | `""` | PostgreSQL image repository. Default: `"postgres"`. | +| image.tag | string | `""` | PostgreSQL image version. Default: `Chart appVersion`. | | postgres.data.storage | string | `"1Gi"` | Data storage size. Default: `"1Gi"`. | | postgres.data.storageClassName | string | `"longhorn"` | Data storage class name. Default: `"longhorn"`. | | postgres.name | string | `"default"` | Default database name | diff --git a/mika/postgres/templates/deployment.yaml b/mika/postgres/templates/deployment.yaml index 1eb89a3b..f82acbb9 100644 --- a/mika/postgres/templates/deployment.yaml +++ b/mika/postgres/templates/deployment.yaml @@ -1,3 +1,7 @@ +{{- $registry := .Values.image.registry | default "docker.io" | toString }} +{{- $repository := .Values.image.repository | default "postgres" | toString }} +{{- $tag := .Values.image.tag | default .Chart.AppVersion | toString }} +{{- $pullPolicy := .Values.image.pullPolicy | default "IfNotPresent" | toString | quote }} apiVersion: apps/v1 kind: Deployment metadata: @@ -20,8 +24,8 @@ spec: spec: containers: - name: postgres - image: "{{ .Values.image.postgres.registry }}/{{ .Values.image.postgres.repository }}:{{ .Values.image.postgres.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.postgres.pullPolicy }} + image: {{ printf "%s/%s:%s" $registry $repository $tag | quote }} + imagePullPolicy: {{ $pullPolicy }} ports: - name: postgres containerPort: 5432 diff --git a/mika/postgres/values.yaml b/mika/postgres/values.yaml index b13dd848..298e006e 100644 --- a/mika/postgres/values.yaml +++ b/mika/postgres/values.yaml @@ -4,11 +4,20 @@ replicaCount: 1 +# Container image used for the PostgreSQL database. image: - registry: docker.io - repository: postgres + # PostgreSQL image registry. + # Default: "docker.io" + registry: "" + # PostgreSQL image repository. + # Default: "postgres" + repository: "" + # PostgreSQL image version. + # Default: Chart appVersion tag: "" - pullPolicy: IfNotPresent + # PostgreSQL image pull policy. + # Default: "IfNotPresent" + pullPolicy: "" postgres: name: "default" # name of default database From 38ee5278f2b730a02f95ec684db1a2ab1a2b209c Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Wed, 10 May 2023 11:25:55 +0800 Subject: [PATCH 007/117] postgres: Updated replicaCount setting --- mika/postgres/README.md | 2 +- mika/postgres/templates/deployment.yaml | 3 ++- mika/postgres/values.yaml | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mika/postgres/README.md b/mika/postgres/README.md index fe80b55d..abd42293 100644 --- a/mika/postgres/README.md +++ b/mika/postgres/README.md @@ -70,7 +70,7 @@ helm uninstall $release_name --namespace $namespace --wait | postgres.name | string | `"default"` | Default database name | | postgres.pass | string | `""` | Root postgres password | | postgres.user | string | `"root"` | Root postgres user | -| replicaCount | int | `1` | Postgres replica count | +| replicaCount | int | `1` | Desired number of running replicas for PostgreSQL. Default: `"1"`. | | resources.limits.cpu | string | `"250m"` | Maximum cpu allocation | | resources.limits.memory | string | `"250Mi"` | Maximum memory allocation | | resources.requests.cpu | string | `"10m"` | Minimum cpu allocation | diff --git a/mika/postgres/templates/deployment.yaml b/mika/postgres/templates/deployment.yaml index f82acbb9..9de7da90 100644 --- a/mika/postgres/templates/deployment.yaml +++ b/mika/postgres/templates/deployment.yaml @@ -1,3 +1,4 @@ +{{- $replica_count := .Values.replicaCount | default "1" | toString }} {{- $registry := .Values.image.registry | default "docker.io" | toString }} {{- $repository := .Values.image.repository | default "postgres" | toString }} {{- $tag := .Values.image.tag | default .Chart.AppVersion | toString }} @@ -9,7 +10,7 @@ metadata: labels: {{- include "postgres.labels" . | nindent 4 }} spec: - replicas: {{ .Values.replicaCount | default 1 }} + replicas: {{ int $replica_count }} selector: matchLabels: {{- include "postgres.selectorLabels" . | nindent 6 }} diff --git a/mika/postgres/values.yaml b/mika/postgres/values.yaml index 298e006e..06ae4a36 100644 --- a/mika/postgres/values.yaml +++ b/mika/postgres/values.yaml @@ -2,7 +2,9 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -replicaCount: 1 +# Desired number of running replicas for PostgreSQL. +# Default: "1" +replicaCount: "" # Container image used for the PostgreSQL database. image: From d3c404d831de1b0e94a3835263a44a10bdc7228e Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Wed, 10 May 2023 11:37:27 +0800 Subject: [PATCH 008/117] postgres: Updated resources setting description --- mika/postgres/README.md | 8 ++++---- mika/postgres/values.yaml | 23 +++++++++++++++++++---- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/mika/postgres/README.md b/mika/postgres/README.md index abd42293..7de7fb8c 100644 --- a/mika/postgres/README.md +++ b/mika/postgres/README.md @@ -71,7 +71,7 @@ helm uninstall $release_name --namespace $namespace --wait | postgres.pass | string | `""` | Root postgres password | | postgres.user | string | `"root"` | Root postgres user | | replicaCount | int | `1` | Desired number of running replicas for PostgreSQL. Default: `"1"`. | -| resources.limits.cpu | string | `"250m"` | Maximum cpu allocation | -| resources.limits.memory | string | `"250Mi"` | Maximum memory allocation | -| resources.requests.cpu | string | `"10m"` | Minimum cpu allocation | -| resources.requests.memory | string | `"10Mi"` | Minimum memory allocation | +| resources.limits.cpu | string | `"250m"` | The maximum amount of CPU resources allowed for PostgreSQL. | +| resources.limits.memory | string | `"250Mi"` | The maximum amount of memory allowed for PostgreSQL. | +| resources.requests.cpu | string | `"10m"` | The minimum amount of CPU resources required by PostgreSQL. | +| resources.requests.memory | string | `"10Mi"` | The minimum amount of memory required by PostgreSQL. | diff --git a/mika/postgres/values.yaml b/mika/postgres/values.yaml index 06ae4a36..6e6f01d7 100644 --- a/mika/postgres/values.yaml +++ b/mika/postgres/values.yaml @@ -37,10 +37,25 @@ postgres: # storageClassName: "longhorn" storageClassName: "" +# Resource requirements and limits for PostgreSQL. resources: + # The minimum amount of resources required by PostgreSQL to run. requests: - cpu: "10m" # postgres cpu request - memory: "10Mi" # postgres memory request + # The minimum amount of CPU resources required by PostgreSQL. + # Example: + # cpu: "10m" + cpu: "10m" + # The minimum amount of memory required by PostgreSQL. + # Example: + # memory: "10Mi" + memory: "10Mi" + # The maximum amount of resources allowed for PostgreSQL. limits: - cpu: "250m" # postgres cpu limit - memory: "250Mi" # postgres memory limit + # The maximum amount of CPU resources allowed for PostgreSQL. + # Example: + # cpu: "250m" + cpu: "250m" + # The maximum amount of memory allowed for PostgreSQL. + # Example: + # memory: "250Mi" + memory: "250Mi" From 5f9b322946fcf6cad85c35fafbba3fd2c6a9746d Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Wed, 10 May 2023 11:54:14 +0800 Subject: [PATCH 009/117] postgres: Updated database credentials setting --- mika/postgres/README.md | 6 +++--- mika/postgres/templates/secret.yaml | 9 ++++++--- mika/postgres/values.yaml | 17 ++++++++++++++--- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/mika/postgres/README.md b/mika/postgres/README.md index 7de7fb8c..cae85132 100644 --- a/mika/postgres/README.md +++ b/mika/postgres/README.md @@ -67,9 +67,9 @@ helm uninstall $release_name --namespace $namespace --wait | image.tag | string | `""` | PostgreSQL image version. Default: `Chart appVersion`. | | postgres.data.storage | string | `"1Gi"` | Data storage size. Default: `"1Gi"`. | | postgres.data.storageClassName | string | `"longhorn"` | Data storage class name. Default: `"longhorn"`. | -| postgres.name | string | `"default"` | Default database name | -| postgres.pass | string | `""` | Root postgres password | -| postgres.user | string | `"root"` | Root postgres user | +| postgres.name | string | `""` | The name of the default PostgreSQL database. Default: `"default"`. | +| postgres.pass | string | `""` | The password for accessing the PostgreSQL instance. | +| postgres.user | string | `""` | The username for accessing the PostgreSQL instance. Default: `"root"`. | | replicaCount | int | `1` | Desired number of running replicas for PostgreSQL. Default: `"1"`. | | resources.limits.cpu | string | `"250m"` | The maximum amount of CPU resources allowed for PostgreSQL. | | resources.limits.memory | string | `"250Mi"` | The maximum amount of memory allowed for PostgreSQL. | diff --git a/mika/postgres/templates/secret.yaml b/mika/postgres/templates/secret.yaml index dc890738..700c9c15 100644 --- a/mika/postgres/templates/secret.yaml +++ b/mika/postgres/templates/secret.yaml @@ -1,3 +1,6 @@ +{{- $postgres_name := .Values.postgres.name | default "default" | toString | b64enc }} +{{- $postgres_user := .Values.postgres.user | default "root" | toString | b64enc }} +{{- $postgres_pass := .Values.postgres.pass | toString | b64enc }} apiVersion: v1 kind: Secret metadata: @@ -6,6 +9,6 @@ metadata: {{- include "postgres.labels" . | nindent 4 }} type: Opaque data: - DB_NAME: {{ .Values.postgres.name | toString | b64enc }} - DB_USER: {{ .Values.postgres.user | toString | b64enc }} - DB_PASS: {{ .Values.postgres.pass | toString | b64enc }} + DB_NAME: {{ $postgres_name }} + DB_USER: {{ $postgres_user }} + DB_PASS: {{ $postgres_pass }} diff --git a/mika/postgres/values.yaml b/mika/postgres/values.yaml index 6e6f01d7..cb3ed134 100644 --- a/mika/postgres/values.yaml +++ b/mika/postgres/values.yaml @@ -22,9 +22,20 @@ image: pullPolicy: "" postgres: - name: "default" # name of default database - user: "root" # database user - pass: "" # database user password + # The name of the default PostgreSQL database. + # Default: "default" + # Example: + # name: "default" + name: "" + # The username for accessing the PostgreSQL instance. + # Default: "root" + # Example: + # user: "root" + user: "" + # The password for accessing the PostgreSQL instance. + # Example: + # pass: "password" + pass: "" data: # Data storage size. # Default: "1Gi" From eeb80c2c729e567855375ea19655c7dc0d3a2b3c Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Wed, 10 May 2023 14:23:20 +0800 Subject: [PATCH 010/117] postgres: Update value descriptions --- mika/postgres/README.md | 14 +++++++------- mika/postgres/values.yaml | 17 +++++++++-------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/mika/postgres/README.md b/mika/postgres/README.md index cae85132..194ffcaa 100644 --- a/mika/postgres/README.md +++ b/mika/postgres/README.md @@ -61,16 +61,16 @@ helm uninstall $release_name --namespace $namespace --wait | Key | Type | Default | Description | |-----|------|---------|-------------| -| image.pullPolicy | string | `""` | PostgreSQL image pull policy. Default: `"IfNotPresent"`. | -| image.registry | string | `""` | PostgreSQL image registry. Default: `"docker.io"`. | -| image.repository | string | `""` | PostgreSQL image repository. Default: `"postgres"`. | -| image.tag | string | `""` | PostgreSQL image version. Default: `Chart appVersion`. | -| postgres.data.storage | string | `"1Gi"` | Data storage size. Default: `"1Gi"`. | -| postgres.data.storageClassName | string | `"longhorn"` | Data storage class name. Default: `"longhorn"`. | +| image.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the PostgreSQL image. Default: `"IfNotPresent"`. | +| image.registry | string | `""` | The registry where the PostgreSQL image is hosted. Default: `"docker.io"`. | +| image.repository | string | `""` | The name of the repository that contains the PostgreSQL image used. Default: `"postgres"`. | +| image.tag | string | `""` | The tag that specifies the version of the PostgreSQL image used. Default: `Chart appVersion`. | +| postgres.data.storage | string | `"1Gi"` | The amount of persistent storage allocated for the PostgreSQL instance. Default: `"1Gi"`. | +| postgres.data.storageClassName | string | `"longhorn"` | The storage class name used for dynamically provisioning a persistent volume for the PostgreSQL storage. Default: `"longhorn"`. | | postgres.name | string | `""` | The name of the default PostgreSQL database. Default: `"default"`. | | postgres.pass | string | `""` | The password for accessing the PostgreSQL instance. | | postgres.user | string | `""` | The username for accessing the PostgreSQL instance. Default: `"root"`. | -| replicaCount | int | `1` | Desired number of running replicas for PostgreSQL. Default: `"1"`. | +| replicaCount | int | `""` | The desired number of running replicas for PostgreSQL. Default: `"1"`. | | resources.limits.cpu | string | `"250m"` | The maximum amount of CPU resources allowed for PostgreSQL. | | resources.limits.memory | string | `"250Mi"` | The maximum amount of memory allowed for PostgreSQL. | | resources.requests.cpu | string | `"10m"` | The minimum amount of CPU resources required by PostgreSQL. | diff --git a/mika/postgres/values.yaml b/mika/postgres/values.yaml index cb3ed134..303d1629 100644 --- a/mika/postgres/values.yaml +++ b/mika/postgres/values.yaml @@ -2,25 +2,26 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -# Desired number of running replicas for PostgreSQL. +# The desired number of running replicas for PostgreSQL. # Default: "1" replicaCount: "" -# Container image used for the PostgreSQL database. +# Container image used for PostgreSQL. image: - # PostgreSQL image registry. + # The registry where the PostgreSQL image is hosted. # Default: "docker.io" registry: "" - # PostgreSQL image repository. + # The name of the repository that contains the PostgreSQL image used. # Default: "postgres" repository: "" - # PostgreSQL image version. + # The tag that specifies the version of the PostgreSQL image used. # Default: Chart appVersion tag: "" - # PostgreSQL image pull policy. + # The policy that determines when Kubernetes should pull the PostgreSQL image. # Default: "IfNotPresent" pullPolicy: "" +# PostgreSQL configurations. postgres: # The name of the default PostgreSQL database. # Default: "default" @@ -37,12 +38,12 @@ postgres: # pass: "password" pass: "" data: - # Data storage size. + # The amount of persistent storage allocated for the PostgreSQL instance. # Default: "1Gi" # Example: # storage: "1Gi" storage: "" - # Data storage class name. + # The storage class name used for dynamically provisioning a persistent volume for the PostgreSQL storage. # Default: "longhorn" # Example: # storageClassName: "longhorn" From 70f556eb30e5c2d425d5adaff866a989d24256ab Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Wed, 10 May 2023 15:02:20 +0800 Subject: [PATCH 011/117] postgres: Minor update to descriptions --- mika/postgres/README.md | 8 ++++---- mika/postgres/values.yaml | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/mika/postgres/README.md b/mika/postgres/README.md index 194ffcaa..9aedf416 100644 --- a/mika/postgres/README.md +++ b/mika/postgres/README.md @@ -61,10 +61,10 @@ helm uninstall $release_name --namespace $namespace --wait | Key | Type | Default | Description | |-----|------|---------|-------------| -| image.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the PostgreSQL image. Default: `"IfNotPresent"`. | -| image.registry | string | `""` | The registry where the PostgreSQL image is hosted. Default: `"docker.io"`. | -| image.repository | string | `""` | The name of the repository that contains the PostgreSQL image used. Default: `"postgres"`. | -| image.tag | string | `""` | The tag that specifies the version of the PostgreSQL image used. Default: `Chart appVersion`. | +| image.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the PostgreSQL container image. Default: `"IfNotPresent"`. | +| image.registry | string | `""` | The registry where the PostgreSQL container image is hosted. Default: `"docker.io"`. | +| image.repository | string | `""` | The name of the repository that contains the PostgreSQL container image used. Default: `"postgres"`. | +| image.tag | string | `""` | The tag that specifies the version of the PostgreSQL container image used. Default: `Chart appVersion`. | | postgres.data.storage | string | `"1Gi"` | The amount of persistent storage allocated for the PostgreSQL instance. Default: `"1Gi"`. | | postgres.data.storageClassName | string | `"longhorn"` | The storage class name used for dynamically provisioning a persistent volume for the PostgreSQL storage. Default: `"longhorn"`. | | postgres.name | string | `""` | The name of the default PostgreSQL database. Default: `"default"`. | diff --git a/mika/postgres/values.yaml b/mika/postgres/values.yaml index 303d1629..a93398e4 100644 --- a/mika/postgres/values.yaml +++ b/mika/postgres/values.yaml @@ -8,16 +8,16 @@ replicaCount: "" # Container image used for PostgreSQL. image: - # The registry where the PostgreSQL image is hosted. + # The registry where the PostgreSQL container image is hosted. # Default: "docker.io" registry: "" - # The name of the repository that contains the PostgreSQL image used. + # The name of the repository that contains the PostgreSQL container image used. # Default: "postgres" repository: "" - # The tag that specifies the version of the PostgreSQL image used. + # The tag that specifies the version of the PostgreSQL container image used. # Default: Chart appVersion tag: "" - # The policy that determines when Kubernetes should pull the PostgreSQL image. + # The policy that determines when Kubernetes should pull the PostgreSQL container image. # Default: "IfNotPresent" pullPolicy: "" @@ -37,6 +37,7 @@ postgres: # Example: # pass: "password" pass: "" + # PostgreSQL data configurations. data: # The amount of persistent storage allocated for the PostgreSQL instance. # Default: "1Gi" From e186487c1162921effa0dee51d7433eb0651cd20 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Wed, 10 May 2023 19:30:50 +0800 Subject: [PATCH 012/117] Improved sample chart template and documentation --- template/CHART_NAME/Chart.yaml | 18 ++-- template/CHART_NAME/README.md | 34 ++++++- template/CHART_NAME/templates/NOTES.txt | 11 ++- template/CHART_NAME/templates/configmap.yaml | 3 +- template/CHART_NAME/templates/deployment.yaml | 19 +++- template/CHART_NAME/templates/pvc.yaml | 7 +- template/CHART_NAME/templates/secret.yaml | 3 +- template/CHART_NAME/values.yaml | 97 ++++++++++++++----- 8 files changed, 145 insertions(+), 47 deletions(-) diff --git a/template/CHART_NAME/Chart.yaml b/template/CHART_NAME/Chart.yaml index 675c25d5..8dbe0ae4 100644 --- a/template/CHART_NAME/Chart.yaml +++ b/template/CHART_NAME/Chart.yaml @@ -1,16 +1,16 @@ apiVersion: v2 name: CHART_NAME -description: A Helm chart for deploying CHART_NAME +description: A Helm chart for deploying CHART_NAME. type: application version: 0.1.0 -appVersion: "0.0.1" +appVersion: "0.0.1-r1" keywords: - - CHART_NAME -home: https://github.com/irfanhakim-as/charts -icon: https://irfanhakim-as.github.io/charts/logos/CHART_NAME.png + - "CHART_NAME" +home: "https://github.com/irfanhakim-as/charts" +icon: "https://irfanhakim-as.github.io/charts/logos/CHART_NAME.png" sources: - - https://github.com/irfanhakim-as/charts + - "https://github.com/irfanhakim-as/charts" maintainers: - - name: Irfan Hakim - email: irfanhakim.as@yahoo.com - url: https://github.com/irfanhakim-as + - name: "Irfan Hakim" + email: "irfanhakim.as@yahoo.com" + url: "https://github.com/irfanhakim-as" diff --git a/template/CHART_NAME/README.md b/template/CHART_NAME/README.md index 794b89ee..ebde9ea0 100644 --- a/template/CHART_NAME/README.md +++ b/template/CHART_NAME/README.md @@ -29,7 +29,7 @@ Copy `values.yaml` from the chart you would like to install. cp mika/CHART_NAME/values.yaml . ``` -Edit `values.yaml` with the appropriate values. +Edit `values.yaml` with the appropriate values. Please refer to the [Configurations](#configurations) section below, or the `values.yaml` file itself for details and sample values. ```sh nano values.yaml @@ -49,10 +49,40 @@ Verify that your chart has been installed. Replace `$namespace` and `$release_na helm ls --namespace $namespace | grep "$release_name" ``` +## How to upgrade + +After making any necessary changes to the `values.yaml` file, upgrade the desired chart. Replace `$release_name` and `$namespace` accordingly. + +```sh +helm upgrade $release_name mika/CHART_NAME --namespace $namespace --values values.yaml --wait +``` + ## How to uninstall Uninstall the desired chart. Replace `$release_name` and `$namespace` accordingly. ```sh helm uninstall $release_name --namespace $namespace --wait -``` \ No newline at end of file +``` + +## Configurations + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| CHART_NAME.bar | string | `""` | The secret value of the CHART_NAME bar. Default: `"bar"`. | +| CHART_NAME.data.storage | string | `""` | The amount of persistent storage allocated for the CHART_NAME instance. Default: `"1Gi"`. | +| CHART_NAME.data.storageClassName | string | `""` | The storage class name used for dynamically provisioning a persistent volume for the CHART_NAME storage. Default: `"longhorn"`. | +| CHART_NAME.foo | string | `""` | The value of the CHART_NAME foo. Default: `"foo"`. | +| image.CHART_NAME.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the CHART_NAME container image. Default: `"IfNotPresent"`. | +| image.CHART_NAME.registry | string | `""` | The registry where the CHART_NAME container image is hosted. Default: `"docker.io"`. | +| image.CHART_NAME.repository | string | `""` | The name of the repository that contains the CHART_NAME container image used. Default: `"CHART_NAME"`. | +| image.CHART_NAME.tag | string | `""` | The tag that specifies the version of the CHART_NAME container image used. Default: `Chart appVersion`. | +| image.init.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the Init container image. Default: `"IfNotPresent"`. | +| image.init.registry | string | `""` | The registry where the Init container image is hosted. Default: `"docker.io"`. | +| image.init.repository | string | `""` | The name of the repository that contains the Init container image used. Default: `"busybox"`. | +| image.init.tag | string | `""` | The tag that specifies the version of the Init container image used. Default: `"1.34"`. | +| replicaCount | int | `""` | The desired number of running replicas for CHART_NAME. Default: `"1"`. | +| resources.limits.cpu | string | `"250m"` | The maximum amount of CPU resources allowed for CHART_NAME. | +| resources.limits.memory | string | `"250Mi"` | The maximum amount of memory allowed for CHART_NAME. | +| resources.requests.cpu | string | `"10m"` | The minimum amount of CPU resources required by CHART_NAME. | +| resources.requests.memory | string | `"10Mi"` | The minimum amount of memory required by CHART_NAME. | \ No newline at end of file diff --git a/template/CHART_NAME/templates/NOTES.txt b/template/CHART_NAME/templates/NOTES.txt index 3db88605..30fb25e5 100644 --- a/template/CHART_NAME/templates/NOTES.txt +++ b/template/CHART_NAME/templates/NOTES.txt @@ -1 +1,10 @@ -CHART_NAME is now installed and configured. +CHART_NAME is now installed and configured for {{ .Release.Name | toString }}. + +Shown below are some of the values that were configured for this release: + +Foo: {{ .Values.CHART_NAME.foo | toString }} +Bar: {{ .Values.CHART_NAME.bar | toString }} + +See the values.yaml file of this chart for more configuration options. + +Please refer to the official documentation for more information on how to use CHART_NAME. diff --git a/template/CHART_NAME/templates/configmap.yaml b/template/CHART_NAME/templates/configmap.yaml index 514b9c43..7a0e75b9 100644 --- a/template/CHART_NAME/templates/configmap.yaml +++ b/template/CHART_NAME/templates/configmap.yaml @@ -1,3 +1,4 @@ +{{- $foo := .Values.CHART_NAME.foo | default "foo" | toString | quote }} apiVersion: v1 kind: ConfigMap metadata: @@ -5,4 +6,4 @@ metadata: labels: {{- include "CHART_NAME.labels" . | nindent 4 }} data: - FOO: "{{ .Values.configmap.CHART_NAME.FOO }}" + FOO: {{ $foo }} diff --git a/template/CHART_NAME/templates/deployment.yaml b/template/CHART_NAME/templates/deployment.yaml index 172babfc..8274a980 100644 --- a/template/CHART_NAME/templates/deployment.yaml +++ b/template/CHART_NAME/templates/deployment.yaml @@ -1,3 +1,12 @@ +{{- $replica_count := .Values.replicaCount | default "1" | toString }} +{{- $init_registry := .Values.image.init.registry | default "docker.io" | toString }} +{{- $init_repository := .Values.image.init.repository | default "busybox" | toString }} +{{- $init_tag := .Values.image.init.tag | default "1.34" | toString }} +{{- $init_pullPolicy := .Values.image.init.pullPolicy | default "IfNotPresent" | toString | quote }} +{{- $CHART_NAME_registry := .Values.image.CHART_NAME.registry | default "docker.io" | toString }} +{{- $CHART_NAME_repository := .Values.image.CHART_NAME.repository | default "CHART_NAME" | toString }} +{{- $CHART_NAME_tag := .Values.image.CHART_NAME.tag | default .Chart.AppVersion | toString }} +{{- $CHART_NAME_pullPolicy := .Values.image.CHART_NAME.pullPolicy | default "IfNotPresent" | toString | quote }} apiVersion: apps/v1 kind: Deployment metadata: @@ -5,7 +14,7 @@ metadata: labels: {{- include "CHART_NAME.labels" . | nindent 4 }} spec: - replicas: {{ .Values.replicaCount | default 1 }} + replicas: {{ int $replica_count }} selector: matchLabels: {{- include "CHART_NAME.selectorLabels" . | nindent 6 }} @@ -20,8 +29,8 @@ spec: spec: initContainers: - name: init - image: "{{ .Values.image.init.registry }}/{{ .Values.image.init.repository }}:{{ .Values.image.init.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.init.pullPolicy }} + image: {{ printf "%s/%s:%s" $init_registry $init_repository $init_tag | quote }} + imagePullPolicy: {{ $init_pullPolicy }} command: ["/bin/sh"] args: - -c @@ -33,8 +42,8 @@ spec: mountPath: /opt/CHART_NAME containers: - name: CHART_NAME - image: "{{ .Values.image.CHART_NAME.registry }}/{{ .Values.image.CHART_NAME.repository }}:{{ .Values.image.CHART_NAME.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.CHART_NAME.pullPolicy }} + image: {{ printf "%s/%s:%s" $CHART_NAME_registry $CHART_NAME_repository $CHART_NAME_tag | quote }} + imagePullPolicy: {{ $CHART_NAME_pullPolicy }} ports: - name: CHART_NAME containerPort: 80 diff --git a/template/CHART_NAME/templates/pvc.yaml b/template/CHART_NAME/templates/pvc.yaml index b06ec34b..3aaaccd0 100644 --- a/template/CHART_NAME/templates/pvc.yaml +++ b/template/CHART_NAME/templates/pvc.yaml @@ -1,4 +1,5 @@ -# helm pvc +{{- $storage := .Values.CHART_NAME.data.storage | default "1Gi" | toString | quote }} +{{- $storage_class_name := .Values.CHART_NAME.data.storageClassName | default "longhorn" | toString | quote }} apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -10,5 +11,5 @@ spec: - ReadWriteMany resources: requests: - storage: {{ .Values.pvc.data.storage }} - storageClassName: {{ .Values.pvc.data.storageClassName }} + storage: {{ $storage }} + storageClassName: {{ $storage_class_name }} diff --git a/template/CHART_NAME/templates/secret.yaml b/template/CHART_NAME/templates/secret.yaml index 45a98725..a886659c 100644 --- a/template/CHART_NAME/templates/secret.yaml +++ b/template/CHART_NAME/templates/secret.yaml @@ -1,3 +1,4 @@ +{{- $bar := .Values.CHART_NAME.bar | default "bar" | toString | b64enc }} apiVersion: v1 kind: Secret metadata: @@ -6,4 +7,4 @@ metadata: {{- include "CHART_NAME.labels" . | nindent 4 }} type: Opaque data: - BAR: {{ .Values.secret.CHART_NAME.BAR | b64enc }} + BAR: {{ $bar }} diff --git a/template/CHART_NAME/values.yaml b/template/CHART_NAME/values.yaml index 7633254b..5345cde9 100644 --- a/template/CHART_NAME/values.yaml +++ b/template/CHART_NAME/values.yaml @@ -2,38 +2,85 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -replicaCount: 1 +# The desired number of running replicas for CHART_NAME. +# Default: "1" +replicaCount: "" +# Container images used for CHART_NAME. image: + # Init container image configurations. init: - registry: docker.io - repository: busybox - tag: "1.34" - pullPolicy: IfNotPresent - + # The registry where the Init container image is hosted. + # Default: "docker.io" + registry: "" + # The name of the repository that contains the Init container image used. + # Default: "busybox" + repository: "" + # The tag that specifies the version of the Init container image used. + # Default: "1.34" + tag: "" + # The policy that determines when Kubernetes should pull the Init container image. + # Default: "IfNotPresent" + pullPolicy: "" + # CHART_NAME container image configurations. CHART_NAME: - registry: docker.io - repository: CHART_NAME - tag: "13.3" - pullPolicy: IfNotPresent + # The registry where the CHART_NAME container image is hosted. + # Default: "docker.io" + registry: "" + # The name of the repository that contains the CHART_NAME container image used. + # Default: "CHART_NAME" + repository: "" + # The tag that specifies the version of the CHART_NAME container image used. + # Default: Chart appVersion + tag: "" + # The policy that determines when Kubernetes should pull the CHART_NAME container image. + # Default: "IfNotPresent" + pullPolicy: "" -configmap: - CHART_NAME: - FOO: "foo" - -secret: - CHART_NAME: - BAR: "bar" - -pvc: +# CHART_NAME configurations. +CHART_NAME: + # The value of the CHART_NAME foo. + # Default: "foo" + # Example: + # foo: "foo" + foo: "" + # The secret value of the CHART_NAME bar. + # Default: "bar" + # Example: + # bar: "bar" + bar: "" + # CHART_NAME data configurations. data: - storage: "storage" - storageClassName: "storageClassName" + # The amount of persistent storage allocated for the CHART_NAME instance. + # Default: "1Gi" + # Example: + # storage: "1Gi" + storage: "" + # The storage class name used for dynamically provisioning a persistent volume for the CHART_NAME storage. + # Default: "longhorn" + # Example: + # storageClassName: "longhorn" + storageClassName: "" +# Resource requirements and limits for CHART_NAME. resources: + # The minimum amount of resources required by CHART_NAME to run. requests: - cpu: "cpu" - memory: "memory" + # The minimum amount of CPU resources required by CHART_NAME. + # Example: + # cpu: "10m" + cpu: "10m" + # The minimum amount of memory required by CHART_NAME. + # Example: + # memory: "10Mi" + memory: "10Mi" + # The maximum amount of resources allowed for CHART_NAME. limits: - cpu: "cpu" - memory: "memory" + # The maximum amount of CPU resources allowed for CHART_NAME. + # Example: + # cpu: "250m" + cpu: "250m" + # The maximum amount of memory allowed for CHART_NAME. + # Example: + # memory: "250Mi" + memory: "250Mi" From c1714dd34eb87980fee7b27f548f5b8c23cc9a13 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Wed, 10 May 2023 23:52:46 +0800 Subject: [PATCH 013/117] postgres: Update chart details --- mika/postgres/Chart.yaml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/mika/postgres/Chart.yaml b/mika/postgres/Chart.yaml index 9d0112dc..9ed8b97f 100644 --- a/mika/postgres/Chart.yaml +++ b/mika/postgres/Chart.yaml @@ -5,14 +5,16 @@ type: application version: 0.1.4 appVersion: "13.3" keywords: - - PostgreSQL - - Postgres - - Database -home: https://github.com/irfanhakim-as/charts -icon: https://irfanhakim-as.github.io/charts/logos/postgres.png + - "PostgreSQL" + - "Postgres" + - "SQL" + - "Relational" + - "Database" +home: "https://github.com/irfanhakim-as/charts" +icon: "https://irfanhakim-as.github.io/charts/logos/postgres.png" sources: - - https://github.com/irfanhakim-as/charts + - "https://github.com/irfanhakim-as/charts" maintainers: - - name: Irfan Hakim - email: irfanhakim.as@yahoo.com - url: https://github.com/irfanhakim-as + - name: "Irfan Hakim" + email: "irfanhakim.as@yahoo.com" + url: "https://github.com/irfanhakim-as" From e04f77c74eee7f2fffdf88742799c9c537191c3f Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Wed, 10 May 2023 23:53:06 +0800 Subject: [PATCH 014/117] postgres: Update chart version --- mika/postgres/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mika/postgres/Chart.yaml b/mika/postgres/Chart.yaml index 9ed8b97f..f414aa20 100644 --- a/mika/postgres/Chart.yaml +++ b/mika/postgres/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: postgres description: Easy tool to deploy a PostgreSQL instance on Kubernetes. type: application -version: 0.1.4 +version: 0.1.5 appVersion: "13.3" keywords: - "PostgreSQL" From e90a3064235a76c2a167f4a146003e4e39050374 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 11 May 2023 02:31:59 +0800 Subject: [PATCH 015/117] postgres: Update chart notes --- mika/postgres/templates/NOTES.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mika/postgres/templates/NOTES.txt b/mika/postgres/templates/NOTES.txt index 76ada238..1d671717 100644 --- a/mika/postgres/templates/NOTES.txt +++ b/mika/postgres/templates/NOTES.txt @@ -1 +1,5 @@ -PostgreSQL for {{ .Release.Name }} is now installed and configured. +PostgreSQL is now installed and configured for {{ .Release.Name | toString }}. + +See the values.yaml file of this chart for more configuration options. + +Please refer to the official documentation for more information on how to use PostgreSQL. From a9f87d826979bb1a5fac8ce503cf1d9c3529ef73 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 18 May 2023 22:31:55 +0800 Subject: [PATCH 016/117] waktusolat: Updated description in values --- mika/waktusolat/values.yaml | 156 ++++++++++++++++++++++++++---------- 1 file changed, 113 insertions(+), 43 deletions(-) diff --git a/mika/waktusolat/values.yaml b/mika/waktusolat/values.yaml index 156d8e68..00477fa1 100644 --- a/mika/waktusolat/values.yaml +++ b/mika/waktusolat/values.yaml @@ -2,80 +2,150 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -replicaCount: 1 +# The desired number of running replicas for WaktuSolat. +# Default: "1" +replicaCount: "" -# Waktu Solat image configuration +# Container images used for WaktuSolat. image: + # WaktuSolat container image configurations. waktusolat: - registry: ghcr.io - repository: irfanhakim-as/waktusolat + # The registry where the WaktuSolat container image is hosted. + # Default: "ghcr.io" + registry: "" + # The name of the repository that contains the WaktuSolat container image used. + # Default: "irfanhakim-as/waktusolat" + repository: "" + # The tag that specifies the version of the WaktuSolat container image used. + # Default: Chart appVersion tag: "" - pullPolicy: IfNotPresent + # The policy that determines when Kubernetes should pull the WaktuSolat container image. + # Default: "IfNotPresent" + pullPolicy: "" + # Redis container image configurations. redis: - registry: docker.io - repository: redis - tag: "alpine" - pullPolicy: IfNotPresent + # The registry where the Redis container image is hosted. + # Default: "docker.io" + registry: "" + # The name of the repository that contains the Redis container image used. + # Default: "redis" + repository: "" + # The tag that specifies the version of the Redis container image used. + # Default: "alpine" + tag: "" + # The policy that determines when Kubernetes should pull the Redis container image. + # Default: "IfNotPresent" + pullPolicy: "" -# Image pull secrets for private registries -imagePullSecrets: - - name: ghcr-token-secret +# Credentials used to securely authenticate and authorise the pulling of container images from private registries. +# Example: +# imagePullSecrets: +# - name: "ghcr-token-secret" +imagePullSecrets: [] -# Waktu Solat configuration +# WaktuSolat configurations. waktusolat: - # Waktu Solat debug mode + # Specifies whether WaktuSolat should run in debug mode. + # Example: + # debug: true debug: false - # Waktu Solat secret key + # A 50-character secret key used for secure session management and cryptographic operations within the WaktuSolat service. + # Example: + # secret: "6&p4%t)-$8a14fmfh92py8j55+us51r6%e52dzy&=a3-6yd4#e" secret: "" - # Default location code - location: "wlp-0" - # Timezone of the background scheduler + # The default location code used by WaktuSolat and its services. + # Default: "wlp-0" + # Example: + # location: "wlp-0" + location: "" + # The timezone for the Celery task scheduler used by WaktuSolat to schedule time-dependent operations. + # Default: "Asia/Kuala_Lumpur" + # Example: + # celery_timezone: "Asia/Kuala_Lumpur" celery_timezone: "Asia/Kuala_Lumpur" - # Mastodon configuration + # WaktuSolat Mastodon configurations. mastodon: - # Base API URL - api: "https://botsin.space/" - # Mastodon token secret + # API endpoint or URL for the Mastodon instance of the WaktuSolat bot. + # Example: + # api: "https://botsin.space/" + api: "" + # A secure token required to authenticate the WaktuSolat service with the Mastodon instance's API. + # Example: + # token: "6&p4%t)-$8a14fmfh92py8j55+us51r6%e52dzy&=a3-6yd4#e" token: "" -# Database configuration +# Database configurations. db: - # Database type - type: "postgresql" - # Database name + # The type of the database used by WaktuSolat. + # Default: "postgresql" + # Example: + # type: "postgresql" + type: "" + # The name of the database used by WaktuSolat. + # Example: + # name: "waktusolat" name: "" - # Database user + # The username or user account for accessing the WaktuSolat database. + # Example: + # user: "root" user: "" - # Database user password + # The password associated with the WaktuSolat database's user. + # Example: + # password: "password" password: "" - # Database server - host: "postgres.default.svc.cluster.local" - # Database port - port: "5432" + # The hostname or IP address of the WaktuSolat database server. + # Example: + # host: "waktusolat.default.svc.cluster.local" + host: "" + # The port number on which the WaktuSolat database server is listening. + # Default: "5432" + # Example: + # port: "5432" + port: "" -# Waktu Solat system resources +# Resource requirements and limits for WaktuSolat containers. resources: - # Waktu Solat container resources + # WaktuSolat container resources. waktusolat: + # The minimum amount of resources required by WaktuSolat to run. requests: - # Minimum CPU allocation + # The minimum amount of CPU resources required by WaktuSolat. + # Example: + # cpu: "20m" cpu: "20m" - # Minimum memory allocation + # The minimum amount of memory required by WaktuSolat. + # Example: + # memory: "250Mi" memory: "250Mi" + # The maximum amount of resources allowed for WaktuSolat. limits: - # Maximum CPU allocation + # The maximum amount of CPU resources allowed for WaktuSolat. + # Example: + # cpu: "50m" cpu: "50m" - # Maximum memory allocation + # The maximum amount of memory allowed for WaktuSolat. + # Example: + # memory: "450Mi" memory: "450Mi" - # Redis container resources + # Redis container resources. redis: + # The minimum amount of resources required by Redis to run. requests: - # Minimum CPU allocation + # The minimum amount of CPU resources required by Redis. + # Example: + # cpu: "5m" cpu: "5m" - # Minimum memory allocation + # The minimum amount of memory required by Redis. + # Example: + # memory: "30Mi" memory: "30Mi" + # The maximum amount of resources allowed for Redis. limits: - # Maximum CPU allocation + # The maximum amount of CPU resources allowed for Redis. + # Example: + # cpu: "15m" cpu: "15m" - # Maximum memory allocation + # The maximum amount of memory allowed for Redis. + # Example: + # memory: "50Mi" memory: "50Mi" From a1f012fd09d20c57e657d2847ca8a34713982b43 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sun, 21 May 2023 23:56:19 +0800 Subject: [PATCH 017/117] Minor update to comment --- template/CHART_NAME/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/CHART_NAME/values.yaml b/template/CHART_NAME/values.yaml index 5345cde9..92266643 100644 --- a/template/CHART_NAME/values.yaml +++ b/template/CHART_NAME/values.yaml @@ -62,7 +62,7 @@ CHART_NAME: # storageClassName: "longhorn" storageClassName: "" -# Resource requirements and limits for CHART_NAME. +# Resource requirements and limits for CHART_NAME container. resources: # The minimum amount of resources required by CHART_NAME to run. requests: From 080cd21d49db786e3820d0ffb9357c353995b68a Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Mon, 22 May 2023 01:06:01 +0800 Subject: [PATCH 018/117] waktusolat: Update values and add default values to template --- mika/waktusolat/templates/configmap.yaml | 17 ++++++++++------ mika/waktusolat/templates/deployment.yaml | 19 +++++++++++++----- mika/waktusolat/templates/secret.yaml | 24 +++++++++++++++-------- 3 files changed, 41 insertions(+), 19 deletions(-) diff --git a/mika/waktusolat/templates/configmap.yaml b/mika/waktusolat/templates/configmap.yaml index 391d870c..1f94c0fc 100644 --- a/mika/waktusolat/templates/configmap.yaml +++ b/mika/waktusolat/templates/configmap.yaml @@ -1,3 +1,8 @@ +{{- $debug := .Values.waktusolat.debug | default "false" | toString | quote }} +{{- $location := .Values.waktusolat.location | default "wlp-0" | toString | quote }} +{{- $api := .Values.waktusolat.mastodon.api | toString | quote }} +{{- $redis_service := printf "redis://%s-waktusolat-svc" .Release.Name | quote }} +{{- $celery_timezone := .Values.waktusolat.celery_timezone | default "Asia/Kuala_Lumpur" | toString | quote }} {{- $domain := .Values.waktusolat.domain | default "localhost" | toString }} apiVersion: v1 kind: ConfigMap @@ -6,12 +11,12 @@ metadata: labels: {{- include "waktusolat.labels" . | nindent 4 }} data: - DEBUG: {{ .Values.waktusolat.debug | toString | quote }} - LOCATION_CODE: {{ .Values.waktusolat.location | toString | quote }} - API_BASE_URL: {{ .Values.waktusolat.mastodon.api | toString | quote }} - CELERY_BROKER: redis://{{ .Release.Name }}-waktusolat-svc - CELERY_BACKEND: redis://{{ .Release.Name }}-waktusolat-svc - CELERY_TIMEZONE: {{ .Values.waktusolat.celery_timezone | toString | quote }} + DEBUG: {{ $debug }} + LOCATION_CODE: {{ $location }} + API_BASE_URL: {{ $api }} + CELERY_BROKER: {{ $redis_service }} + CELERY_BACKEND: {{ $redis_service }} + CELERY_TIMEZONE: {{ $celery_timezone }} --- apiVersion: v1 kind: ConfigMap diff --git a/mika/waktusolat/templates/deployment.yaml b/mika/waktusolat/templates/deployment.yaml index d385a133..c8e3601a 100644 --- a/mika/waktusolat/templates/deployment.yaml +++ b/mika/waktusolat/templates/deployment.yaml @@ -1,3 +1,12 @@ +{{- $replica_count := .Values.replicaCount | default "1" | toString }} +{{- $waktusolat_registry := .Values.image.waktusolat.registry | default "ghcr.io" | toString }} +{{- $waktusolat_repository := .Values.image.waktusolat.repository | default "irfanhakim-as/waktusolat" | toString }} +{{- $waktusolat_tag := .Values.image.waktusolat.tag | default .Chart.AppVersion | toString }} +{{- $waktusolat_pullPolicy := .Values.image.waktusolat.pullPolicy | default "IfNotPresent" | toString | quote }} +{{- $redis_registry := .Values.image.redis.registry | default "docker.io" | toString }} +{{- $redis_repository := .Values.image.redis.repository | default "redis" | toString }} +{{- $redis_tag := .Values.image.redis.tag | default "alpine" | toString }} +{{- $redis_pullPolicy := .Values.image.redis.pullPolicy | default "IfNotPresent" | toString | quote }} apiVersion: apps/v1 kind: Deployment metadata: @@ -5,7 +14,7 @@ metadata: labels: {{- include "waktusolat.labels" . | nindent 4 }} spec: - replicas: {{ .Values.replicaCount | default 1 }} + replicas: {{ int $replica_count }} selector: matchLabels: {{- include "waktusolat.selectorLabels" . | nindent 6 }} @@ -24,8 +33,8 @@ spec: {{- end }} containers: - name: waktusolat - image: "{{ .Values.image.waktusolat.registry }}/{{ .Values.image.waktusolat.repository }}:{{ .Values.image.waktusolat.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.waktusolat.pullPolicy }} + image: {{ printf "%s/%s:%s" $waktusolat_registry $waktusolat_repository $waktusolat_tag | quote }} + imagePullPolicy: {{ $waktusolat_pullPolicy }} ports: - name: waktusolat containerPort: 80 @@ -108,8 +117,8 @@ spec: subPath: mastodon.secret readOnly: true - name: redis - image: "{{ .Values.image.redis.registry }}/{{ .Values.image.redis.repository }}:{{ .Values.image.redis.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.redis.pullPolicy }} + image: {{ printf "%s/%s:%s" $redis_registry $redis_repository $redis_tag | quote }} + imagePullPolicy: {{ $redis_pullPolicy }} ports: - name: redis containerPort: 6379 diff --git a/mika/waktusolat/templates/secret.yaml b/mika/waktusolat/templates/secret.yaml index 0ff8ce34..03556589 100644 --- a/mika/waktusolat/templates/secret.yaml +++ b/mika/waktusolat/templates/secret.yaml @@ -1,3 +1,11 @@ +{{- $secret := .Values.waktusolat.secret | toString | b64enc }} +{{- $db_type := .Values.db.type | default "postgresql" | toString | b64enc }} +{{- $db_name := .Values.db.name | toString | b64enc }} +{{- $db_user := .Values.db.user | toString | b64enc }} +{{- $db_password := .Values.db.password | toString | b64enc }} +{{- $db_host := .Values.db.host | toString | b64enc }} +{{- $db_port := .Values.db.port | default "5432" | toString | b64enc }} +{{- $token := .Values.waktusolat.mastodon.token | toString | b64enc }} apiVersion: v1 kind: Secret metadata: @@ -6,13 +14,13 @@ metadata: {{- include "waktusolat.labels" . | nindent 4 }} type: Opaque data: - SECRET_KEY: {{ .Values.waktusolat.secret | toString | b64enc }} - DB_TYPE: {{ .Values.db.type | toString | b64enc }} - DB_NAME: {{ .Values.db.name | toString | b64enc }} - DB_USER: {{ .Values.db.user | toString | b64enc }} - DB_PASS: {{ .Values.db.password | toString | b64enc }} - DB_HOST: {{ .Values.db.host | toString | b64enc }} - DB_PORT: {{ .Values.db.port | toString | b64enc }} + SECRET_KEY: {{ $secret }} + DB_TYPE: {{ $db_type }} + DB_NAME: {{ $db_name }} + DB_USER: {{ $db_user }} + DB_PASS: {{ $db_password }} + DB_HOST: {{ $db_host }} + DB_PORT: {{ $db_port }} --- apiVersion: v1 kind: Secret @@ -23,4 +31,4 @@ metadata: type: Opaque data: mastodon.secret: |- - {{ .Values.waktusolat.mastodon.token | toString | b64enc | nindent 4 }} + {{ $token | nindent 4 }} From 420520e2c4e451b27a3c2e3cda93f327b935845d Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Mon, 22 May 2023 01:21:46 +0800 Subject: [PATCH 019/117] waktusolat: Add default value info for debug --- mika/waktusolat/values.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/mika/waktusolat/values.yaml b/mika/waktusolat/values.yaml index 00477fa1..09fcc064 100644 --- a/mika/waktusolat/values.yaml +++ b/mika/waktusolat/values.yaml @@ -46,6 +46,7 @@ imagePullSecrets: [] # WaktuSolat configurations. waktusolat: # Specifies whether WaktuSolat should run in debug mode. + # Default: false # Example: # debug: true debug: false From 796a0d9ea64fa894134b666e3d64186c7a7a5324 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Mon, 22 May 2023 01:22:55 +0800 Subject: [PATCH 020/117] waktusolat: Update values documentation --- mika/waktusolat/README.md | 62 +++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/mika/waktusolat/README.md b/mika/waktusolat/README.md index b7fd571c..d078a872 100644 --- a/mika/waktusolat/README.md +++ b/mika/waktusolat/README.md @@ -73,37 +73,37 @@ Uninstall the desired chart. Replace `$release_name` and `$namespace` accordingl helm uninstall $release_name --namespace $namespace --wait ``` -## Configuration +## Configurations | Key | Type | Default | Description | |-----|------|---------|-------------| -| db.host | string | `"postgres.default.svc.cluster.local"` | Database server | -| db.name | string | `""` | Database name | -| db.password | string | `""` | Database user password | -| db.port | string | `"5432"` | Database port | -| db.type | string | `"postgresql"` | Database type | -| db.user | string | `""` | Database user | -| image.redis.pullPolicy | string | `"IfNotPresent"` | Redis image pull policy | -| image.redis.registry | string | `"docker.io"` | Redis image registry | -| image.redis.repository | string | `"redis"` | Redis image repository | -| image.redis.tag | string | `"alpine"` | Redis image version | -| image.waktusolat.pullPolicy | string | `"IfNotPresent"` | Waktu Solat image pull policy | -| image.waktusolat.registry | string | `"ghcr.io"` | Waktu Solat image registry | -| image.waktusolat.repository | string | `"irfanhakim-as/waktusolat"` | Waktu Solat image repository | -| image.waktusolat.tag | string | `""` | Waktu Solat image version | -| imagePullSecrets[0].name | string | `"ghcr-token-secret"` | Image pull secret name | -| replicaCount | int | `1` | Waktu Solat replica count | -| resources.redis.limits.cpu | string | `"15m"` | Redis maximum cpu allocation | -| resources.redis.limits.memory | string | `"50Mi"` | Redis maximum memory allocation | -| resources.redis.requests.cpu | string | `"5m"` | Redis minimum cpu allocation | -| resources.redis.requests.memory | string | `"30Mi"` | Redis minimum memory allocation | -| resources.waktusolat.limits.cpu | string | `"50m"` | Waktu Solat maximum cpu allocation | -| resources.waktusolat.limits.memory | string | `"450Mi"` | Waktu Solat maximum memory allocation | -| resources.waktusolat.requests.cpu | string | `"20m"` | Waktu Solat minimum cpu allocation | -| resources.waktusolat.requests.memory | string | `"250Mi"` | Waktu Solat minimum memory allocation | -| waktusolat.celery_timezone | string | `"Asia/Kuala_Lumpur"` | Timezone of the background scheduler | -| waktusolat.debug | bool | `false` | Waktu Solat debug mode | -| waktusolat.location | string | `"wlp-0"` | Default location code | -| waktusolat.mastodon.api | string | `"https://botsin.space/"` | Mastodon base API URL | -| waktusolat.mastodon.token | string | `""` | Mastodon token secret | -| waktusolat.secret | string | `""` | Waktu Solat secret key | +| db.host | string | `""` | The hostname or IP address of the WaktuSolat database server. | +| db.name | string | `""` | The name of the database used by WaktuSolat. | +| db.password | string | `""` | The password associated with the WaktuSolat database's user. | +| db.port | string | `""` | The port number on which the WaktuSolat database server is listening. Default: `"5432"`. | +| db.type | string | `""` | The type of the database used by WaktuSolat. Default: `"postgresql"`. | +| db.user | string | `""` | The username or user account for accessing the WaktuSolat database. | +| image.redis.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the Redis container image. Default: `"alpine"`. | +| image.redis.registry | string | `""` | The registry where the Redis container image is hosted. Default: `"docker.io"`. | +| image.redis.repository | string | `""` | The name of the repository that contains the Redis container image used. Default: `"redis"`. | +| image.redis.tag | string | `""` | The tag that specifies the version of the Redis container image used. Default: `"alpine"`. | +| image.waktusolat.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the WaktuSolat container image. Default: `"IfNotPresent"`. | +| image.waktusolat.registry | string | `""` | The registry where the WaktuSolat container image is hosted. Default: `"ghcr.io"`. | +| image.waktusolat.repository | string | `""` | The name of the repository that contains the WaktuSolat container image used. Default: `"irfanhakim-as/waktusolat"`. | +| image.waktusolat.tag | string | `""` | The tag that specifies the version of the WaktuSolat container image used. Default: `Chart appVersion`. | +| imagePullSecrets | list | `[]` | Credentials used to securely authenticate and authorise the pulling of container images from private registries. | +| replicaCount | string | `""` | The desired number of running replicas for WaktuSolat. Default: `"1"`. | +| resources.redis.limits.cpu | string | `"15m"` | The maximum amount of CPU resources allowed for Redis. | +| resources.redis.limits.memory | string | `"50Mi"` | The maximum amount of memory allowed for Redis. | +| resources.redis.requests.cpu | string | `"5m"` | The minimum amount of CPU resources required by Redis. | +| resources.redis.requests.memory | string | `"30Mi"` | The minimum amount of memory required by Redis. | +| resources.waktusolat.limits.cpu | string | `"50m"` | The maximum amount of CPU resources allowed for WaktuSolat. | +| resources.waktusolat.limits.memory | string | `"450Mi"` | The maximum amount of memory allowed for WaktuSolat. | +| resources.waktusolat.requests.cpu | string | `"20m"` | The minimum amount of CPU resources required by WaktuSolat. | +| resources.waktusolat.requests.memory | string | `"250Mi"` | The minimum amount of memory required by WaktuSolat. | +| waktusolat.celery_timezone | string | `"Asia/Kuala_Lumpur"` | The timezone for the Celery task scheduler used by WaktuSolat to schedule time-dependent operations. Default: `"Asia/Kuala_Lumpur"`. | +| waktusolat.debug | bool | `false` | Specifies whether WaktuSolat should run in debug mode. Default: `false`. | +| waktusolat.location | string | `""` | The default location code used by WaktuSolat and its services. Default: `"wlp-0"`. | +| waktusolat.mastodon.api | string | `""` | API endpoint or URL for the Mastodon instance of the WaktuSolat bot. | +| waktusolat.mastodon.token | string | `""` | A secure token required to authenticate the WaktuSolat service with the Mastodon instance's API. | +| waktusolat.secret | string | `""` | A 50-character secret key used for secure session management and cryptographic operations within the WaktuSolat service. | From f6bd57bfc5c621be547ffaab7a913101584f9e2e Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Mon, 22 May 2023 01:30:51 +0800 Subject: [PATCH 021/117] waktusolat: Update notes --- mika/waktusolat/templates/NOTES.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mika/waktusolat/templates/NOTES.txt b/mika/waktusolat/templates/NOTES.txt index fbe4247e..786eb894 100644 --- a/mika/waktusolat/templates/NOTES.txt +++ b/mika/waktusolat/templates/NOTES.txt @@ -1 +1,5 @@ -waktusolat is now installed and configured for {{ .Release.Name }}. +waktusolat is now installed and configured for {{ .Release.Name | toString }}. + +See the values.yaml file of this chart for more configuration options. + +Please refer to the official documentation for more information on how to use waktusolat. From 3ea19c652d2642c45cae538b610ca1fed7bcc492 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Mon, 22 May 2023 01:34:47 +0800 Subject: [PATCH 022/117] waktusolat: Update chart details --- mika/waktusolat/Chart.yaml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mika/waktusolat/Chart.yaml b/mika/waktusolat/Chart.yaml index 525dbc71..98079702 100644 --- a/mika/waktusolat/Chart.yaml +++ b/mika/waktusolat/Chart.yaml @@ -5,15 +5,15 @@ type: application version: 0.1.3 appVersion: "0.0.2-stable" keywords: - - waktu solat - - prayer time - - mastodon -home: https://github.com/irfanhakim-as/waktusolat -icon: https://irfanhakim-as.github.io/charts/logos/mika.png + - "waktu solat" + - "prayer time" + - "mastodon" +home: "https://github.com/irfanhakim-as/waktusolat" +icon: "https://irfanhakim-as.github.io/charts/logos/mika.png" sources: - - https://github.com/irfanhakim-as/waktusolat - - https://github.com/irfanhakim-as/charts + - "https://github.com/irfanhakim-as/waktusolat" + - "https://github.com/irfanhakim-as/charts" maintainers: - - name: Irfan Hakim - email: irfanhakim.as@yahoo.com - url: https://github.com/irfanhakim-as + - name: "Irfan Hakim" + email: "irfanhakim.as@yahoo.com" + url: "https://github.com/irfanhakim-as" From 39d781669479ec23a1322dd4fadba51cde14c8d2 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Mon, 22 May 2023 01:35:00 +0800 Subject: [PATCH 023/117] waktusolat: Update chart version --- mika/waktusolat/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mika/waktusolat/Chart.yaml b/mika/waktusolat/Chart.yaml index 98079702..2efe28d4 100644 --- a/mika/waktusolat/Chart.yaml +++ b/mika/waktusolat/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: waktusolat description: Waktu Solat is a simple web application that posts local prayer times on Mastodon. type: application -version: 0.1.3 +version: 0.1.4 appVersion: "0.0.2-stable" keywords: - "waktu solat" From d17267e70f219f44fe45f92d2da66b2bd2817260 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Tue, 23 May 2023 17:35:19 +0800 Subject: [PATCH 024/117] postgres-agent: Update chart values --- mika/postgres-agent/README.md | 28 ++++----- mika/postgres-agent/templates/deployment.yaml | 13 ++-- mika/postgres-agent/templates/secret.yaml | 18 ++++-- mika/postgres-agent/values.yaml | 60 ++++++++++++++----- 4 files changed, 81 insertions(+), 38 deletions(-) diff --git a/mika/postgres-agent/README.md b/mika/postgres-agent/README.md index 6d2bbb85..95effd19 100644 --- a/mika/postgres-agent/README.md +++ b/mika/postgres-agent/README.md @@ -29,7 +29,7 @@ Install [`mika/postgres`](../postgres/). This step can be skipped if you have an ### Prepare chart values -Copy `values.yaml` from the chart you would like to install. Refer to the [Configuration](#configuration) section for more information. +Copy `values.yaml` from the chart you would like to install. Refer to the [Configurations](#configurations) section for more information. ```sh cp mika/postgres-agent/values.yaml . @@ -63,19 +63,19 @@ Uninstall the desired chart. Replace `$release_name` and `$namespace` accordingl helm uninstall $release_name --namespace $namespace --wait ``` -## Configuration +## Configurations | Key | Type | Default | Description | |-----|------|---------|-------------| -| image.postgres.pullPolicy | string | `"IfNotPresent"` | Postgres image pull policy | -| image.postgres.registry | string | `"docker.io"` | Postgres image registry | -| image.postgres.repository | string | `"postgres"` | Postgres image repository | -| image.postgres.tag | string | `""` | Postgres image version | -| postgres.host | string | `"postgres.default.svc.cluster.local"` | Postgres server | -| postgres.mode.create | bool | `true` | Enable create database and user mode | -| postgres.mode.drop | bool | `false` | Enable drop database mode | -| postgres.name | string | `""` | Database name | -| postgres.pass | string | `""` | Database user password. Only required in create mode. | -| postgres.root.pass | string | `""` | Database root user password | -| postgres.root.user | string | `""` | Database root user | -| postgres.user | string | `""` | Database user. Only required in create mode. | +| image.postgres.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the PostgreSQL container image. Default: `"IfNotPresent"`. | +| image.postgres.registry | string | `""` | The registry where the PostgreSQL container image is hosted. Default: `"docker.io"`. | +| image.postgres.repository | string | `""` | The name of the repository that contains the PostgreSQL container image used. Default: `"postgres"`. | +| image.postgres.tag | string | `""` | The tag that specifies the version of the PostgreSQL container image used. Default: `Chart appVersion`. | +| postgres.host | string | `""` | The hostname or IP address of the PostgreSQL database server. | +| postgres.mode.create | bool | `true` | Specifies whether to create a database and user in a remote PostgreSQL instance. Default: `true`. | +| postgres.mode.drop | bool | `false` | Specifies whether to delete a database in a remote PostgreSQL instance. Default: `false`. | +| postgres.name | string | `""` | The name of the intended PostgreSQL database. | +| postgres.password | string | `""` | The password associated with the intended PostgreSQL database user. | +| postgres.root.password | string | `""` | The password associated with the PostgreSQL database server root user. | +| postgres.root.user | string | `""` | The username or user account for accessing the PostgreSQL database server as root. Default: `"root"`. | +| postgres.user | string | `""` | The username or user account for accessing the intended PostgreSQL database. | diff --git a/mika/postgres-agent/templates/deployment.yaml b/mika/postgres-agent/templates/deployment.yaml index e10987d5..563a8795 100644 --- a/mika/postgres-agent/templates/deployment.yaml +++ b/mika/postgres-agent/templates/deployment.yaml @@ -1,3 +1,8 @@ +{{- $registry := .Values.image.postgres.registry | default "docker.io" | toString }} +{{- $repository := .Values.image.postgres.repository | default "postgres" | toString }} +{{- $tag := .Values.image.postgres.tag | default .Chart.AppVersion | toString }} +{{- $pullPolicy := .Values.image.postgres.pullPolicy | default "IfNotPresent" | toString | quote }} +{{- $create_mode := .Values.postgres.mode.create | default true }} apiVersion: batch/v1 kind: Job metadata: @@ -18,11 +23,11 @@ spec: spec: containers: - name: postgres-agent - image: "{{ .Values.image.postgres.registry }}/{{ .Values.image.postgres.repository }}:{{ .Values.image.postgres.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.postgres.pullPolicy }} + image: {{ printf "%s/%s:%s" $registry $repository $tag | quote }} + imagePullPolicy: {{ $pullPolicy }} resources: {{- toYaml .Values.resources | nindent 12 }} - {{- if .Values.postgres.mode.create }} + {{- if $create_mode }} command: ["/bin/sh"] args: - -c @@ -47,7 +52,7 @@ spec: secretKeyRef: name: {{ .Release.Name }}-postgres-agent-secret key: DB_NAME - {{- if .Values.postgres.mode.create }} + {{- if $create_mode }} - name: DB_USER valueFrom: secretKeyRef: diff --git a/mika/postgres-agent/templates/secret.yaml b/mika/postgres-agent/templates/secret.yaml index b01bb8f0..14cf1f1e 100644 --- a/mika/postgres-agent/templates/secret.yaml +++ b/mika/postgres-agent/templates/secret.yaml @@ -1,3 +1,9 @@ +{{- $db_host := .Values.postgres.host | toString | b64enc }} +{{- $db_name := .Values.postgres.name | toString | b64enc }} +{{- $db_user := .Values.postgres.user | toString | b64enc }} +{{- $db_password := .Values.postgres.password | toString | b64enc }} +{{- $root_user := .Values.postgres.root.user | default "root" | toString | b64enc }} +{{- $root_password := .Values.postgres.root.password | toString | b64enc }} apiVersion: v1 kind: Secret metadata: @@ -6,9 +12,9 @@ metadata: {{- include "postgres-agent.labels" . | nindent 4 }} type: Opaque data: - DB_HOST: {{ .Values.postgres.host | toString | b64enc }} - DB_NAME: {{ .Values.postgres.name | toString | b64enc }} - DB_USER: {{ .Values.postgres.user | toString | b64enc }} - DB_PASS: {{ .Values.postgres.pass | toString | b64enc }} - ROOT_USER: {{ .Values.postgres.root.user | toString | b64enc }} - ROOT_PASS: {{ .Values.postgres.root.pass | toString | b64enc }} + DB_HOST: {{ $db_host }} + DB_NAME: {{ $db_name }} + DB_USER: {{ $db_user }} + DB_PASS: {{ $db_password }} + ROOT_USER: {{ $root_user }} + ROOT_PASS: {{ $root_password }} diff --git a/mika/postgres-agent/values.yaml b/mika/postgres-agent/values.yaml index 1ba6a009..0ecaa338 100644 --- a/mika/postgres-agent/values.yaml +++ b/mika/postgres-agent/values.yaml @@ -2,29 +2,61 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. +# Container images used for PostgreSQL. image: + # PostgreSQL container image configurations. postgres: - registry: docker.io - repository: postgres + # The registry where the PostgreSQL container image is hosted. + # Default: "docker.io" + registry: "" + # The name of the repository that contains the PostgreSQL container image used. + # Default: "postgres" + repository: "" + # The tag that specifies the version of the PostgreSQL container image used. + # Default: Chart appVersion tag: "" - pullPolicy: IfNotPresent + # The policy that determines when Kubernetes should pull the PostgreSQL container image. + # Default: "IfNotPresent" + pullPolicy: "" +# PostgreSQL configurations. postgres: - # agent mode + # Defines the mode of operation for the PostgreSQL agent chart. mode: + # Specifies whether to create a database and user in a remote PostgreSQL instance. + # Default: true + # Example: + # create: false create: true + # Specifies whether to delete a database in a remote PostgreSQL instance. + # Default: false + # Example: + # drop: true drop: false - # postgres host - host: "postgres.default.svc.cluster.local" - # postgres database name + # The hostname or IP address of the PostgreSQL database server. + # Example: + # host: "postgres.default.svc.cluster.local" + host: "" + # The name of the intended PostgreSQL database. + # Example: + # name: "postgres" name: "" - # postgres database user + # The username or user account for accessing the intended PostgreSQL database. + # Example: + # user: "postgres" user: "" - # postgres database user password - pass: "" - # postgres database root + # The password associated with the intended PostgreSQL database user. + # Example: + # password: "password" + password: "" + # PostgreSQL database server root user configurations. root: - # root postgres user + # The username or user account for accessing the PostgreSQL database server as root. + # Default: "root" + # Example: + # user: "root" user: "" - # root postgres user password - pass: "" + # The password associated with the PostgreSQL database server root user. + # Example: + # password: "password" + password: "" From fd29b6f49cfcb685dce5d5f85abd984863d8ed1f Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Tue, 23 May 2023 17:36:07 +0800 Subject: [PATCH 025/117] postgres-agent: Add quotes to chart details --- mika/postgres-agent/Chart.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mika/postgres-agent/Chart.yaml b/mika/postgres-agent/Chart.yaml index d3513fbf..03342f19 100644 --- a/mika/postgres-agent/Chart.yaml +++ b/mika/postgres-agent/Chart.yaml @@ -5,14 +5,14 @@ type: application version: 0.1.1 appVersion: "13.3" keywords: - - postgres - - agent - - job -home: https://github.com/irfanhakim-as/charts -icon: https://irfanhakim-as.github.io/charts/logos/postgres.png + - "postgres" + - "agent" + - "job" +home: "https://github.com/irfanhakim-as/charts" +icon: "https://irfanhakim-as.github.io/charts/logos/postgres.png" sources: - - https://github.com/irfanhakim-as/charts + - "https://github.com/irfanhakim-as/charts" maintainers: - - name: Irfan Hakim - email: irfanhakim.as@yahoo.com - url: https://github.com/irfanhakim-as + - name: "Irfan Hakim" + email: "irfanhakim.as@yahoo.com" + url: "https://github.com/irfanhakim-as" From 085058340b903f4f2b0512fd1e64fdad9616148e Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Tue, 23 May 2023 17:37:05 +0800 Subject: [PATCH 026/117] postgres-agent: Update chart version --- mika/postgres-agent/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mika/postgres-agent/Chart.yaml b/mika/postgres-agent/Chart.yaml index 03342f19..8e120614 100644 --- a/mika/postgres-agent/Chart.yaml +++ b/mika/postgres-agent/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: postgres-agent description: Easily deploy a database and create a user in a remote PostgreSQL instance or delete a database. type: application -version: 0.1.1 +version: 0.1.2 appVersion: "13.3" keywords: - "postgres" From 5c8149c76198c09e00a4db58b641e5d7341fadfb Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Wed, 24 May 2023 00:35:56 +0800 Subject: [PATCH 027/117] postgres-agent: Add shortened db host name to the Job name --- mika/postgres-agent/templates/deployment.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mika/postgres-agent/templates/deployment.yaml b/mika/postgres-agent/templates/deployment.yaml index 563a8795..1bc0107b 100644 --- a/mika/postgres-agent/templates/deployment.yaml +++ b/mika/postgres-agent/templates/deployment.yaml @@ -1,3 +1,4 @@ +{{- $host := .Values.postgres.host | default "postgres" | toString }} {{- $registry := .Values.image.postgres.registry | default "docker.io" | toString }} {{- $repository := .Values.image.postgres.repository | default "postgres" | toString }} {{- $tag := .Values.image.postgres.tag | default .Chart.AppVersion | toString }} @@ -6,7 +7,7 @@ apiVersion: batch/v1 kind: Job metadata: - name: {{ .Release.Name }}-postgres-agent + name: {{ printf "%s-%s-%s" (index (splitList "." $host) 0) .Release.Name "postgres-agent" }} labels: {{- include "postgres-agent.labels" . | nindent 4 }} spec: From 7f236a7fbebf9bb47ad9db57f519ac99c8f5f0a1 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Wed, 24 May 2023 00:37:10 +0800 Subject: [PATCH 028/117] postgres-agent: Add double quotes --- mika/postgres-agent/templates/deployment.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mika/postgres-agent/templates/deployment.yaml b/mika/postgres-agent/templates/deployment.yaml index 1bc0107b..d6c309cd 100644 --- a/mika/postgres-agent/templates/deployment.yaml +++ b/mika/postgres-agent/templates/deployment.yaml @@ -29,14 +29,14 @@ spec: resources: {{- toYaml .Values.resources | nindent 12 }} {{- if $create_mode }} - command: ["/bin/sh"] + command: ["/bin/bash"] args: - -c - >- psql -v ON_ERROR_STOP=1 -h $(DB_HOST) -U $(ROOT_USER) -d postgres <<-EOSQL - SELECT 'CREATE DATABASE $(DB_NAME)' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '$(DB_NAME)')\gexec - SELECT 'CREATE USER $(DB_USER) WITH PASSWORD ''$(DB_PASS)''' WHERE NOT EXISTS (SELECT FROM pg_user WHERE usename = '$(DB_USER)')\gexec - GRANT ALL PRIVILEGES ON DATABASE $(DB_NAME) TO $(DB_USER)\gexec + SELECT 'CREATE DATABASE "$(DB_NAME)"' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '$(DB_NAME)')\gexec + SELECT 'CREATE USER "$(DB_USER)" WITH PASSWORD ''$(DB_PASS)''' WHERE NOT EXISTS (SELECT FROM pg_user WHERE usename = '$(DB_USER)')\gexec + GRANT ALL PRIVILEGES ON DATABASE "$(DB_NAME)" TO "$(DB_USER)"\gexec EOSQL {{- else }} command: ["dropdb"] From 9565cad97e12557c2e3abf495ee68e24697dbb0f Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Wed, 24 May 2023 01:13:38 +0800 Subject: [PATCH 029/117] postgres-agent: Default values for helm bools do not work as you'd expect https://stackoverflow.com/a/74262000 --- mika/postgres-agent/README.md | 4 ++-- mika/postgres-agent/templates/deployment.yaml | 2 +- mika/postgres-agent/values.yaml | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/mika/postgres-agent/README.md b/mika/postgres-agent/README.md index 95effd19..c0486573 100644 --- a/mika/postgres-agent/README.md +++ b/mika/postgres-agent/README.md @@ -72,8 +72,8 @@ helm uninstall $release_name --namespace $namespace --wait | image.postgres.repository | string | `""` | The name of the repository that contains the PostgreSQL container image used. Default: `"postgres"`. | | image.postgres.tag | string | `""` | The tag that specifies the version of the PostgreSQL container image used. Default: `Chart appVersion`. | | postgres.host | string | `""` | The hostname or IP address of the PostgreSQL database server. | -| postgres.mode.create | bool | `true` | Specifies whether to create a database and user in a remote PostgreSQL instance. Default: `true`. | -| postgres.mode.drop | bool | `false` | Specifies whether to delete a database in a remote PostgreSQL instance. Default: `false`. | +| postgres.mode.create | bool | `true` | Specifies whether to create a database and user in a remote PostgreSQL instance. | +| postgres.mode.drop | bool | `false` | Specifies whether to delete a database in a remote PostgreSQL instance. | | postgres.name | string | `""` | The name of the intended PostgreSQL database. | | postgres.password | string | `""` | The password associated with the intended PostgreSQL database user. | | postgres.root.password | string | `""` | The password associated with the PostgreSQL database server root user. | diff --git a/mika/postgres-agent/templates/deployment.yaml b/mika/postgres-agent/templates/deployment.yaml index d6c309cd..302ab992 100644 --- a/mika/postgres-agent/templates/deployment.yaml +++ b/mika/postgres-agent/templates/deployment.yaml @@ -3,7 +3,7 @@ {{- $repository := .Values.image.postgres.repository | default "postgres" | toString }} {{- $tag := .Values.image.postgres.tag | default .Chart.AppVersion | toString }} {{- $pullPolicy := .Values.image.postgres.pullPolicy | default "IfNotPresent" | toString | quote }} -{{- $create_mode := .Values.postgres.mode.create | default true }} +{{- $create_mode := .Values.postgres.mode.create }} apiVersion: batch/v1 kind: Job metadata: diff --git a/mika/postgres-agent/values.yaml b/mika/postgres-agent/values.yaml index 0ecaa338..3cd49c1c 100644 --- a/mika/postgres-agent/values.yaml +++ b/mika/postgres-agent/values.yaml @@ -24,12 +24,10 @@ postgres: # Defines the mode of operation for the PostgreSQL agent chart. mode: # Specifies whether to create a database and user in a remote PostgreSQL instance. - # Default: true # Example: # create: false create: true # Specifies whether to delete a database in a remote PostgreSQL instance. - # Default: false # Example: # drop: true drop: false From 5415af3355b60684d5dd12677019f4187f4ac5bb Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Wed, 24 May 2023 01:17:09 +0800 Subject: [PATCH 030/117] postgres-agent: Dropping databases now also support dropping users --- mika/postgres-agent/templates/deployment.yaml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mika/postgres-agent/templates/deployment.yaml b/mika/postgres-agent/templates/deployment.yaml index 302ab992..815e21f4 100644 --- a/mika/postgres-agent/templates/deployment.yaml +++ b/mika/postgres-agent/templates/deployment.yaml @@ -39,8 +39,14 @@ spec: GRANT ALL PRIVILEGES ON DATABASE "$(DB_NAME)" TO "$(DB_USER)"\gexec EOSQL {{- else }} - command: ["dropdb"] - args: ["-h", "$(DB_HOST)", "-U", "$(ROOT_USER)", "$(DB_NAME)"] + command: ["/bin/bash"] + args: + - -c + - >- + psql -v ON_ERROR_STOP=1 -h $(DB_HOST) -U $(ROOT_USER) -d postgres <<-EOSQL + SELECT 'DROP DATABASE "$(DB_NAME)"' WHERE EXISTS (SELECT FROM pg_database WHERE datname = '$(DB_NAME)')\gexec + SELECT 'DROP USER "$(DB_USER)"' WHERE EXISTS (SELECT FROM pg_user WHERE usename = '$(DB_USER)')\gexec + EOSQL {{- end }} env: - name: DB_HOST @@ -53,12 +59,12 @@ spec: secretKeyRef: name: {{ .Release.Name }}-postgres-agent-secret key: DB_NAME - {{- if $create_mode }} - name: DB_USER valueFrom: secretKeyRef: name: {{ .Release.Name }}-postgres-agent-secret key: DB_USER + {{- if $create_mode }} - name: DB_PASS valueFrom: secretKeyRef: From 0647680b5c521d754518da2b2ab7abf06b0b7008 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Wed, 24 May 2023 01:42:11 +0800 Subject: [PATCH 031/117] waktusolat: Update wrong link --- mika/waktusolat/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mika/waktusolat/README.md b/mika/waktusolat/README.md index d078a872..2523e453 100644 --- a/mika/waktusolat/README.md +++ b/mika/waktusolat/README.md @@ -45,7 +45,7 @@ Copy `values.yaml` from the chart you would like to install. cp mika/waktusolat/values.yaml . ``` -Edit `values.yaml` with the appropriate values. Refer to the [Configuration](#Configuration) section for available options. +Edit `values.yaml` with the appropriate values. Refer to the [Configurations](#Configurations) section for available options. ```sh nano values.yaml From 4321545f42270634a704805b2b5f34609a7c287e Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Wed, 24 May 2023 01:43:58 +0800 Subject: [PATCH 032/117] waktusolat: Add celery config --- mika/waktusolat/templates/_helpers.tpl | 812 ++++++++++++++++++++++ mika/waktusolat/templates/configmap.yaml | 14 + mika/waktusolat/templates/deployment.yaml | 22 + 3 files changed, 848 insertions(+) diff --git a/mika/waktusolat/templates/_helpers.tpl b/mika/waktusolat/templates/_helpers.tpl index 036c843c..52f801bc 100644 --- a/mika/waktusolat/templates/_helpers.tpl +++ b/mika/waktusolat/templates/_helpers.tpl @@ -60,3 +60,815 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +/etc/default/celeryd template +*/}} +{{- define "waktusolat.default-celeryd" -}} +# Names of nodes to start +# most people will only start one node: +#CELERYD_NODES="worker1" +# but you can also start multiple and configure settings +# for each in CELERYD_OPTS +#CELERYD_NODES="worker1 worker2 worker3" +# alternatively, you can specify the number of nodes to start: +#CELERYD_NODES=10 +CELERYD_NODES="worker1" + +# Absolute or relative path to the 'celery' command: +#CELERY_BIN="/usr/local/bin/celery" +#CELERY_BIN="/virtualenvs/def/bin/celery" +CELERY_BIN="/usr/local/bin/celery" + +# App instance to use +# comment out this line if you don't use an app +#CELERY_APP="proj" +# or fully qualified: +#CELERY_APP="proj.tasks:app" +CELERY_APP="base" + +# Where to chdir at start. +#CELERYD_CHDIR="/opt/Myproject/" +CELERYD_CHDIR="/base/" + +# Extra command-line arguments to the worker +#CELERYD_OPTS="--time-limit=300 --concurrency=8" +# Configure node-specific settings by appending node name to arguments: +#CELERYD_OPTS="--time-limit=300 -c 8 -c:worker2 4 -c:worker3 2 -Ofair:worker1" +CELERYD_OPTS="--time-limit=300 --concurrency=8 --without-gossip --without-mingle --without-heartbeat -Ofair --pool=solo" + +# Set logging level +#CELERYD_LOG_LEVEL="DEBUG" +CELERYD_LOG_LEVEL="INFO" + +# %n will be replaced with the first part of the nodename. +#CELERYD_LOG_FILE="/var/log/celery/%n%I.log" +#CELERYD_PID_FILE="/var/run/celery/%n.pid" +CELERYD_LOG_FILE="/var/log/celery/%n%I.log" +CELERYD_PID_FILE="/var/run/celery/%n.pid" + +# Workers should run as an unprivileged user. +# You need to create this user manually (or you can choose +# a user/group combination that already exists (e.g., nobody). +#CELERYD_USER="celery" +#CELERYD_GROUP="celery" +CELERYD_USER="root" +CELERYD_GROUP="root" + +# If enabled pid and log directories will be created if missing, +# and owned by the userid/group configured. +#CELERY_CREATE_DIRS=1 +CELERY_CREATE_DIRS=1 +{{- end }} + +{{/* +/etc/init.d/celerybeat template +*/}} +{{- define "waktusolat.initd-celerybeat" -}} +#!/bin/sh -e +# ========================================================= +# celerybeat - Starts the Celery periodic task scheduler. +# ========================================================= +# +# :Usage: /etc/init.d/celerybeat {start|stop|force-reload|restart|try-restart|status} +# :Configuration file: /etc/default/celerybeat or /etc/default/celeryd +# +# See https://docs.celeryq.dev/en/latest/userguide/daemonizing.html#generic-init-scripts + +### BEGIN INIT INFO +# Provides: celerybeat +# Required-Start: $network $local_fs $remote_fs +# Required-Stop: $network $local_fs $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: celery periodic task scheduler +### END INIT INFO + +# Cannot use set -e/bash -e since the kill -0 command will abort +# abnormally in the absence of a valid process ID. +#set -e +VERSION=10.1 +echo "celery init v${VERSION}." + +if [ $(id -u) -ne 0 ]; then + echo "Error: This program can only be used by the root user." + echo " Unprivileged users must use 'celery beat --detach'" + exit 1 +fi + +origin_is_runlevel_dir () { + set +e + dirname $0 | grep -q "/etc/rc.\.d" + echo $? +} + +# Can be a runlevel symlink (e.g., S02celeryd) +if [ $(origin_is_runlevel_dir) -eq 0 ]; then + SCRIPT_FILE=$(readlink "$0") +else + SCRIPT_FILE="$0" +fi +SCRIPT_NAME="$(basename "$SCRIPT_FILE")" + +# /etc/init.d/celerybeat: start and stop the celery periodic task scheduler daemon. + +# Make sure executable configuration script is owned by root +_config_sanity() { + local path="$1" + local owner=$(ls -ld "$path" | awk '{print $3}') + local iwgrp=$(ls -ld "$path" | cut -b 6) + local iwoth=$(ls -ld "$path" | cut -b 9) + + if [ "$(id -u $owner)" != "0" ]; then + echo "Error: Config script '$path' must be owned by root!" + echo + echo "Resolution:" + echo "Review the file carefully, and make sure it hasn't been " + echo "modified with mailicious intent. When sure the " + echo "script is safe to execute with superuser privileges " + echo "you can change ownership of the script:" + echo " $ sudo chown root '$path'" + exit 1 + fi + + if [ "$iwoth" != "-" ]; then # S_IWOTH + echo "Error: Config script '$path' cannot be writable by others!" + echo + echo "Resolution:" + echo "Review the file carefully, and make sure it hasn't been " + echo "modified with malicious intent. When sure the " + echo "script is safe to execute with superuser privileges " + echo "you can change the scripts permissions:" + echo " $ sudo chmod 640 '$path'" + exit 1 + fi + if [ "$iwgrp" != "-" ]; then # S_IWGRP + echo "Error: Config script '$path' cannot be writable by group!" + echo + echo "Resolution:" + echo "Review the file carefully, and make sure it hasn't been " + echo "modified with malicious intent. When sure the " + echo "script is safe to execute with superuser privileges " + echo "you can change the scripts permissions:" + echo " $ sudo chmod 640 '$path'" + exit 1 + fi +} + +scripts="" + +if test -f /etc/default/celeryd; then + scripts="/etc/default/celeryd" + _config_sanity /etc/default/celeryd + . /etc/default/celeryd +fi + +EXTRA_CONFIG="/etc/default/${SCRIPT_NAME}" +if test -f "$EXTRA_CONFIG"; then + scripts="$scripts, $EXTRA_CONFIG" + _config_sanity "$EXTRA_CONFIG" + . "$EXTRA_CONFIG" +fi + +echo "Using configuration: $scripts" + +CELERY_BIN=${CELERY_BIN:-"celery"} +DEFAULT_USER="celery" +DEFAULT_PID_FILE="/var/run/celery/beat.pid" +DEFAULT_LOG_FILE="/var/log/celery/beat.log" +DEFAULT_LOG_LEVEL="INFO" +DEFAULT_CELERYBEAT="$CELERY_BIN" + +CELERYBEAT=${CELERYBEAT:-$DEFAULT_CELERYBEAT} +CELERYBEAT_LOG_LEVEL=${CELERYBEAT_LOG_LEVEL:-${CELERYBEAT_LOGLEVEL:-$DEFAULT_LOG_LEVEL}} + +CELERYBEAT_SU=${CELERYBEAT_SU:-"su"} +CELERYBEAT_SU_ARGS=${CELERYBEAT_SU_ARGS:-""} + +# Sets --app argument for CELERY_BIN +CELERY_APP_ARG="" +if [ ! -z "$CELERY_APP" ]; then + CELERY_APP_ARG="--app=$CELERY_APP" +fi + +CELERYBEAT_USER=${CELERYBEAT_USER:-${CELERYD_USER:-$DEFAULT_USER}} + +# Set CELERY_CREATE_DIRS to always create log/pid dirs. +CELERY_CREATE_DIRS=${CELERY_CREATE_DIRS:-0} +CELERY_CREATE_RUNDIR=$CELERY_CREATE_DIRS +CELERY_CREATE_LOGDIR=$CELERY_CREATE_DIRS +if [ -z "$CELERYBEAT_PID_FILE" ]; then + CELERYBEAT_PID_FILE="$DEFAULT_PID_FILE" + CELERY_CREATE_RUNDIR=1 +fi +if [ -z "$CELERYBEAT_LOG_FILE" ]; then + CELERYBEAT_LOG_FILE="$DEFAULT_LOG_FILE" + CELERY_CREATE_LOGDIR=1 +fi + +export CELERY_LOADER + +if [ -n "$2" ]; then + CELERYBEAT_OPTS="$CELERYBEAT_OPTS $2" +fi + +CELERYBEAT_LOG_DIR=`dirname $CELERYBEAT_LOG_FILE` +CELERYBEAT_PID_DIR=`dirname $CELERYBEAT_PID_FILE` + +# Extra start-stop-daemon options, like user/group. + +CELERYBEAT_CHDIR=${CELERYBEAT_CHDIR:-$CELERYD_CHDIR} +if [ -n "$CELERYBEAT_CHDIR" ]; then + DAEMON_OPTS="$DAEMON_OPTS --workdir=$CELERYBEAT_CHDIR" +fi + + +export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" + +check_dev_null() { + if [ ! -c /dev/null ]; then + echo "/dev/null is not a character device!" + exit 75 # EX_TEMPFAIL + fi +} + +maybe_die() { + if [ $? -ne 0 ]; then + echo "Exiting: $*" + exit 77 # EX_NOPERM + fi +} + +create_default_dir() { + if [ ! -d "$1" ]; then + echo "- Creating default directory: '$1'" + mkdir -p "$1" + maybe_die "Couldn't create directory $1" + echo "- Changing permissions of '$1' to 02755" + chmod 02755 "$1" + maybe_die "Couldn't change permissions for $1" + if [ -n "$CELERYBEAT_USER" ]; then + echo "- Changing owner of '$1' to '$CELERYBEAT_USER'" + chown "$CELERYBEAT_USER" "$1" + maybe_die "Couldn't change owner of $1" + fi + if [ -n "$CELERYBEAT_GROUP" ]; then + echo "- Changing group of '$1' to '$CELERYBEAT_GROUP'" + chgrp "$CELERYBEAT_GROUP" "$1" + maybe_die "Couldn't change group of $1" + fi + fi +} + +check_paths() { + if [ $CELERY_CREATE_LOGDIR -eq 1 ]; then + create_default_dir "$CELERYBEAT_LOG_DIR" + fi + if [ $CELERY_CREATE_RUNDIR -eq 1 ]; then + create_default_dir "$CELERYBEAT_PID_DIR" + fi +} + + +create_paths () { + create_default_dir "$CELERYBEAT_LOG_DIR" + create_default_dir "$CELERYBEAT_PID_DIR" +} + +is_running() { + pid=$1 + ps $pid > /dev/null 2>&1 +} + +wait_pid () { + pid=$1 + forever=1 + i=0 + while [ $forever -gt 0 ]; do + if ! is_running $pid; then + echo "OK" + forever=0 + else + kill -TERM "$pid" + i=$((i + 1)) + if [ $i -gt 60 ]; then + echo "ERROR" + echo "Timed out while stopping (30s)" + forever=0 + else + sleep 0.5 + fi + fi + done +} + + +stop_beat () { + echo -n "Stopping ${SCRIPT_NAME}... " + if [ -f "$CELERYBEAT_PID_FILE" ]; then + wait_pid $(cat "$CELERYBEAT_PID_FILE") + else + echo "NOT RUNNING" + fi +} + +_chuid () { + ${CELERYBEAT_SU} ${CELERYBEAT_SU_ARGS} \ + "$CELERYBEAT_USER" -c "$CELERYBEAT $*" +} + +start_beat () { + echo "Starting ${SCRIPT_NAME}..." + _chuid $CELERY_APP_ARG $DAEMON_OPTS beat --detach \ + --pidfile="$CELERYBEAT_PID_FILE" \ + --logfile="$CELERYBEAT_LOG_FILE" \ + --loglevel="$CELERYBEAT_LOG_LEVEL" \ + $CELERYBEAT_OPTS +} + + +check_status () { + local failed= + local pid_file=$CELERYBEAT_PID_FILE + if [ ! -e $pid_file ]; then + echo "${SCRIPT_NAME} is down: no pid file found" + failed=true + elif [ ! -r $pid_file ]; then + echo "${SCRIPT_NAME} is in unknown state, user cannot read pid file." + failed=true + else + local pid=`cat "$pid_file"` + local cleaned_pid=`echo "$pid" | sed -e 's/[^0-9]//g'` + if [ -z "$pid" ] || [ "$cleaned_pid" != "$pid" ]; then + echo "${SCRIPT_NAME}: bad pid file ($pid_file)" + failed=true + else + local failed= + kill -0 $pid 2> /dev/null || failed=true + if [ "$failed" ]; then + echo "${SCRIPT_NAME} (pid $pid) is down, but pid file exists!" + failed=true + else + echo "${SCRIPT_NAME} (pid $pid) is up..." + fi + fi + fi + + [ "$failed" ] && exit 1 || exit 0 +} + + +case "$1" in + start) + check_dev_null + check_paths + start_beat + ;; + stop) + check_paths + stop_beat + ;; + reload|force-reload) + echo "Use start+stop" + ;; + status) + check_status + ;; + restart) + echo "Restarting celery periodic task scheduler" + check_paths + stop_beat && check_dev_null && start_beat + ;; + create-paths) + check_dev_null + create_paths + ;; + check-paths) + check_dev_null + check_paths + ;; + *) + echo "Usage: /etc/init.d/${SCRIPT_NAME} {start|stop|restart|create-paths|status}" + exit 64 # EX_USAGE + ;; +esac + +exit 0 +{{- end }} + +{{/* +/etc/init.d/celeryd template +*/}} +{{- define "waktusolat.initd-celeryd" -}} +#!/bin/sh -e +# ============================================ +# celeryd - Starts the Celery worker daemon. +# ============================================ +# +# :Usage: /etc/init.d/celeryd {start|stop|force-reload|restart|try-restart|status} +# :Configuration file: /etc/default/celeryd (or /usr/local/etc/celeryd on BSD) +# +# See https://docs.celeryq.dev/en/latest/userguide/daemonizing.html#generic-init-scripts + + +### BEGIN INIT INFO +# Provides: celeryd +# Required-Start: $network $local_fs $remote_fs +# Required-Stop: $network $local_fs $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: celery task worker daemon +### END INIT INFO +# +# +# To implement separate init-scripts, copy this script and give it a different +# name. That is, if your new application named "little-worker" needs an init, +# you should use: +# +# cp /etc/init.d/celeryd /etc/init.d/little-worker +# +# You can then configure this by manipulating /etc/default/little-worker. +# +VERSION=10.1 +echo "celery init v${VERSION}." +if [ $(id -u) -ne 0 ]; then + echo "Error: This program can only be used by the root user." + echo " Unprivileged users must use the 'celery multi' utility, " + echo " or 'celery worker --detach'." + exit 1 +fi + +origin_is_runlevel_dir () { + set +e + dirname $0 | grep -q "/etc/rc.\.d" + echo $? +} + +# Can be a runlevel symlink (e.g., S02celeryd) +if [ $(origin_is_runlevel_dir) -eq 0 ]; then + SCRIPT_FILE=$(readlink "$0") +else + SCRIPT_FILE="$0" +fi +SCRIPT_NAME="$(basename "$SCRIPT_FILE")" + +DEFAULT_USER="celery" +DEFAULT_PID_FILE="/var/run/celery/%n.pid" +DEFAULT_LOG_FILE="/var/log/celery/%n%I.log" +DEFAULT_LOG_LEVEL="INFO" +DEFAULT_NODES="celery" +DEFAULT_CELERYD="-m celery worker --detach" + +if [ -d "/etc/default" ]; then + CELERY_CONFIG_DIR="/etc/default" +else + CELERY_CONFIG_DIR="/usr/local/etc" +fi + +CELERY_DEFAULTS=${CELERY_DEFAULTS:-"$CELERY_CONFIG_DIR/${SCRIPT_NAME}"} + +# Make sure executable configuration script is owned by root +_config_sanity() { + local path="$1" + local owner=$(ls -ld "$path" | awk '{print $3}') + local iwgrp=$(ls -ld "$path" | cut -b 6) + local iwoth=$(ls -ld "$path" | cut -b 9) + + if [ "$(id -u $owner)" != "0" ]; then + echo "Error: Config script '$path' must be owned by root!" + echo + echo "Resolution:" + echo "Review the file carefully, and make sure it hasn't been " + echo "modified with mailicious intent. When sure the " + echo "script is safe to execute with superuser privileges " + echo "you can change ownership of the script:" + echo " $ sudo chown root '$path'" + exit 1 + fi + + if [ "$iwoth" != "-" ]; then # S_IWOTH + echo "Error: Config script '$path' cannot be writable by others!" + echo + echo "Resolution:" + echo "Review the file carefully, and make sure it hasn't been " + echo "modified with malicious intent. When sure the " + echo "script is safe to execute with superuser privileges " + echo "you can change the scripts permissions:" + echo " $ sudo chmod 640 '$path'" + exit 1 + fi + if [ "$iwgrp" != "-" ]; then # S_IWGRP + echo "Error: Config script '$path' cannot be writable by group!" + echo + echo "Resolution:" + echo "Review the file carefully, and make sure it hasn't been " + echo "modified with malicious intent. When sure the " + echo "script is safe to execute with superuser privileges " + echo "you can change the scripts permissions:" + echo " $ sudo chmod 640 '$path'" + exit 1 + fi +} + +if [ -f "$CELERY_DEFAULTS" ]; then + _config_sanity "$CELERY_DEFAULTS" + echo "Using config script: $CELERY_DEFAULTS" + . "$CELERY_DEFAULTS" +fi + +# Sets --app argument for CELERY_BIN +CELERY_APP_ARG="" +if [ ! -z "$CELERY_APP" ]; then + CELERY_APP_ARG="--app=$CELERY_APP" +fi + +# Options to su +# can be used to enable login shell (CELERYD_SU_ARGS="-l"), +# or even to use start-stop-daemon instead of su. +CELERYD_SU=${CELERY_SU:-"su"} +CELERYD_SU_ARGS=${CELERYD_SU_ARGS:-""} + +CELERYD_USER=${CELERYD_USER:-$DEFAULT_USER} + +# Set CELERY_CREATE_DIRS to always create log/pid dirs. +CELERY_CREATE_DIRS=${CELERY_CREATE_DIRS:-0} +CELERY_CREATE_RUNDIR=$CELERY_CREATE_DIRS +CELERY_CREATE_LOGDIR=$CELERY_CREATE_DIRS +if [ -z "$CELERYD_PID_FILE" ]; then + CELERYD_PID_FILE="$DEFAULT_PID_FILE" + CELERY_CREATE_RUNDIR=1 +fi +if [ -z "$CELERYD_LOG_FILE" ]; then + CELERYD_LOG_FILE="$DEFAULT_LOG_FILE" + CELERY_CREATE_LOGDIR=1 +fi + +CELERYD_LOG_LEVEL=${CELERYD_LOG_LEVEL:-${CELERYD_LOGLEVEL:-$DEFAULT_LOG_LEVEL}} +CELERY_BIN=${CELERY_BIN:-"celery"} +CELERYD_MULTI=${CELERYD_MULTI:-"$CELERY_BIN multi"} +CELERYD_NODES=${CELERYD_NODES:-$DEFAULT_NODES} + +export CELERY_LOADER + +if [ -n "$2" ]; then + CELERYD_OPTS="$CELERYD_OPTS $2" +fi + +CELERYD_LOG_DIR=`dirname $CELERYD_LOG_FILE` +CELERYD_PID_DIR=`dirname $CELERYD_PID_FILE` + +# Extra start-stop-daemon options, like user/group. +if [ -n "$CELERYD_CHDIR" ]; then + DAEMON_OPTS="$DAEMON_OPTS --workdir=$CELERYD_CHDIR" +fi + + +check_dev_null() { + if [ ! -c /dev/null ]; then + echo "/dev/null is not a character device!" + exit 75 # EX_TEMPFAIL + fi +} + + +maybe_die() { + if [ $? -ne 0 ]; then + echo "Exiting: $* (errno $?)" + exit 77 # EX_NOPERM + fi +} + +create_default_dir() { + if [ ! -d "$1" ]; then + echo "- Creating default directory: '$1'" + mkdir -p "$1" + maybe_die "Couldn't create directory $1" + echo "- Changing permissions of '$1' to 02755" + chmod 02755 "$1" + maybe_die "Couldn't change permissions for $1" + if [ -n "$CELERYD_USER" ]; then + echo "- Changing owner of '$1' to '$CELERYD_USER'" + chown "$CELERYD_USER" "$1" + maybe_die "Couldn't change owner of $1" + fi + if [ -n "$CELERYD_GROUP" ]; then + echo "- Changing group of '$1' to '$CELERYD_GROUP'" + chgrp "$CELERYD_GROUP" "$1" + maybe_die "Couldn't change group of $1" + fi + fi +} + + +check_paths() { + if [ $CELERY_CREATE_LOGDIR -eq 1 ]; then + create_default_dir "$CELERYD_LOG_DIR" + fi + if [ $CELERY_CREATE_RUNDIR -eq 1 ]; then + create_default_dir "$CELERYD_PID_DIR" + fi +} + +create_paths() { + create_default_dir "$CELERYD_LOG_DIR" + create_default_dir "$CELERYD_PID_DIR" +} + +export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" + + +_get_pidfiles () { + # note: multi < 3.1.14 output to stderr, not stdout, hence the redirect. + ${CELERYD_MULTI} expand "${CELERYD_PID_FILE}" ${CELERYD_NODES} 2>&1 +} + + +_get_pids() { + found_pids=0 + my_exitcode=0 + + for pidfile in $(_get_pidfiles); do + local pid=`cat "$pidfile"` + local cleaned_pid=`echo "$pid" | sed -e 's/[^0-9]//g'` + if [ -z "$pid" ] || [ "$cleaned_pid" != "$pid" ]; then + echo "bad pid file ($pidfile)" + one_failed=true + my_exitcode=1 + else + found_pids=1 + echo "$pid" + fi + + if [ $found_pids -eq 0 ]; then + echo "${SCRIPT_NAME}: All nodes down" + exit $my_exitcode + fi + done +} + + +_chuid () { + ${CELERYD_SU} ${CELERYD_SU_ARGS} "$CELERYD_USER" -c "$CELERYD_MULTI $*" +} + + +start_workers () { + if [ ! -z "$CELERYD_ULIMIT" ]; then + ulimit $CELERYD_ULIMIT + fi + _chuid $* start $CELERYD_NODES $DAEMON_OPTS \ + --pidfile="$CELERYD_PID_FILE" \ + --logfile="$CELERYD_LOG_FILE" \ + --loglevel="$CELERYD_LOG_LEVEL" \ + $CELERY_APP_ARG \ + $CELERYD_OPTS +} + + +dryrun () { + (C_FAKEFORK=1 start_workers --verbose) +} + + +stop_workers () { + _chuid stopwait $CELERYD_NODES $DAEMON_OPTS --pidfile="$CELERYD_PID_FILE" +} + + +restart_workers () { + _chuid restart $CELERYD_NODES $DAEMON_OPTS \ + --pidfile="$CELERYD_PID_FILE" \ + --logfile="$CELERYD_LOG_FILE" \ + --loglevel="$CELERYD_LOG_LEVEL" \ + $CELERY_APP_ARG \ + $CELERYD_OPTS +} + + +kill_workers() { + _chuid kill $CELERYD_NODES $DAEMON_OPTS --pidfile="$CELERYD_PID_FILE" +} + + +restart_workers_graceful () { + echo "WARNING: Use with caution in production" + echo "The workers will attempt to restart, but they may not be able to." + local worker_pids= + worker_pids=`_get_pids` + [ "$one_failed" ] && exit 1 + + for worker_pid in $worker_pids; do + local failed= + kill -HUP $worker_pid 2> /dev/null || failed=true + if [ "$failed" ]; then + echo "${SCRIPT_NAME} worker (pid $worker_pid) could not be restarted" + one_failed=true + else + echo "${SCRIPT_NAME} worker (pid $worker_pid) received SIGHUP" + fi + done + + [ "$one_failed" ] && exit 1 || exit 0 +} + + +check_status () { + my_exitcode=0 + found_pids=0 + + local one_failed= + for pidfile in $(_get_pidfiles); do + if [ ! -r $pidfile ]; then + echo "${SCRIPT_NAME} down: no pidfiles found" + one_failed=true + break + fi + + local node=`basename "$pidfile" .pid` + local pid=`cat "$pidfile"` + local cleaned_pid=`echo "$pid" | sed -e 's/[^0-9]//g'` + if [ -z "$pid" ] || [ "$cleaned_pid" != "$pid" ]; then + echo "bad pid file ($pidfile)" + one_failed=true + else + local failed= + kill -0 $pid 2> /dev/null || failed=true + if [ "$failed" ]; then + echo "${SCRIPT_NAME} (node $node) (pid $pid) is down, but pidfile exists!" + one_failed=true + else + echo "${SCRIPT_NAME} (node $node) (pid $pid) is up..." + fi + fi + done + + [ "$one_failed" ] && exit 1 || exit 0 +} + + +case "$1" in + start) + check_dev_null + check_paths + start_workers + ;; + + stop) + check_dev_null + check_paths + stop_workers + ;; + + reload|force-reload) + echo "Use restart" + ;; + + status) + check_status + ;; + + restart) + check_dev_null + check_paths + restart_workers + ;; + + graceful) + check_dev_null + restart_workers_graceful + ;; + + kill) + check_dev_null + kill_workers + ;; + + dryrun) + check_dev_null + dryrun + ;; + + try-restart) + check_dev_null + check_paths + restart_workers + ;; + + create-paths) + check_dev_null + create_paths + ;; + + check-paths) + check_dev_null + check_paths + ;; + + *) + echo "Usage: /etc/init.d/${SCRIPT_NAME} {start|stop|restart|graceful|kill|dryrun|create-paths}" + exit 64 # EX_USAGE + ;; +esac + +exit 0 +{{- end }} diff --git a/mika/waktusolat/templates/configmap.yaml b/mika/waktusolat/templates/configmap.yaml index 1f94c0fc..61a70f8d 100644 --- a/mika/waktusolat/templates/configmap.yaml +++ b/mika/waktusolat/templates/configmap.yaml @@ -49,3 +49,17 @@ data: ErrorLog /var/log/apache2/apache.error.log CustomLog /var/log/apache2/apache.access.log combined +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-waktusolat-celery-config + labels: + {{- include "waktusolat.labels" . | nindent 4 }} +data: + default-celeryd: |- + {{- include "waktusolat.default-celeryd" . | nindent 4 }} + celerybeat: |- + {{- include "waktusolat.initd-celerybeat" . | nindent 4 }} + initd-celeryd: |- + {{- include "waktusolat.initd-celeryd" . | nindent 4 }} diff --git a/mika/waktusolat/templates/deployment.yaml b/mika/waktusolat/templates/deployment.yaml index c8e3601a..54fc21ec 100644 --- a/mika/waktusolat/templates/deployment.yaml +++ b/mika/waktusolat/templates/deployment.yaml @@ -112,6 +112,18 @@ spec: mountPath: /etc/apache2/sites-available/000-default.conf subPath: site-config.conf readOnly: true + - name: {{ .Release.Name }}-waktusolat-celery-config + mountPath: /etc/default/celeryd + subPath: default-celeryd + readOnly: true + - name: {{ .Release.Name }}-waktusolat-celery-config + mountPath: /etc/init.d/celerybeat + subPath: celerybeat + readOnly: true + - name: {{ .Release.Name }}-waktusolat-celery-config + mountPath: /etc/init.d/celeryd + subPath: initd-celeryd + readOnly: true - name: {{ .Release.Name }}-waktusolat-token-secret mountPath: /base/base/mastodon.secret subPath: mastodon.secret @@ -129,6 +141,16 @@ spec: - name: {{ .Release.Name }}-waktusolat-site-config configMap: name: {{ .Release.Name }}-waktusolat-site-config + - name: {{ .Release.Name }}-waktusolat-celery-config + configMap: + name: {{ .Release.Name }}-waktusolat-celery-config + items: + - key: default-celeryd + path: default-celeryd + - key: celerybeat + path: celerybeat + - key: initd-celeryd + path: initd-celeryd - name: {{ .Release.Name }}-waktusolat-token-secret secret: secretName: {{ .Release.Name }}-waktusolat-token-secret From 84846a50dd42cc49bf3318f4f6b73cdb87d65ffe Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 25 May 2023 01:57:33 +0800 Subject: [PATCH 033/117] waktusolat: Separate celery configmaps and add defaultMode --- mika/waktusolat/templates/configmap.yaml | 14 +++++++--- mika/waktusolat/templates/deployment.yaml | 32 ++++++++++++----------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/mika/waktusolat/templates/configmap.yaml b/mika/waktusolat/templates/configmap.yaml index 61a70f8d..b7a7761b 100644 --- a/mika/waktusolat/templates/configmap.yaml +++ b/mika/waktusolat/templates/configmap.yaml @@ -53,13 +53,21 @@ data: apiVersion: v1 kind: ConfigMap metadata: - name: {{ .Release.Name }}-waktusolat-celery-config + name: {{ .Release.Name }}-waktusolat-default-celery-config labels: {{- include "waktusolat.labels" . | nindent 4 }} data: - default-celeryd: |- + celeryd: |- {{- include "waktusolat.default-celeryd" . | nindent 4 }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-waktusolat-initd-celery-config + labels: + {{- include "waktusolat.labels" . | nindent 4 }} +data: celerybeat: |- {{- include "waktusolat.initd-celerybeat" . | nindent 4 }} - initd-celeryd: |- + celeryd: |- {{- include "waktusolat.initd-celeryd" . | nindent 4 }} diff --git a/mika/waktusolat/templates/deployment.yaml b/mika/waktusolat/templates/deployment.yaml index 54fc21ec..8f676279 100644 --- a/mika/waktusolat/templates/deployment.yaml +++ b/mika/waktusolat/templates/deployment.yaml @@ -111,19 +111,15 @@ spec: - name: {{ .Release.Name }}-waktusolat-site-config mountPath: /etc/apache2/sites-available/000-default.conf subPath: site-config.conf - readOnly: true - - name: {{ .Release.Name }}-waktusolat-celery-config + - name: {{ .Release.Name }}-waktusolat-default-celery-config mountPath: /etc/default/celeryd - subPath: default-celeryd - readOnly: true - - name: {{ .Release.Name }}-waktusolat-celery-config + subPath: celeryd + - name: {{ .Release.Name }}-waktusolat-initd-celery-config mountPath: /etc/init.d/celerybeat subPath: celerybeat - readOnly: true - - name: {{ .Release.Name }}-waktusolat-celery-config + - name: {{ .Release.Name }}-waktusolat-initd-celery-config mountPath: /etc/init.d/celeryd - subPath: initd-celeryd - readOnly: true + subPath: celeryd - name: {{ .Release.Name }}-waktusolat-token-secret mountPath: /base/base/mastodon.secret subPath: mastodon.secret @@ -141,16 +137,22 @@ spec: - name: {{ .Release.Name }}-waktusolat-site-config configMap: name: {{ .Release.Name }}-waktusolat-site-config - - name: {{ .Release.Name }}-waktusolat-celery-config + - name: {{ .Release.Name }}-waktusolat-default-celery-config + configMap: + name: {{ .Release.Name }}-waktusolat-default-celery-config + defaultMode: 0640 + items: + - key: celeryd + path: celeryd + - name: {{ .Release.Name }}-waktusolat-initd-celery-config configMap: - name: {{ .Release.Name }}-waktusolat-celery-config + name: {{ .Release.Name }}-waktusolat-initd-celery-config + defaultMode: 0755 items: - - key: default-celeryd - path: default-celeryd - key: celerybeat path: celerybeat - - key: initd-celeryd - path: initd-celeryd + - key: celeryd + path: celeryd - name: {{ .Release.Name }}-waktusolat-token-secret secret: secretName: {{ .Release.Name }}-waktusolat-token-secret From 8932b08660687f26f600ffb42ece808e8b8ad8a8 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 25 May 2023 01:58:55 +0800 Subject: [PATCH 034/117] waktusolat: Re-enable readOnly for site-config.conf --- mika/waktusolat/templates/deployment.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/mika/waktusolat/templates/deployment.yaml b/mika/waktusolat/templates/deployment.yaml index 8f676279..c69695aa 100644 --- a/mika/waktusolat/templates/deployment.yaml +++ b/mika/waktusolat/templates/deployment.yaml @@ -111,6 +111,7 @@ spec: - name: {{ .Release.Name }}-waktusolat-site-config mountPath: /etc/apache2/sites-available/000-default.conf subPath: site-config.conf + readOnly: true - name: {{ .Release.Name }}-waktusolat-default-celery-config mountPath: /etc/default/celeryd subPath: celeryd From b2118e53c3505c080163c01cd4ea02a1bb019c40 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 26 May 2023 00:20:04 +0800 Subject: [PATCH 035/117] waktusolat: Add waktusolat-scheduler-config for celery --- mika/waktusolat/templates/_helpers.tpl | 88 +++++++++++++++++++++++ mika/waktusolat/templates/configmap.yaml | 14 ++++ mika/waktusolat/templates/deployment.yaml | 20 ++++++ 3 files changed, 122 insertions(+) diff --git a/mika/waktusolat/templates/_helpers.tpl b/mika/waktusolat/templates/_helpers.tpl index 52f801bc..6f08c887 100644 --- a/mika/waktusolat/templates/_helpers.tpl +++ b/mika/waktusolat/templates/_helpers.tpl @@ -872,3 +872,91 @@ esac exit 0 {{- end }} + +{{/* +/base/base/celery.py template +*/}} +{{- define "waktusolat.celery-py" -}} +from __future__ import absolute_import, unicode_literals +import os +from celery import Celery +from celery.schedules import crontab +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "base.settings") +app = Celery("base") +app.config_from_object("django.conf:settings", namespace="CELERY") +app.autodiscover_tasks() + + +app.conf.beat_schedule = { + # clean and update prayer times every 0000 hour + "clean_db_every_0000": { + "task": "base.tasks.clean_db_task", + "schedule": crontab(hour=0, minute=0), + }, + # notify solat schedule every 0500 hour + "notify_solat_schedule_every_0500": { + "task": "base.tasks.notify_solat_schedule_task", + "schedule": crontab(hour=5, minute=0), + }, + # check and notify solat time every sharp minute + "notify_solat_times_every_minute": { + "task": "base.tasks.notify_solat_times_task", + "schedule": crontab(minute="*"), + }, + # check for any posts that need to be posted every 1 second + "post_scheduler_every_1s": { + "task": "base.tasks.post_scheduler_task", + "schedule": 1.0, + }, +} + + +@app.task(bind=True) +def debug_task(self): + print("Request: {0!r}".format(self.request)) +{{- end }} + +{{/* +/base/base/__init__.py template +*/}} +{{- define "waktusolat.init-py" -}} +from .celery import app as celery_app + +__all__ = ("celery_app",) +{{- end }} + +{{/* +/base/base/tasks.py template +*/}} +{{- define "waktusolat.tasks-py" -}} +from __future__ import absolute_import, unicode_literals +import logging +from celery import shared_task +from base.methods import post_scheduler +from lib import solat +logger=logging.getLogger('base') + + +# clean and update prayer times +@shared_task +def clean_db_task(): + solat.clean_db() + + +# notify solat schedule +@shared_task +def notify_solat_schedule_task(): + solat.notify_solat_schedule() + + +# check and notify solat time +@shared_task +def notify_solat_times_task(): + solat.notify_solat_times() + + +# check for any posts that need to be posted +@shared_task +def post_scheduler_task(): + post_scheduler() +{{- end }} diff --git a/mika/waktusolat/templates/configmap.yaml b/mika/waktusolat/templates/configmap.yaml index b7a7761b..c9cd756e 100644 --- a/mika/waktusolat/templates/configmap.yaml +++ b/mika/waktusolat/templates/configmap.yaml @@ -71,3 +71,17 @@ data: {{- include "waktusolat.initd-celerybeat" . | nindent 4 }} celeryd: |- {{- include "waktusolat.initd-celeryd" . | nindent 4 }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-waktusolat-scheduler-config + labels: + {{- include "waktusolat.labels" . | nindent 4 }} +data: + celery.py: |- + {{- include "waktusolat.celery-py" . | nindent 4 }} + init.py: |- + {{- include "waktusolat.init-py" . | nindent 4 }} + tasks.py: |- + {{- include "waktusolat.tasks-py" . | nindent 4 }} diff --git a/mika/waktusolat/templates/deployment.yaml b/mika/waktusolat/templates/deployment.yaml index c69695aa..86353644 100644 --- a/mika/waktusolat/templates/deployment.yaml +++ b/mika/waktusolat/templates/deployment.yaml @@ -121,6 +121,15 @@ spec: - name: {{ .Release.Name }}-waktusolat-initd-celery-config mountPath: /etc/init.d/celeryd subPath: celeryd + - name: {{ .Release.Name }}-waktusolat-scheduler-config + mountPath: /base/base/celery.py + subPath: celery.py + - name: {{ .Release.Name }}-waktusolat-scheduler-config + mountPath: /base/base/__init__.py + subPath: init.py + - name: {{ .Release.Name }}-waktusolat-scheduler-config + mountPath: /base/base/tasks.py + subPath: tasks.py - name: {{ .Release.Name }}-waktusolat-token-secret mountPath: /base/base/mastodon.secret subPath: mastodon.secret @@ -154,6 +163,17 @@ spec: path: celerybeat - key: celeryd path: celeryd + - name: {{ .Release.Name }}-waktusolat-scheduler-config + configMap: + name: {{ .Release.Name }}-waktusolat-scheduler-config + defaultMode: 0775 + items: + - key: celery.py + path: celery.py + - key: init.py + path: init.py + - key: tasks.py + path: tasks.py - name: {{ .Release.Name }}-waktusolat-token-secret secret: secretName: {{ .Release.Name }}-waktusolat-token-secret From a846a452a76297bc58f464fe28973af5c49f0044 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 26 May 2023 00:20:41 +0800 Subject: [PATCH 036/117] waktusolat: Mounts are mounted for gid 33 (www-data) --- mika/waktusolat/templates/deployment.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mika/waktusolat/templates/deployment.yaml b/mika/waktusolat/templates/deployment.yaml index 86353644..87752bac 100644 --- a/mika/waktusolat/templates/deployment.yaml +++ b/mika/waktusolat/templates/deployment.yaml @@ -177,3 +177,5 @@ spec: - name: {{ .Release.Name }}-waktusolat-token-secret secret: secretName: {{ .Release.Name }}-waktusolat-token-secret + securityContext: + fsGroup: 33 From 8d7682a4a06d0320b0efd1172265256116316ab9 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 26 May 2023 00:31:15 +0800 Subject: [PATCH 037/117] waktusolat: Generalise celery timezone for all schedulers --- mika/waktusolat/README.md | 2 +- mika/waktusolat/templates/configmap.yaml | 4 ++-- mika/waktusolat/templates/deployment.yaml | 4 ++-- mika/waktusolat/values.yaml | 12 +++++++----- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/mika/waktusolat/README.md b/mika/waktusolat/README.md index 2523e453..72dad80a 100644 --- a/mika/waktusolat/README.md +++ b/mika/waktusolat/README.md @@ -101,9 +101,9 @@ helm uninstall $release_name --namespace $namespace --wait | resources.waktusolat.limits.memory | string | `"450Mi"` | The maximum amount of memory allowed for WaktuSolat. | | resources.waktusolat.requests.cpu | string | `"20m"` | The minimum amount of CPU resources required by WaktuSolat. | | resources.waktusolat.requests.memory | string | `"250Mi"` | The minimum amount of memory required by WaktuSolat. | -| waktusolat.celery_timezone | string | `"Asia/Kuala_Lumpur"` | The timezone for the Celery task scheduler used by WaktuSolat to schedule time-dependent operations. Default: `"Asia/Kuala_Lumpur"`. | | waktusolat.debug | bool | `false` | Specifies whether WaktuSolat should run in debug mode. Default: `false`. | | waktusolat.location | string | `""` | The default location code used by WaktuSolat and its services. Default: `"wlp-0"`. | | waktusolat.mastodon.api | string | `""` | API endpoint or URL for the Mastodon instance of the WaktuSolat bot. | | waktusolat.mastodon.token | string | `""` | A secure token required to authenticate the WaktuSolat service with the Mastodon instance's API. | +| waktusolat.scheduler.timezone | string | `""` | The timezone for the task scheduler used by WaktuSolat to schedule time-dependent operations. Default: `"Asia/Kuala_Lumpur"`. | | waktusolat.secret | string | `""` | A 50-character secret key used for secure session management and cryptographic operations within the WaktuSolat service. | diff --git a/mika/waktusolat/templates/configmap.yaml b/mika/waktusolat/templates/configmap.yaml index c9cd756e..2c121bf6 100644 --- a/mika/waktusolat/templates/configmap.yaml +++ b/mika/waktusolat/templates/configmap.yaml @@ -2,7 +2,7 @@ {{- $location := .Values.waktusolat.location | default "wlp-0" | toString | quote }} {{- $api := .Values.waktusolat.mastodon.api | toString | quote }} {{- $redis_service := printf "redis://%s-waktusolat-svc" .Release.Name | quote }} -{{- $celery_timezone := .Values.waktusolat.celery_timezone | default "Asia/Kuala_Lumpur" | toString | quote }} +{{- $scheduler_timezone := .Values.waktusolat.scheduler.timezone | default "Asia/Kuala_Lumpur" | toString | quote }} {{- $domain := .Values.waktusolat.domain | default "localhost" | toString }} apiVersion: v1 kind: ConfigMap @@ -16,7 +16,7 @@ data: API_BASE_URL: {{ $api }} CELERY_BROKER: {{ $redis_service }} CELERY_BACKEND: {{ $redis_service }} - CELERY_TIMEZONE: {{ $celery_timezone }} + SCHEDULER_TIMEZONE: {{ $scheduler_timezone }} --- apiVersion: v1 kind: ConfigMap diff --git a/mika/waktusolat/templates/deployment.yaml b/mika/waktusolat/templates/deployment.yaml index 87752bac..0bbaa75c 100644 --- a/mika/waktusolat/templates/deployment.yaml +++ b/mika/waktusolat/templates/deployment.yaml @@ -67,11 +67,11 @@ spec: configMapKeyRef: name: {{ .Release.Name }}-waktusolat-cm key: CELERY_BACKEND - - name: CELERY_TIMEZONE + - name: SCHEDULER_TIMEZONE valueFrom: configMapKeyRef: name: {{ .Release.Name }}-waktusolat-cm - key: CELERY_TIMEZONE + key: SCHEDULER_TIMEZONE - name: SECRET_KEY valueFrom: secretKeyRef: diff --git a/mika/waktusolat/values.yaml b/mika/waktusolat/values.yaml index 09fcc064..dd8fb162 100644 --- a/mika/waktusolat/values.yaml +++ b/mika/waktusolat/values.yaml @@ -59,11 +59,6 @@ waktusolat: # Example: # location: "wlp-0" location: "" - # The timezone for the Celery task scheduler used by WaktuSolat to schedule time-dependent operations. - # Default: "Asia/Kuala_Lumpur" - # Example: - # celery_timezone: "Asia/Kuala_Lumpur" - celery_timezone: "Asia/Kuala_Lumpur" # WaktuSolat Mastodon configurations. mastodon: # API endpoint or URL for the Mastodon instance of the WaktuSolat bot. @@ -74,6 +69,13 @@ waktusolat: # Example: # token: "6&p4%t)-$8a14fmfh92py8j55+us51r6%e52dzy&=a3-6yd4#e" token: "" + # WaktuSolat scheduler configurations. + scheduler: + # The timezone for the task scheduler used by WaktuSolat to schedule time-dependent operations. + # Default: "Asia/Kuala_Lumpur" + # Example: + # timezone: "Asia/Kuala_Lumpur" + timezone: "" # Database configurations. db: From 3864f7cb7acedd993e83f9f6fc5c2a0e1bfe280a Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 26 May 2023 00:38:17 +0800 Subject: [PATCH 038/117] waktusolat: Add new setting to toggle between using different schedulers --- mika/waktusolat/README.md | 2 ++ mika/waktusolat/values.yaml | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/mika/waktusolat/README.md b/mika/waktusolat/README.md index 72dad80a..8ff62c5b 100644 --- a/mika/waktusolat/README.md +++ b/mika/waktusolat/README.md @@ -105,5 +105,7 @@ helm uninstall $release_name --namespace $namespace --wait | waktusolat.location | string | `""` | The default location code used by WaktuSolat and its services. Default: `"wlp-0"`. | | waktusolat.mastodon.api | string | `""` | API endpoint or URL for the Mastodon instance of the WaktuSolat bot. | | waktusolat.mastodon.token | string | `""` | A secure token required to authenticate the WaktuSolat service with the Mastodon instance's API. | +| waktusolat.scheduler.apscheduler | bool | `false` | Specifies whether APScheduler should be used by WaktuSolat as the task scheduler. Default: `false`. | +| waktusolat.scheduler.celery | bool | `true` | Specifies whether Celery should be used by WaktuSolat as the task scheduler. Default: `true`. | | waktusolat.scheduler.timezone | string | `""` | The timezone for the task scheduler used by WaktuSolat to schedule time-dependent operations. Default: `"Asia/Kuala_Lumpur"`. | | waktusolat.secret | string | `""` | A 50-character secret key used for secure session management and cryptographic operations within the WaktuSolat service. | diff --git a/mika/waktusolat/values.yaml b/mika/waktusolat/values.yaml index dd8fb162..12f89d51 100644 --- a/mika/waktusolat/values.yaml +++ b/mika/waktusolat/values.yaml @@ -71,6 +71,16 @@ waktusolat: token: "" # WaktuSolat scheduler configurations. scheduler: + # Specifies whether APScheduler should be used by WaktuSolat as the task scheduler. + # Default: false + # Example: + # apscheduler: true + apscheduler: false + # Specifies whether Celery should be used by WaktuSolat as the task scheduler. + # Default: true + # Example: + # celery: false + celery: true # The timezone for the task scheduler used by WaktuSolat to schedule time-dependent operations. # Default: "Asia/Kuala_Lumpur" # Example: From e17efc75ab4cf31f21005e6197b74b7267226952 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 26 May 2023 01:09:57 +0800 Subject: [PATCH 039/117] waktusolat: Remove default values for bools as they're not entirely supported --- mika/waktusolat/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mika/waktusolat/README.md b/mika/waktusolat/README.md index 8ff62c5b..907787b2 100644 --- a/mika/waktusolat/README.md +++ b/mika/waktusolat/README.md @@ -105,7 +105,7 @@ helm uninstall $release_name --namespace $namespace --wait | waktusolat.location | string | `""` | The default location code used by WaktuSolat and its services. Default: `"wlp-0"`. | | waktusolat.mastodon.api | string | `""` | API endpoint or URL for the Mastodon instance of the WaktuSolat bot. | | waktusolat.mastodon.token | string | `""` | A secure token required to authenticate the WaktuSolat service with the Mastodon instance's API. | -| waktusolat.scheduler.apscheduler | bool | `false` | Specifies whether APScheduler should be used by WaktuSolat as the task scheduler. Default: `false`. | -| waktusolat.scheduler.celery | bool | `true` | Specifies whether Celery should be used by WaktuSolat as the task scheduler. Default: `true`. | +| waktusolat.scheduler.apscheduler | bool | `false` | Specifies whether APScheduler should be used by WaktuSolat as the task scheduler. | +| waktusolat.scheduler.celery | bool | `true` | Specifies whether Celery should be used by WaktuSolat as the task scheduler. | | waktusolat.scheduler.timezone | string | `""` | The timezone for the task scheduler used by WaktuSolat to schedule time-dependent operations. Default: `"Asia/Kuala_Lumpur"`. | | waktusolat.secret | string | `""` | A 50-character secret key used for secure session management and cryptographic operations within the WaktuSolat service. | From 27f782d3aa140a01cfba696a62eb6f1efbbd4f54 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 26 May 2023 01:11:17 +0800 Subject: [PATCH 040/117] waktusolat: Include celery components only when enabled --- mika/waktusolat/templates/configmap.yaml | 7 +++++++ mika/waktusolat/templates/deployment.yaml | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/mika/waktusolat/templates/configmap.yaml b/mika/waktusolat/templates/configmap.yaml index 2c121bf6..371899f5 100644 --- a/mika/waktusolat/templates/configmap.yaml +++ b/mika/waktusolat/templates/configmap.yaml @@ -4,6 +4,7 @@ {{- $redis_service := printf "redis://%s-waktusolat-svc" .Release.Name | quote }} {{- $scheduler_timezone := .Values.waktusolat.scheduler.timezone | default "Asia/Kuala_Lumpur" | toString | quote }} {{- $domain := .Values.waktusolat.domain | default "localhost" | toString }} +{{- $celery := .Values.waktusolat.scheduler.celery }} apiVersion: v1 kind: ConfigMap metadata: @@ -14,8 +15,10 @@ data: DEBUG: {{ $debug }} LOCATION_CODE: {{ $location }} API_BASE_URL: {{ $api }} + {{- if $celery }} CELERY_BROKER: {{ $redis_service }} CELERY_BACKEND: {{ $redis_service }} + {{- end }} SCHEDULER_TIMEZONE: {{ $scheduler_timezone }} --- apiVersion: v1 @@ -49,6 +52,7 @@ data: ErrorLog /var/log/apache2/apache.error.log CustomLog /var/log/apache2/apache.access.log combined +{{- if $celery }} --- apiVersion: v1 kind: ConfigMap @@ -71,6 +75,7 @@ data: {{- include "waktusolat.initd-celerybeat" . | nindent 4 }} celeryd: |- {{- include "waktusolat.initd-celeryd" . | nindent 4 }} +{{- end }} --- apiVersion: v1 kind: ConfigMap @@ -79,9 +84,11 @@ metadata: labels: {{- include "waktusolat.labels" . | nindent 4 }} data: + {{- if $celery }} celery.py: |- {{- include "waktusolat.celery-py" . | nindent 4 }} init.py: |- {{- include "waktusolat.init-py" . | nindent 4 }} + {{- end }} tasks.py: |- {{- include "waktusolat.tasks-py" . | nindent 4 }} diff --git a/mika/waktusolat/templates/deployment.yaml b/mika/waktusolat/templates/deployment.yaml index 0bbaa75c..c0879454 100644 --- a/mika/waktusolat/templates/deployment.yaml +++ b/mika/waktusolat/templates/deployment.yaml @@ -7,6 +7,7 @@ {{- $redis_repository := .Values.image.redis.repository | default "redis" | toString }} {{- $redis_tag := .Values.image.redis.tag | default "alpine" | toString }} {{- $redis_pullPolicy := .Values.image.redis.pullPolicy | default "IfNotPresent" | toString | quote }} +{{- $celery := .Values.waktusolat.scheduler.celery }} apiVersion: apps/v1 kind: Deployment metadata: @@ -57,6 +58,7 @@ spec: configMapKeyRef: name: {{ .Release.Name }}-waktusolat-cm key: API_BASE_URL + {{- if $celery }} - name: CELERY_BROKER valueFrom: configMapKeyRef: @@ -67,6 +69,7 @@ spec: configMapKeyRef: name: {{ .Release.Name }}-waktusolat-cm key: CELERY_BACKEND + {{- end }} - name: SCHEDULER_TIMEZONE valueFrom: configMapKeyRef: @@ -112,6 +115,7 @@ spec: mountPath: /etc/apache2/sites-available/000-default.conf subPath: site-config.conf readOnly: true + {{- if $celery }} - name: {{ .Release.Name }}-waktusolat-default-celery-config mountPath: /etc/default/celeryd subPath: celeryd @@ -127,6 +131,7 @@ spec: - name: {{ .Release.Name }}-waktusolat-scheduler-config mountPath: /base/base/__init__.py subPath: init.py + {{- end }} - name: {{ .Release.Name }}-waktusolat-scheduler-config mountPath: /base/base/tasks.py subPath: tasks.py @@ -134,6 +139,7 @@ spec: mountPath: /base/base/mastodon.secret subPath: mastodon.secret readOnly: true + {{- if $celery }} - name: redis image: {{ printf "%s/%s:%s" $redis_registry $redis_repository $redis_tag | quote }} imagePullPolicy: {{ $redis_pullPolicy }} @@ -143,10 +149,12 @@ spec: protocol: TCP resources: {{- toYaml .Values.resources.redis | nindent 12 }} + {{- end }} volumes: - name: {{ .Release.Name }}-waktusolat-site-config configMap: name: {{ .Release.Name }}-waktusolat-site-config + {{- if $celery }} - name: {{ .Release.Name }}-waktusolat-default-celery-config configMap: name: {{ .Release.Name }}-waktusolat-default-celery-config @@ -163,15 +171,18 @@ spec: path: celerybeat - key: celeryd path: celeryd + {{- end }} - name: {{ .Release.Name }}-waktusolat-scheduler-config configMap: name: {{ .Release.Name }}-waktusolat-scheduler-config defaultMode: 0775 items: + {{- if $celery }} - key: celery.py path: celery.py - key: init.py path: init.py + {{- end }} - key: tasks.py path: tasks.py - name: {{ .Release.Name }}-waktusolat-token-secret From 5876620f9056be37a939f33607701015cdfe6d0c Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 26 May 2023 02:41:36 +0800 Subject: [PATCH 041/117] waktusolat: Add APScheduler support --- mika/waktusolat/templates/_helpers.tpl | 49 ++++++++++++++++++++++- mika/waktusolat/templates/configmap.yaml | 12 +++++- mika/waktusolat/templates/deployment.yaml | 12 ++++++ 3 files changed, 70 insertions(+), 3 deletions(-) diff --git a/mika/waktusolat/templates/_helpers.tpl b/mika/waktusolat/templates/_helpers.tpl index 6f08c887..34dfb7c1 100644 --- a/mika/waktusolat/templates/_helpers.tpl +++ b/mika/waktusolat/templates/_helpers.tpl @@ -926,9 +926,9 @@ __all__ = ("celery_app",) {{- end }} {{/* -/base/base/tasks.py template +Celery /base/base/tasks.py template */}} -{{- define "waktusolat.tasks-py" -}} +{{- define "waktusolat.celery-tasks-py" -}} from __future__ import absolute_import, unicode_literals import logging from celery import shared_task @@ -960,3 +960,48 @@ def notify_solat_times_task(): def post_scheduler_task(): post_scheduler() {{- end }} + +{{/* +APScheduler /base/base/tasks.py template +*/}} +{{- define "waktusolat.apscheduler-tasks-py" -}} +from django.conf import settings +from base.methods import post_scheduler +from lib import solat +from apscheduler.schedulers.background import BackgroundScheduler + + +SCHEDULER_TIMEZONE = getattr(settings, "SCHEDULER_TIMEZONE", None) + + +def start(): + scheduler = BackgroundScheduler(timezone=SCHEDULER_TIMEZONE) + + job_name = "clean_db" + scheduler.add_job(solat.clean_db, 'cron', hour='0', id=job_name, replace_existing=True) + + job_name = "notify_solat_schedule" + scheduler.add_job(solat.notify_solat_schedule, 'cron', hour='5', id=job_name, replace_existing=True) + + job_name = "notify_solat_times" + scheduler.add_job(solat.notify_solat_times, 'cron', minute='*', id=job_name, replace_existing=True) + + job_name = "post_scheduler" + scheduler.add_job(post_scheduler, 'cron', second='*/1', id=job_name, replace_existing=True) + + scheduler.start() +{{- end }} + +{{/* +/base/base/apps.py template +*/}} +{{- define "waktusolat.apps-py" -}} +from django.apps import AppConfig + +class BaseConfig(AppConfig): + name = 'base' + + def ready(self): + from base import tasks + tasks.start() +{{- end }} diff --git a/mika/waktusolat/templates/configmap.yaml b/mika/waktusolat/templates/configmap.yaml index 371899f5..452f4173 100644 --- a/mika/waktusolat/templates/configmap.yaml +++ b/mika/waktusolat/templates/configmap.yaml @@ -4,6 +4,7 @@ {{- $redis_service := printf "redis://%s-waktusolat-svc" .Release.Name | quote }} {{- $scheduler_timezone := .Values.waktusolat.scheduler.timezone | default "Asia/Kuala_Lumpur" | toString | quote }} {{- $domain := .Values.waktusolat.domain | default "localhost" | toString }} +{{- $apscheduler := .Values.waktusolat.scheduler.apscheduler }} {{- $celery := .Values.waktusolat.scheduler.celery }} apiVersion: v1 kind: ConfigMap @@ -76,6 +77,7 @@ data: celeryd: |- {{- include "waktusolat.initd-celeryd" . | nindent 4 }} {{- end }} +{{- if or $apscheduler $celery }} --- apiVersion: v1 kind: ConfigMap @@ -89,6 +91,14 @@ data: {{- include "waktusolat.celery-py" . | nindent 4 }} init.py: |- {{- include "waktusolat.init-py" . | nindent 4 }} + {{- else if $apscheduler }} + apps.py: |- + {{- include "waktusolat.apps-py" . | nindent 4 }} {{- end }} tasks.py: |- - {{- include "waktusolat.tasks-py" . | nindent 4 }} + {{- if $celery }} + {{- include "waktusolat.celery-tasks-py" . | nindent 4 }} + {{- else if $apscheduler }} + {{- include "waktusolat.apscheduler-tasks-py" . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/mika/waktusolat/templates/deployment.yaml b/mika/waktusolat/templates/deployment.yaml index c0879454..3fbd2a54 100644 --- a/mika/waktusolat/templates/deployment.yaml +++ b/mika/waktusolat/templates/deployment.yaml @@ -7,6 +7,7 @@ {{- $redis_repository := .Values.image.redis.repository | default "redis" | toString }} {{- $redis_tag := .Values.image.redis.tag | default "alpine" | toString }} {{- $redis_pullPolicy := .Values.image.redis.pullPolicy | default "IfNotPresent" | toString | quote }} +{{- $apscheduler := .Values.waktusolat.scheduler.apscheduler }} {{- $celery := .Values.waktusolat.scheduler.celery }} apiVersion: apps/v1 kind: Deployment @@ -131,10 +132,16 @@ spec: - name: {{ .Release.Name }}-waktusolat-scheduler-config mountPath: /base/base/__init__.py subPath: init.py + {{- else if $apscheduler }} + - name: {{ .Release.Name }}-waktusolat-scheduler-config + mountPath: /base/base/apps.py + subPath: apps.py {{- end }} + {{- if or $apscheduler $celery }} - name: {{ .Release.Name }}-waktusolat-scheduler-config mountPath: /base/base/tasks.py subPath: tasks.py + {{- end }} - name: {{ .Release.Name }}-waktusolat-token-secret mountPath: /base/base/mastodon.secret subPath: mastodon.secret @@ -172,6 +179,7 @@ spec: - key: celeryd path: celeryd {{- end }} + {{- if or $apscheduler $celery }} - name: {{ .Release.Name }}-waktusolat-scheduler-config configMap: name: {{ .Release.Name }}-waktusolat-scheduler-config @@ -182,9 +190,13 @@ spec: path: celery.py - key: init.py path: init.py + {{- else if $apscheduler }} + - key: apps.py + path: apps.py {{- end }} - key: tasks.py path: tasks.py + {{- end }} - name: {{ .Release.Name }}-waktusolat-token-secret secret: secretName: {{ .Release.Name }}-waktusolat-token-secret From aa241ebc65fae7a4f665e07ee5bc382eaf50251f Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 1 Jun 2023 22:52:24 +0800 Subject: [PATCH 042/117] Generalise redis resources for scheduler --- mika/waktusolat/README.md | 8 ++++---- mika/waktusolat/templates/deployment.yaml | 2 +- mika/waktusolat/values.yaml | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/mika/waktusolat/README.md b/mika/waktusolat/README.md index 907787b2..2642e1b3 100644 --- a/mika/waktusolat/README.md +++ b/mika/waktusolat/README.md @@ -93,10 +93,10 @@ helm uninstall $release_name --namespace $namespace --wait | image.waktusolat.tag | string | `""` | The tag that specifies the version of the WaktuSolat container image used. Default: `Chart appVersion`. | | imagePullSecrets | list | `[]` | Credentials used to securely authenticate and authorise the pulling of container images from private registries. | | replicaCount | string | `""` | The desired number of running replicas for WaktuSolat. Default: `"1"`. | -| resources.redis.limits.cpu | string | `"15m"` | The maximum amount of CPU resources allowed for Redis. | -| resources.redis.limits.memory | string | `"50Mi"` | The maximum amount of memory allowed for Redis. | -| resources.redis.requests.cpu | string | `"5m"` | The minimum amount of CPU resources required by Redis. | -| resources.redis.requests.memory | string | `"30Mi"` | The minimum amount of memory required by Redis. | +| resources.scheduler.limits.cpu | string | `"15m"` | The maximum amount of CPU resources allowed for Scheduler. | +| resources.scheduler.limits.memory | string | `"50Mi"` | The maximum amount of memory allowed for Scheduler. | +| resources.scheduler.requests.cpu | string | `"5m"` | The minimum amount of CPU resources required by Scheduler. | +| resources.scheduler.requests.memory | string | `"30Mi"` | The minimum amount of memory required by Scheduler. | | resources.waktusolat.limits.cpu | string | `"50m"` | The maximum amount of CPU resources allowed for WaktuSolat. | | resources.waktusolat.limits.memory | string | `"450Mi"` | The maximum amount of memory allowed for WaktuSolat. | | resources.waktusolat.requests.cpu | string | `"20m"` | The minimum amount of CPU resources required by WaktuSolat. | diff --git a/mika/waktusolat/templates/deployment.yaml b/mika/waktusolat/templates/deployment.yaml index 3fbd2a54..0f3986e9 100644 --- a/mika/waktusolat/templates/deployment.yaml +++ b/mika/waktusolat/templates/deployment.yaml @@ -155,7 +155,7 @@ spec: containerPort: 6379 protocol: TCP resources: - {{- toYaml .Values.resources.redis | nindent 12 }} + {{- toYaml .Values.resources.scheduler | nindent 12 }} {{- end }} volumes: - name: {{ .Release.Name }}-waktusolat-site-config diff --git a/mika/waktusolat/values.yaml b/mika/waktusolat/values.yaml index 12f89d51..2ef56650 100644 --- a/mika/waktusolat/values.yaml +++ b/mika/waktusolat/values.yaml @@ -140,25 +140,25 @@ resources: # Example: # memory: "450Mi" memory: "450Mi" - # Redis container resources. - redis: - # The minimum amount of resources required by Redis to run. + # Scheduler container resources. + scheduler: + # The minimum amount of resources required by Scheduler to run. requests: - # The minimum amount of CPU resources required by Redis. + # The minimum amount of CPU resources required by Scheduler. # Example: # cpu: "5m" cpu: "5m" - # The minimum amount of memory required by Redis. + # The minimum amount of memory required by Scheduler. # Example: # memory: "30Mi" memory: "30Mi" - # The maximum amount of resources allowed for Redis. + # The maximum amount of resources allowed for Scheduler. limits: - # The maximum amount of CPU resources allowed for Redis. + # The maximum amount of CPU resources allowed for Scheduler. # Example: # cpu: "15m" cpu: "15m" - # The maximum amount of memory allowed for Redis. + # The maximum amount of memory allowed for Scheduler. # Example: # memory: "50Mi" memory: "50Mi" From 9d8e3b0e344b30349751b10f4b22d814c7fd40da Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 1 Jun 2023 22:57:31 +0800 Subject: [PATCH 043/117] Updated recommended scheduler resources values --- mika/waktusolat/README.md | 14 +++++++------- mika/waktusolat/values.yaml | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/mika/waktusolat/README.md b/mika/waktusolat/README.md index 2642e1b3..30ca59d0 100644 --- a/mika/waktusolat/README.md +++ b/mika/waktusolat/README.md @@ -93,14 +93,14 @@ helm uninstall $release_name --namespace $namespace --wait | image.waktusolat.tag | string | `""` | The tag that specifies the version of the WaktuSolat container image used. Default: `Chart appVersion`. | | imagePullSecrets | list | `[]` | Credentials used to securely authenticate and authorise the pulling of container images from private registries. | | replicaCount | string | `""` | The desired number of running replicas for WaktuSolat. Default: `"1"`. | -| resources.scheduler.limits.cpu | string | `"15m"` | The maximum amount of CPU resources allowed for Scheduler. | -| resources.scheduler.limits.memory | string | `"50Mi"` | The maximum amount of memory allowed for Scheduler. | -| resources.scheduler.requests.cpu | string | `"5m"` | The minimum amount of CPU resources required by Scheduler. | -| resources.scheduler.requests.memory | string | `"30Mi"` | The minimum amount of memory required by Scheduler. | +| resources.scheduler.limits.cpu | string | `"20m"` | The maximum amount of CPU resources allowed for Scheduler. | +| resources.scheduler.limits.memory | string | `"200Mi"` | The maximum amount of memory allowed for Scheduler. | +| resources.scheduler.requests.cpu | string | `"10m"` | The minimum amount of CPU resources required by Scheduler. | +| resources.scheduler.requests.memory | string | `"100Mi"` | The minimum amount of memory required by Scheduler. | | resources.waktusolat.limits.cpu | string | `"50m"` | The maximum amount of CPU resources allowed for WaktuSolat. | -| resources.waktusolat.limits.memory | string | `"450Mi"` | The maximum amount of memory allowed for WaktuSolat. | -| resources.waktusolat.requests.cpu | string | `"20m"` | The minimum amount of CPU resources required by WaktuSolat. | -| resources.waktusolat.requests.memory | string | `"250Mi"` | The minimum amount of memory required by WaktuSolat. | +| resources.waktusolat.limits.memory | string | `"120Mi"` | The maximum amount of memory allowed for WaktuSolat. | +| resources.waktusolat.requests.cpu | string | `"30m"` | The minimum amount of CPU resources required by WaktuSolat. | +| resources.waktusolat.requests.memory | string | `"60Mi"` | The minimum amount of memory required by WaktuSolat. | | waktusolat.debug | bool | `false` | Specifies whether WaktuSolat should run in debug mode. Default: `false`. | | waktusolat.location | string | `""` | The default location code used by WaktuSolat and its services. Default: `"wlp-0"`. | | waktusolat.mastodon.api | string | `""` | API endpoint or URL for the Mastodon instance of the WaktuSolat bot. | diff --git a/mika/waktusolat/values.yaml b/mika/waktusolat/values.yaml index 2ef56650..3b47e7c9 100644 --- a/mika/waktusolat/values.yaml +++ b/mika/waktusolat/values.yaml @@ -125,11 +125,11 @@ resources: # The minimum amount of CPU resources required by WaktuSolat. # Example: # cpu: "20m" - cpu: "20m" + cpu: "30m" # The minimum amount of memory required by WaktuSolat. # Example: # memory: "250Mi" - memory: "250Mi" + memory: "60Mi" # The maximum amount of resources allowed for WaktuSolat. limits: # The maximum amount of CPU resources allowed for WaktuSolat. @@ -139,7 +139,7 @@ resources: # The maximum amount of memory allowed for WaktuSolat. # Example: # memory: "450Mi" - memory: "450Mi" + memory: "120Mi" # Scheduler container resources. scheduler: # The minimum amount of resources required by Scheduler to run. @@ -147,18 +147,18 @@ resources: # The minimum amount of CPU resources required by Scheduler. # Example: # cpu: "5m" - cpu: "5m" + cpu: "10m" # The minimum amount of memory required by Scheduler. # Example: # memory: "30Mi" - memory: "30Mi" + memory: "100Mi" # The maximum amount of resources allowed for Scheduler. limits: # The maximum amount of CPU resources allowed for Scheduler. # Example: # cpu: "15m" - cpu: "15m" + cpu: "20m" # The maximum amount of memory allowed for Scheduler. # Example: # memory: "50Mi" - memory: "50Mi" + memory: "200Mi" From 3e7e05d0a74094d8ff3d9156b6628a5d7c26a82f Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 1 Jun 2023 23:00:10 +0800 Subject: [PATCH 044/117] Scheduler toggles have no default values --- mika/waktusolat/values.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/mika/waktusolat/values.yaml b/mika/waktusolat/values.yaml index 3b47e7c9..65279c8e 100644 --- a/mika/waktusolat/values.yaml +++ b/mika/waktusolat/values.yaml @@ -72,12 +72,10 @@ waktusolat: # WaktuSolat scheduler configurations. scheduler: # Specifies whether APScheduler should be used by WaktuSolat as the task scheduler. - # Default: false # Example: # apscheduler: true apscheduler: false # Specifies whether Celery should be used by WaktuSolat as the task scheduler. - # Default: true # Example: # celery: false celery: true From 10898c7a23a069c6650f5963244d6a6ad5359e5b Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 1 Jun 2023 23:04:33 +0800 Subject: [PATCH 045/117] Use BlockingScheduler for APScheduler --- mika/waktusolat/templates/_helpers.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mika/waktusolat/templates/_helpers.tpl b/mika/waktusolat/templates/_helpers.tpl index 34dfb7c1..76cf8b3f 100644 --- a/mika/waktusolat/templates/_helpers.tpl +++ b/mika/waktusolat/templates/_helpers.tpl @@ -968,14 +968,14 @@ APScheduler /base/base/tasks.py template from django.conf import settings from base.methods import post_scheduler from lib import solat -from apscheduler.schedulers.background import BackgroundScheduler +from apscheduler.schedulers.blocking import BlockingScheduler SCHEDULER_TIMEZONE = getattr(settings, "SCHEDULER_TIMEZONE", None) def start(): - scheduler = BackgroundScheduler(timezone=SCHEDULER_TIMEZONE) + scheduler = BlockingScheduler(timezone=SCHEDULER_TIMEZONE) job_name = "clean_db" scheduler.add_job(solat.clean_db, 'cron', hour='0', id=job_name, replace_existing=True) From 4c7bada28dce50079f1e50d78a8156fdbce52ab7 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 1 Jun 2023 23:31:38 +0800 Subject: [PATCH 046/117] Add custom entrypoint for apscheduler --- mika/waktusolat/templates/_helpers.tpl | 17 +++++++++++++++++ mika/waktusolat/templates/configmap.yaml | 13 ++++++++++++- mika/waktusolat/templates/deployment.yaml | 10 +++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/mika/waktusolat/templates/_helpers.tpl b/mika/waktusolat/templates/_helpers.tpl index 76cf8b3f..075f50fb 100644 --- a/mika/waktusolat/templates/_helpers.tpl +++ b/mika/waktusolat/templates/_helpers.tpl @@ -992,6 +992,23 @@ def start(): scheduler.start() {{- end }} +{{/* +APScheduler /entrypoint.sh template +*/}} +{{- define "waktusolat.apscheduler-entrypoint-sh" -}} +#!/bin/bash + +export APP_ROOT="base" + +# ================= DO NOT EDIT BEYOND THIS LINE ================= + +python3 manage.py makemigrations + +python3 manage.py migrate + +tail -f /dev/null +{{- end }} + {{/* /base/base/apps.py template */}} diff --git a/mika/waktusolat/templates/configmap.yaml b/mika/waktusolat/templates/configmap.yaml index 452f4173..d500cdcf 100644 --- a/mika/waktusolat/templates/configmap.yaml +++ b/mika/waktusolat/templates/configmap.yaml @@ -53,7 +53,18 @@ data: ErrorLog /var/log/apache2/apache.error.log CustomLog /var/log/apache2/apache.access.log combined -{{- if $celery }} +{{- if $apscheduler }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-waktusolat-apscheduler-config + labels: + {{- include "waktusolat.labels" . | nindent 4 }} +data: + entrypoint.sh: |- + {{- include "waktusolat.apscheduler-entrypoint-sh" . | nindent 4 }} +{{- else if $celery }} --- apiVersion: v1 kind: ConfigMap diff --git a/mika/waktusolat/templates/deployment.yaml b/mika/waktusolat/templates/deployment.yaml index 0f3986e9..16bd03d9 100644 --- a/mika/waktusolat/templates/deployment.yaml +++ b/mika/waktusolat/templates/deployment.yaml @@ -161,7 +161,15 @@ spec: - name: {{ .Release.Name }}-waktusolat-site-config configMap: name: {{ .Release.Name }}-waktusolat-site-config - {{- if $celery }} + {{- if $apscheduler }} + - name: {{ .Release.Name }}-waktusolat-apscheduler-config + configMap: + name: {{ .Release.Name }}-waktusolat-apscheduler-config + defaultMode: 0755 + items: + - key: entrypoint.sh + path: entrypoint.sh + {{- else if $celery }} - name: {{ .Release.Name }}-waktusolat-default-celery-config configMap: name: {{ .Release.Name }}-waktusolat-default-celery-config From 3feb9a821283438cfeb30c6c3ba17b2263fc1412 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 1 Jun 2023 23:32:53 +0800 Subject: [PATCH 047/117] Add sidecar container for apscheduler --- mika/waktusolat/templates/configmap.yaml | 14 ++-- mika/waktusolat/templates/deployment.yaml | 84 +++++++++++++++++++++-- 2 files changed, 86 insertions(+), 12 deletions(-) diff --git a/mika/waktusolat/templates/configmap.yaml b/mika/waktusolat/templates/configmap.yaml index d500cdcf..54015f60 100644 --- a/mika/waktusolat/templates/configmap.yaml +++ b/mika/waktusolat/templates/configmap.yaml @@ -97,19 +97,19 @@ metadata: labels: {{- include "waktusolat.labels" . | nindent 4 }} data: - {{- if $celery }} + {{- if $apscheduler }} + apps.py: |- + {{- include "waktusolat.apps-py" . | nindent 4 }} + {{- else if $celery }} celery.py: |- {{- include "waktusolat.celery-py" . | nindent 4 }} init.py: |- {{- include "waktusolat.init-py" . | nindent 4 }} - {{- else if $apscheduler }} - apps.py: |- - {{- include "waktusolat.apps-py" . | nindent 4 }} {{- end }} tasks.py: |- - {{- if $celery }} - {{- include "waktusolat.celery-tasks-py" . | nindent 4 }} - {{- else if $apscheduler }} + {{- if $apscheduler }} {{- include "waktusolat.apscheduler-tasks-py" . | nindent 4 }} + {{- else if $celery }} + {{- include "waktusolat.celery-tasks-py" . | nindent 4 }} {{- end }} {{- end }} diff --git a/mika/waktusolat/templates/deployment.yaml b/mika/waktusolat/templates/deployment.yaml index 16bd03d9..2333a2d6 100644 --- a/mika/waktusolat/templates/deployment.yaml +++ b/mika/waktusolat/templates/deployment.yaml @@ -129,24 +129,98 @@ spec: - name: {{ .Release.Name }}-waktusolat-scheduler-config mountPath: /base/base/celery.py subPath: celery.py + - name: {{ .Release.Name }}-waktusolat-scheduler-config + mountPath: /base/base/tasks.py + subPath: tasks.py - name: {{ .Release.Name }}-waktusolat-scheduler-config mountPath: /base/base/__init__.py subPath: init.py - {{- else if $apscheduler }} + {{- end }} + - name: {{ .Release.Name }}-waktusolat-token-secret + mountPath: /base/base/mastodon.secret + subPath: mastodon.secret + readOnly: true + {{- if $apscheduler }} + - name: apscheduler + image: {{ printf "%s/%s:%s" $waktusolat_registry $waktusolat_repository $waktusolat_tag | quote }} + imagePullPolicy: {{ $waktusolat_pullPolicy }} + ports: + - name: waktusolat + containerPort: 80 + protocol: TCP + resources: + {{- toYaml .Values.resources.scheduler | nindent 12 }} + env: + - name: DEBUG + valueFrom: + configMapKeyRef: + name: {{ .Release.Name }}-waktusolat-cm + key: DEBUG + - name: LOCATION_CODE + valueFrom: + configMapKeyRef: + name: {{ .Release.Name }}-waktusolat-cm + key: LOCATION_CODE + - name: API_BASE_URL + valueFrom: + configMapKeyRef: + name: {{ .Release.Name }}-waktusolat-cm + key: API_BASE_URL + - name: SCHEDULER_TIMEZONE + valueFrom: + configMapKeyRef: + name: {{ .Release.Name }}-waktusolat-cm + key: SCHEDULER_TIMEZONE + - name: SECRET_KEY + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-waktusolat-secret + key: SECRET_KEY + - name: DB_TYPE + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-waktusolat-secret + key: DB_TYPE + - name: DB_NAME + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-waktusolat-secret + key: DB_NAME + - name: DB_USER + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-waktusolat-secret + key: DB_USER + - name: DB_PASS + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-waktusolat-secret + key: DB_PASS + - name: DB_HOST + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-waktusolat-secret + key: DB_HOST + - name: DB_PORT + valueFrom: + secretKeyRef: + name: {{ .Release.Name }}-waktusolat-secret + key: DB_PORT + volumeMounts: + - name: {{ .Release.Name }}-waktusolat-apscheduler-config + mountPath: /entrypoint.sh + subPath: entrypoint.sh - name: {{ .Release.Name }}-waktusolat-scheduler-config mountPath: /base/base/apps.py subPath: apps.py - {{- end }} - {{- if or $apscheduler $celery }} - name: {{ .Release.Name }}-waktusolat-scheduler-config mountPath: /base/base/tasks.py subPath: tasks.py - {{- end }} - name: {{ .Release.Name }}-waktusolat-token-secret mountPath: /base/base/mastodon.secret subPath: mastodon.secret readOnly: true - {{- if $celery }} + {{- else if $celery }} - name: redis image: {{ printf "%s/%s:%s" $redis_registry $redis_repository $redis_tag | quote }} imagePullPolicy: {{ $redis_pullPolicy }} From e9e11c4f8ac0cbb887bfaf0e6509e64cdacb8500 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 2 Jun 2023 00:13:45 +0800 Subject: [PATCH 048/117] Update template names --- mika/waktusolat/templates/_helpers.tpl | 16 ++++++++-------- mika/waktusolat/templates/configmap.yaml | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mika/waktusolat/templates/_helpers.tpl b/mika/waktusolat/templates/_helpers.tpl index 075f50fb..7e845b84 100644 --- a/mika/waktusolat/templates/_helpers.tpl +++ b/mika/waktusolat/templates/_helpers.tpl @@ -62,7 +62,7 @@ Create the name of the service account to use {{- end }} {{/* -/etc/default/celeryd template +Celery /etc/default/celeryd template */}} {{- define "waktusolat.default-celeryd" -}} # Names of nodes to start @@ -122,7 +122,7 @@ CELERY_CREATE_DIRS=1 {{- end }} {{/* -/etc/init.d/celerybeat template +Celery /etc/init.d/celerybeat template */}} {{- define "waktusolat.initd-celerybeat" -}} #!/bin/sh -e @@ -457,7 +457,7 @@ exit 0 {{- end }} {{/* -/etc/init.d/celeryd template +Celery /etc/init.d/celeryd template */}} {{- define "waktusolat.initd-celeryd" -}} #!/bin/sh -e @@ -874,7 +874,7 @@ exit 0 {{- end }} {{/* -/base/base/celery.py template +Celery /base/base/celery.py template */}} {{- define "waktusolat.celery-py" -}} from __future__ import absolute_import, unicode_literals @@ -917,9 +917,9 @@ def debug_task(self): {{- end }} {{/* -/base/base/__init__.py template +Celery /base/base/__init__.py template */}} -{{- define "waktusolat.init-py" -}} +{{- define "waktusolat.celery-init-py" -}} from .celery import app as celery_app __all__ = ("celery_app",) @@ -1010,9 +1010,9 @@ tail -f /dev/null {{- end }} {{/* -/base/base/apps.py template +APScheduler /base/base/apps.py template */}} -{{- define "waktusolat.apps-py" -}} +{{- define "waktusolat.apscheduler-apps-py" -}} from django.apps import AppConfig class BaseConfig(AppConfig): diff --git a/mika/waktusolat/templates/configmap.yaml b/mika/waktusolat/templates/configmap.yaml index 54015f60..166d8d9f 100644 --- a/mika/waktusolat/templates/configmap.yaml +++ b/mika/waktusolat/templates/configmap.yaml @@ -99,12 +99,12 @@ metadata: data: {{- if $apscheduler }} apps.py: |- - {{- include "waktusolat.apps-py" . | nindent 4 }} + {{- include "waktusolat.apscheduler-apps-py" . | nindent 4 }} {{- else if $celery }} celery.py: |- {{- include "waktusolat.celery-py" . | nindent 4 }} init.py: |- - {{- include "waktusolat.init-py" . | nindent 4 }} + {{- include "waktusolat.celery-init-py" . | nindent 4 }} {{- end }} tasks.py: |- {{- if $apscheduler }} From d33577774d589c1e28e106fd4e9e61d9002772e1 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 2 Jun 2023 00:16:53 +0800 Subject: [PATCH 049/117] Make apscheduler the recommended scheduler --- mika/waktusolat/README.md | 4 ++-- mika/waktusolat/values.yaml | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mika/waktusolat/README.md b/mika/waktusolat/README.md index 30ca59d0..dc87cc63 100644 --- a/mika/waktusolat/README.md +++ b/mika/waktusolat/README.md @@ -105,7 +105,7 @@ helm uninstall $release_name --namespace $namespace --wait | waktusolat.location | string | `""` | The default location code used by WaktuSolat and its services. Default: `"wlp-0"`. | | waktusolat.mastodon.api | string | `""` | API endpoint or URL for the Mastodon instance of the WaktuSolat bot. | | waktusolat.mastodon.token | string | `""` | A secure token required to authenticate the WaktuSolat service with the Mastodon instance's API. | -| waktusolat.scheduler.apscheduler | bool | `false` | Specifies whether APScheduler should be used by WaktuSolat as the task scheduler. | -| waktusolat.scheduler.celery | bool | `true` | Specifies whether Celery should be used by WaktuSolat as the task scheduler. | +| waktusolat.scheduler.apscheduler | bool | `true` | Specifies whether APScheduler should be used by WaktuSolat as the task scheduler. | +| waktusolat.scheduler.celery | bool | `false` | Specifies whether Celery should be used by WaktuSolat as the task scheduler. | | waktusolat.scheduler.timezone | string | `""` | The timezone for the task scheduler used by WaktuSolat to schedule time-dependent operations. Default: `"Asia/Kuala_Lumpur"`. | | waktusolat.secret | string | `""` | A 50-character secret key used for secure session management and cryptographic operations within the WaktuSolat service. | diff --git a/mika/waktusolat/values.yaml b/mika/waktusolat/values.yaml index 65279c8e..fb1a89ec 100644 --- a/mika/waktusolat/values.yaml +++ b/mika/waktusolat/values.yaml @@ -73,12 +73,12 @@ waktusolat: scheduler: # Specifies whether APScheduler should be used by WaktuSolat as the task scheduler. # Example: - # apscheduler: true - apscheduler: false + # apscheduler: false + apscheduler: true # Specifies whether Celery should be used by WaktuSolat as the task scheduler. # Example: - # celery: false - celery: true + # celery: true + celery: false # The timezone for the task scheduler used by WaktuSolat to schedule time-dependent operations. # Default: "Asia/Kuala_Lumpur" # Example: From 8077cfca3a17700b495c778f069758d36c7007e5 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 2 Jun 2023 00:18:02 +0800 Subject: [PATCH 050/117] Include SCHEDULER_TIMEZONE var only if a scheduler is enabled --- mika/waktusolat/templates/configmap.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mika/waktusolat/templates/configmap.yaml b/mika/waktusolat/templates/configmap.yaml index 166d8d9f..e570f309 100644 --- a/mika/waktusolat/templates/configmap.yaml +++ b/mika/waktusolat/templates/configmap.yaml @@ -20,7 +20,9 @@ data: CELERY_BROKER: {{ $redis_service }} CELERY_BACKEND: {{ $redis_service }} {{- end }} + {{- if or $apscheduler $celery }} SCHEDULER_TIMEZONE: {{ $scheduler_timezone }} + {{- end }} --- apiVersion: v1 kind: ConfigMap From ded44d77a987e7e4891cc9fafd9f73ca7c4765db Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 2 Jun 2023 00:43:08 +0800 Subject: [PATCH 051/117] Reorder helper templates --- mika/waktusolat/templates/_helpers.tpl | 124 ++++++++++++------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/mika/waktusolat/templates/_helpers.tpl b/mika/waktusolat/templates/_helpers.tpl index 7e845b84..28dba842 100644 --- a/mika/waktusolat/templates/_helpers.tpl +++ b/mika/waktusolat/templates/_helpers.tpl @@ -61,6 +61,68 @@ Create the name of the service account to use {{- end }} {{- end }} +{{/* +APScheduler /entrypoint.sh template +*/}} +{{- define "waktusolat.apscheduler-entrypoint-sh" -}} +#!/bin/bash + +export APP_ROOT="base" + +# ================= DO NOT EDIT BEYOND THIS LINE ================= + +python3 manage.py makemigrations + +python3 manage.py migrate + +tail -f /dev/null +{{- end }} + +{{/* +APScheduler /base/base/apps.py template +*/}} +{{- define "waktusolat.apscheduler-apps-py" -}} +from django.apps import AppConfig + +class BaseConfig(AppConfig): + name = 'base' + + def ready(self): + from base import tasks + tasks.start() +{{- end }} + +{{/* +APScheduler /base/base/tasks.py template +*/}} +{{- define "waktusolat.apscheduler-tasks-py" -}} +from django.conf import settings +from base.methods import post_scheduler +from lib import solat +from apscheduler.schedulers.blocking import BlockingScheduler + + +SCHEDULER_TIMEZONE = getattr(settings, "SCHEDULER_TIMEZONE", None) + + +def start(): + scheduler = BlockingScheduler(timezone=SCHEDULER_TIMEZONE) + + job_name = "clean_db" + scheduler.add_job(solat.clean_db, 'cron', hour='0', id=job_name, replace_existing=True) + + job_name = "notify_solat_schedule" + scheduler.add_job(solat.notify_solat_schedule, 'cron', hour='5', id=job_name, replace_existing=True) + + job_name = "notify_solat_times" + scheduler.add_job(solat.notify_solat_times, 'cron', minute='*', id=job_name, replace_existing=True) + + job_name = "post_scheduler" + scheduler.add_job(post_scheduler, 'cron', second='*/1', id=job_name, replace_existing=True) + + scheduler.start() +{{- end }} + {{/* Celery /etc/default/celeryd template */}} @@ -960,65 +1022,3 @@ def notify_solat_times_task(): def post_scheduler_task(): post_scheduler() {{- end }} - -{{/* -APScheduler /base/base/tasks.py template -*/}} -{{- define "waktusolat.apscheduler-tasks-py" -}} -from django.conf import settings -from base.methods import post_scheduler -from lib import solat -from apscheduler.schedulers.blocking import BlockingScheduler - - -SCHEDULER_TIMEZONE = getattr(settings, "SCHEDULER_TIMEZONE", None) - - -def start(): - scheduler = BlockingScheduler(timezone=SCHEDULER_TIMEZONE) - - job_name = "clean_db" - scheduler.add_job(solat.clean_db, 'cron', hour='0', id=job_name, replace_existing=True) - - job_name = "notify_solat_schedule" - scheduler.add_job(solat.notify_solat_schedule, 'cron', hour='5', id=job_name, replace_existing=True) - - job_name = "notify_solat_times" - scheduler.add_job(solat.notify_solat_times, 'cron', minute='*', id=job_name, replace_existing=True) - - job_name = "post_scheduler" - scheduler.add_job(post_scheduler, 'cron', second='*/1', id=job_name, replace_existing=True) - - scheduler.start() -{{- end }} - -{{/* -APScheduler /entrypoint.sh template -*/}} -{{- define "waktusolat.apscheduler-entrypoint-sh" -}} -#!/bin/bash - -export APP_ROOT="base" - -# ================= DO NOT EDIT BEYOND THIS LINE ================= - -python3 manage.py makemigrations - -python3 manage.py migrate - -tail -f /dev/null -{{- end }} - -{{/* -APScheduler /base/base/apps.py template -*/}} -{{- define "waktusolat.apscheduler-apps-py" -}} -from django.apps import AppConfig - -class BaseConfig(AppConfig): - name = 'base' - - def ready(self): - from base import tasks - tasks.start() -{{- end }} From 940331c67a56227402f5f06814cbf99da72e3d66 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 2 Jun 2023 00:53:15 +0800 Subject: [PATCH 052/117] Use envFrom for configmap and secret env variables --- mika/waktusolat/templates/deployment.yaml | 134 ++-------------------- 1 file changed, 10 insertions(+), 124 deletions(-) diff --git a/mika/waktusolat/templates/deployment.yaml b/mika/waktusolat/templates/deployment.yaml index 2333a2d6..c99dbed0 100644 --- a/mika/waktusolat/templates/deployment.yaml +++ b/mika/waktusolat/templates/deployment.yaml @@ -43,74 +43,11 @@ spec: protocol: TCP resources: {{- toYaml .Values.resources.waktusolat | nindent 12 }} - env: - - name: DEBUG - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-waktusolat-cm - key: DEBUG - - name: LOCATION_CODE - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-waktusolat-cm - key: LOCATION_CODE - - name: API_BASE_URL - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-waktusolat-cm - key: API_BASE_URL - {{- if $celery }} - - name: CELERY_BROKER - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-waktusolat-cm - key: CELERY_BROKER - - name: CELERY_BACKEND - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-waktusolat-cm - key: CELERY_BACKEND - {{- end }} - - name: SCHEDULER_TIMEZONE - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-waktusolat-cm - key: SCHEDULER_TIMEZONE - - name: SECRET_KEY - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-waktusolat-secret - key: SECRET_KEY - - name: DB_TYPE - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-waktusolat-secret - key: DB_TYPE - - name: DB_NAME - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-waktusolat-secret - key: DB_NAME - - name: DB_USER - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-waktusolat-secret - key: DB_USER - - name: DB_PASS - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-waktusolat-secret - key: DB_PASS - - name: DB_HOST - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-waktusolat-secret - key: DB_HOST - - name: DB_PORT - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-waktusolat-secret - key: DB_PORT + envFrom: + - configMapRef: + name: {{ .Release.Name }}-waktusolat-cm + - secretRef: + name: {{ .Release.Name }}-waktusolat-secret volumeMounts: - name: {{ .Release.Name }}-waktusolat-site-config mountPath: /etc/apache2/sites-available/000-default.conf @@ -150,62 +87,11 @@ spec: protocol: TCP resources: {{- toYaml .Values.resources.scheduler | nindent 12 }} - env: - - name: DEBUG - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-waktusolat-cm - key: DEBUG - - name: LOCATION_CODE - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-waktusolat-cm - key: LOCATION_CODE - - name: API_BASE_URL - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-waktusolat-cm - key: API_BASE_URL - - name: SCHEDULER_TIMEZONE - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-waktusolat-cm - key: SCHEDULER_TIMEZONE - - name: SECRET_KEY - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-waktusolat-secret - key: SECRET_KEY - - name: DB_TYPE - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-waktusolat-secret - key: DB_TYPE - - name: DB_NAME - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-waktusolat-secret - key: DB_NAME - - name: DB_USER - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-waktusolat-secret - key: DB_USER - - name: DB_PASS - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-waktusolat-secret - key: DB_PASS - - name: DB_HOST - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-waktusolat-secret - key: DB_HOST - - name: DB_PORT - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-waktusolat-secret - key: DB_PORT + envFrom: + - configMapRef: + name: {{ .Release.Name }}-waktusolat-cm + - secretRef: + name: {{ .Release.Name }}-waktusolat-secret volumeMounts: - name: {{ .Release.Name }}-waktusolat-apscheduler-config mountPath: /entrypoint.sh From f33b14fd87e98a832cc4756e656131b9ac9d9ed9 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sat, 3 Jun 2023 01:49:05 +0800 Subject: [PATCH 053/117] Add missing domain setting --- mika/waktusolat/README.md | 1 + mika/waktusolat/values.yaml | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/mika/waktusolat/README.md b/mika/waktusolat/README.md index dc87cc63..9fbdd507 100644 --- a/mika/waktusolat/README.md +++ b/mika/waktusolat/README.md @@ -102,6 +102,7 @@ helm uninstall $release_name --namespace $namespace --wait | resources.waktusolat.requests.cpu | string | `"30m"` | The minimum amount of CPU resources required by WaktuSolat. | | resources.waktusolat.requests.memory | string | `"60Mi"` | The minimum amount of memory required by WaktuSolat. | | waktusolat.debug | bool | `false` | Specifies whether WaktuSolat should run in debug mode. Default: `false`. | +| waktusolat.domain | string | `""` | The domain name of the WaktuSolat service. Default: `"localhost"`. | | waktusolat.location | string | `""` | The default location code used by WaktuSolat and its services. Default: `"wlp-0"`. | | waktusolat.mastodon.api | string | `""` | API endpoint or URL for the Mastodon instance of the WaktuSolat bot. | | waktusolat.mastodon.token | string | `""` | A secure token required to authenticate the WaktuSolat service with the Mastodon instance's API. | diff --git a/mika/waktusolat/values.yaml b/mika/waktusolat/values.yaml index fb1a89ec..3ce226a2 100644 --- a/mika/waktusolat/values.yaml +++ b/mika/waktusolat/values.yaml @@ -50,6 +50,11 @@ waktusolat: # Example: # debug: true debug: false + # The domain name of the WaktuSolat service. + # Default: "localhost" + # Example: + # domain: "localhost" + domain: "" # A 50-character secret key used for secure session management and cryptographic operations within the WaktuSolat service. # Example: # secret: "6&p4%t)-$8a14fmfh92py8j55+us51r6%e52dzy&=a3-6yd4#e" From 21af8d868f6ac8067e99281455ca4cd2d3ebdcff Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sat, 3 Jun 2023 01:49:22 +0800 Subject: [PATCH 054/117] Only include the redis port if celery is enabled --- mika/waktusolat/templates/service.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mika/waktusolat/templates/service.yaml b/mika/waktusolat/templates/service.yaml index 63924a7a..c423e77a 100644 --- a/mika/waktusolat/templates/service.yaml +++ b/mika/waktusolat/templates/service.yaml @@ -1,3 +1,4 @@ +{{- $celery := .Values.waktusolat.scheduler.celery }} apiVersion: v1 kind: Service metadata: @@ -11,9 +12,11 @@ spec: targetPort: waktusolat protocol: TCP name: {{ .Release.Name }}-waktusolat + {{- if $celery }} - port: 6379 targetPort: redis protocol: TCP name: {{ .Release.Name }}-redis + {{- end }} selector: {{- include "waktusolat.selectorLabels" . | nindent 4 }} From d7dd8a992f9915e34b263f1934cf916fe023c8a7 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sat, 3 Jun 2023 03:26:49 +0800 Subject: [PATCH 055/117] Add bot ID setting --- mika/waktusolat/README.md | 1 + mika/waktusolat/templates/configmap.yaml | 2 ++ mika/waktusolat/values.yaml | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/mika/waktusolat/README.md b/mika/waktusolat/README.md index 9fbdd507..5803923b 100644 --- a/mika/waktusolat/README.md +++ b/mika/waktusolat/README.md @@ -105,6 +105,7 @@ helm uninstall $release_name --namespace $namespace --wait | waktusolat.domain | string | `""` | The domain name of the WaktuSolat service. Default: `"localhost"`. | | waktusolat.location | string | `""` | The default location code used by WaktuSolat and its services. Default: `"wlp-0"`. | | waktusolat.mastodon.api | string | `""` | API endpoint or URL for the Mastodon instance of the WaktuSolat bot. | +| waktusolat.mastodon.bot | string | `""` | The username or user account for the Mastodon instance of the WaktuSolat bot. | | waktusolat.mastodon.token | string | `""` | A secure token required to authenticate the WaktuSolat service with the Mastodon instance's API. | | waktusolat.scheduler.apscheduler | bool | `true` | Specifies whether APScheduler should be used by WaktuSolat as the task scheduler. | | waktusolat.scheduler.celery | bool | `false` | Specifies whether Celery should be used by WaktuSolat as the task scheduler. | diff --git a/mika/waktusolat/templates/configmap.yaml b/mika/waktusolat/templates/configmap.yaml index e570f309..171c2f7e 100644 --- a/mika/waktusolat/templates/configmap.yaml +++ b/mika/waktusolat/templates/configmap.yaml @@ -1,6 +1,7 @@ {{- $debug := .Values.waktusolat.debug | default "false" | toString | quote }} {{- $location := .Values.waktusolat.location | default "wlp-0" | toString | quote }} {{- $api := .Values.waktusolat.mastodon.api | toString | quote }} +{{- $bot := .Values.waktusolat.mastodon.bot | toString | quote }} {{- $redis_service := printf "redis://%s-waktusolat-svc" .Release.Name | quote }} {{- $scheduler_timezone := .Values.waktusolat.scheduler.timezone | default "Asia/Kuala_Lumpur" | toString | quote }} {{- $domain := .Values.waktusolat.domain | default "localhost" | toString }} @@ -16,6 +17,7 @@ data: DEBUG: {{ $debug }} LOCATION_CODE: {{ $location }} API_BASE_URL: {{ $api }} + BOT_ID: {{ $bot }} {{- if $celery }} CELERY_BROKER: {{ $redis_service }} CELERY_BACKEND: {{ $redis_service }} diff --git a/mika/waktusolat/values.yaml b/mika/waktusolat/values.yaml index 3ce226a2..122c54b9 100644 --- a/mika/waktusolat/values.yaml +++ b/mika/waktusolat/values.yaml @@ -70,6 +70,10 @@ waktusolat: # Example: # api: "https://botsin.space/" api: "" + # The username or user account for the Mastodon instance of the WaktuSolat bot. + # Example: + # bot: "waktusolat" + bot: "" # A secure token required to authenticate the WaktuSolat service with the Mastodon instance's API. # Example: # token: "6&p4%t)-$8a14fmfh92py8j55+us51r6%e52dzy&=a3-6yd4#e" From ca1d4fc598cf6fc4cbf32bb38c493c2ebb487e8e Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sun, 4 Jun 2023 01:21:54 +0800 Subject: [PATCH 056/117] rizz: Add new testing chart --- mika/rizz/.helmignore | 23 + mika/rizz/Chart.yaml | 19 + mika/rizz/README.md | 114 +++ mika/rizz/templates/NOTES.txt | 5 + mika/rizz/templates/_helpers.tpl | 1010 +++++++++++++++++++++++++++ mika/rizz/templates/configmap.yaml | 121 ++++ mika/rizz/templates/deployment.yaml | 172 +++++ mika/rizz/templates/secret.yaml | 34 + mika/rizz/templates/service.yaml | 22 + mika/rizz/values.yaml | 177 +++++ 10 files changed, 1697 insertions(+) create mode 100644 mika/rizz/.helmignore create mode 100644 mika/rizz/Chart.yaml create mode 100644 mika/rizz/README.md create mode 100644 mika/rizz/templates/NOTES.txt create mode 100644 mika/rizz/templates/_helpers.tpl create mode 100644 mika/rizz/templates/configmap.yaml create mode 100644 mika/rizz/templates/deployment.yaml create mode 100644 mika/rizz/templates/secret.yaml create mode 100644 mika/rizz/templates/service.yaml create mode 100644 mika/rizz/values.yaml diff --git a/mika/rizz/.helmignore b/mika/rizz/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/mika/rizz/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/mika/rizz/Chart.yaml b/mika/rizz/Chart.yaml new file mode 100644 index 00000000..37c56779 --- /dev/null +++ b/mika/rizz/Chart.yaml @@ -0,0 +1,19 @@ +apiVersion: v2 +name: rizz +description: Rizz is a simple web application that tracks and posts content from RSS Feeds on Mastodon. +type: application +version: 0.0.1 +appVersion: "0.0.1-preview-r1" +keywords: + - "rss" + - "monitor" + - "mastodon" +home: "https://github.com/irfanhakim-as/rizz" +icon: "https://irfanhakim-as.github.io/charts/logos/mika.png" +sources: + - "https://github.com/irfanhakim-as/rizz" + - "https://github.com/irfanhakim-as/charts" +maintainers: + - name: "Irfan Hakim" + email: "irfanhakim.as@yahoo.com" + url: "https://github.com/irfanhakim-as" diff --git a/mika/rizz/README.md b/mika/rizz/README.md new file mode 100644 index 00000000..33e19a95 --- /dev/null +++ b/mika/rizz/README.md @@ -0,0 +1,114 @@ +# `rizz` + +## Prerequisites + +- Kubernetes 1.19+ +- Helm 3.2.0+ + +## Preflight checklist + +### Create image pull secret + +Replace `$github-username`, `$github-pass`, `$github-email` and `$namespace` accordingly. + +```sh +kubectl create secret docker-registry ghcr-token-secret --docker-server=https://ghcr.io --docker-username="$github-username" --docker-password="$github-pass" --docker-email="$github-email" -n $namespace +``` + +### Generate secret key for `rizz.secret` + +```sh +python -c 'import random; print("".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)]))' +``` + +## How to add repo + +Add the repo to your local helm client. + +```sh +helm repo add mika https://irfanhakim-as.github.io/charts +``` + +Update the repo to retrieve the latest versions of the packages. + +```sh +helm repo update +``` + +## How to install + +### Prepare chart values + +Copy `values.yaml` from the chart you would like to install. + +```sh +cp mika/rizz/values.yaml . +``` + +Edit `values.yaml` with the appropriate values. Refer to the [Configurations](#Configurations) section for available options. + +```sh +nano values.yaml +``` + +### Perform installation + +Install the desired chart. Replace `$release_name` and `$namespace` accordingly. + +```sh +helm install $release_name mika/rizz --namespace $namespace --create-namespace --values values.yaml --wait +``` + +Verify that your chart has been installed. Replace `$namespace` and `$release_name` accordingly. + +```sh +helm ls --namespace $namespace | grep "$release_name" +``` + +## How to uninstall + +Uninstall the desired chart. Replace `$release_name` and `$namespace` accordingly. + +```sh +helm uninstall $release_name --namespace $namespace --wait +``` + +## Configurations + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| db.host | string | `""` | The hostname or IP address of the Rizz database server. | +| db.name | string | `""` | The name of the database used by Rizz. | +| db.password | string | `""` | The password associated with the Rizz database's user. | +| db.port | string | `""` | The port number on which the Rizz database server is listening. Default: `"5432"`. | +| db.type | string | `""` | The type of the database used by Rizz. Default: `"postgresql"`. | +| db.user | string | `""` | The username or user account for accessing the Rizz database. | +| image.redis.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the Redis container image. Default: `"alpine"`. | +| image.redis.registry | string | `""` | The registry where the Redis container image is hosted. Default: `"docker.io"`. | +| image.redis.repository | string | `""` | The name of the repository that contains the Redis container image used. Default: `"redis"`. | +| image.redis.tag | string | `""` | The tag that specifies the version of the Redis container image used. Default: `"alpine"`. | +| image.rizz.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the Rizz container image. Default: `"IfNotPresent"`. | +| image.rizz.registry | string | `""` | The registry where the Rizz container image is hosted. Default: `"ghcr.io"`. | +| image.rizz.repository | string | `""` | The name of the repository that contains the Rizz container image used. Default: `"irfanhakim-as/rizz"`. | +| image.rizz.tag | string | `""` | The tag that specifies the version of the Rizz container image used. Default: `Chart appVersion`. | +| imagePullSecrets | list | `[]` | Credentials used to securely authenticate and authorise the pulling of container images from private registries. | +| replicaCount | string | `""` | The desired number of running replicas for Rizz. Default: `"1"`. | +| resources.scheduler.limits.cpu | string | `"20m"` | The maximum amount of CPU resources allowed for Scheduler. | +| resources.scheduler.limits.memory | string | `"200Mi"` | The maximum amount of memory allowed for Scheduler. | +| resources.scheduler.requests.cpu | string | `"10m"` | The minimum amount of CPU resources required by Scheduler. | +| resources.scheduler.requests.memory | string | `"100Mi"` | The minimum amount of memory required by Scheduler. | +| resources.rizz.limits.cpu | string | `"50m"` | The maximum amount of CPU resources allowed for Rizz. | +| resources.rizz.limits.memory | string | `"120Mi"` | The maximum amount of memory allowed for Rizz. | +| resources.rizz.requests.cpu | string | `"30m"` | The minimum amount of CPU resources required by Rizz. | +| resources.rizz.requests.memory | string | `"60Mi"` | The minimum amount of memory required by Rizz. | +| rizz.debug | bool | `false` | Specifies whether Rizz should run in debug mode. Default: `false`. | +| rizz.domain | string | `""` | The domain name of the Rizz service. Default: `"localhost"`. | +| rizz.mastodon.api | string | `""` | API endpoint or URL for the Mastodon instance of the Rizz bot. | +| rizz.mastodon.bot | string | `""` | The username or user account for the Mastodon instance of the Rizz bot. | +| rizz.mastodon.token | string | `""` | A secure token required to authenticate the Rizz service with the Mastodon instance's API. | +| rizz.rss.feed | string | `""` | The URL of the RSS feed to be tracked by Rizz. | +| rizz.rss.post_limit | string | `""` | The limit number of posts to be scheduled for posting by Rizz per run. Default: `"3"`. | +| rizz.scheduler.apscheduler | bool | `true` | Specifies whether APScheduler should be used by Rizz as the task scheduler. | +| rizz.scheduler.celery | bool | `false` | Specifies whether Celery should be used by Rizz as the task scheduler. | +| rizz.scheduler.timezone | string | `""` | The timezone for the task scheduler used by Rizz to schedule time-dependent operations. Default: `"Asia/Kuala_Lumpur"`. | +| rizz.secret | string | `""` | A 50-character secret key used for secure session management and cryptographic operations within the Rizz service. | diff --git a/mika/rizz/templates/NOTES.txt b/mika/rizz/templates/NOTES.txt new file mode 100644 index 00000000..55be8054 --- /dev/null +++ b/mika/rizz/templates/NOTES.txt @@ -0,0 +1,5 @@ +rizz is now installed and configured for {{ .Release.Name | toString }}. + +See the values.yaml file of this chart for more configuration options. + +Please refer to the official documentation for more information on how to use rizz. diff --git a/mika/rizz/templates/_helpers.tpl b/mika/rizz/templates/_helpers.tpl new file mode 100644 index 00000000..3891816f --- /dev/null +++ b/mika/rizz/templates/_helpers.tpl @@ -0,0 +1,1010 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "rizz.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "rizz.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "rizz.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "rizz.labels" -}} +helm.sh/chart: {{ include "rizz.chart" . }} +{{ include "rizz.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "rizz.selectorLabels" -}} +app.kubernetes.io/name: {{ include "rizz.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "rizz.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "rizz.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{/* +APScheduler /entrypoint.sh template +*/}} +{{- define "rizz.apscheduler-entrypoint-sh" -}} +#!/bin/bash + +export APP_ROOT="base" + +# ================= DO NOT EDIT BEYOND THIS LINE ================= + +python3 manage.py makemigrations + +python3 manage.py migrate + +tail -f /dev/null +{{- end }} + +{{/* +APScheduler /base/base/apps.py template +*/}} +{{- define "rizz.apscheduler-apps-py" -}} +from django.apps import AppConfig + +class BaseConfig(AppConfig): + name = 'base' + + def ready(self): + from . import signals + from . import tasks + tasks.start() +{{- end }} + +{{/* +APScheduler /base/base/tasks.py template +*/}} +{{- define "rizz.apscheduler-tasks-py" -}} +from django.conf import settings +from base.methods import post_scheduler +from lib import rss +from apscheduler.schedulers.blocking import BlockingScheduler + + +SCHEDULER_TIMEZONE = getattr(settings, "SCHEDULER_TIMEZONE", None) + + +def start(): + scheduler = BlockingScheduler(timezone=SCHEDULER_TIMEZONE) + + job_name = "clean_data" + scheduler.add_job(rss.clean_data, 'cron', hour='0', id=job_name, replace_existing=True) + + job_name = "update_data" + scheduler.add_job(rss.update_data, 'cron', hour='7,12,14,16,20,22', id=job_name, replace_existing=True) + + job_name = "post_scheduler" + scheduler.add_job(post_scheduler, 'cron', second='9,13,15,17,19,21,23', id=job_name, replace_existing=True) + + scheduler.start() +{{- end }} + +{{/* +Celery /etc/default/celeryd template +*/}} +{{- define "rizz.default-celeryd" -}} +# Names of nodes to start +# most people will only start one node: +#CELERYD_NODES="worker1" +# but you can also start multiple and configure settings +# for each in CELERYD_OPTS +#CELERYD_NODES="worker1 worker2 worker3" +# alternatively, you can specify the number of nodes to start: +#CELERYD_NODES=10 +CELERYD_NODES="worker1" + +# Absolute or relative path to the 'celery' command: +#CELERY_BIN="/usr/local/bin/celery" +#CELERY_BIN="/virtualenvs/def/bin/celery" +CELERY_BIN="/usr/local/bin/celery" + +# App instance to use +# comment out this line if you don't use an app +#CELERY_APP="proj" +# or fully qualified: +#CELERY_APP="proj.tasks:app" +CELERY_APP="base" + +# Where to chdir at start. +#CELERYD_CHDIR="/opt/Myproject/" +CELERYD_CHDIR="/base/" + +# Extra command-line arguments to the worker +#CELERYD_OPTS="--time-limit=300 --concurrency=8" +# Configure node-specific settings by appending node name to arguments: +#CELERYD_OPTS="--time-limit=300 -c 8 -c:worker2 4 -c:worker3 2 -Ofair:worker1" +CELERYD_OPTS="--time-limit=300 --concurrency=8 --without-gossip --without-mingle --without-heartbeat -Ofair --pool=solo" + +# Set logging level +#CELERYD_LOG_LEVEL="DEBUG" +CELERYD_LOG_LEVEL="WARNING" + +# %n will be replaced with the first part of the nodename. +#CELERYD_LOG_FILE="/var/log/celery/%n%I.log" +#CELERYD_PID_FILE="/var/run/celery/%n.pid" +CELERYD_LOG_FILE="/var/log/celery/%n%I.log" +CELERYD_PID_FILE="/var/run/celery/%n.pid" + +# Workers should run as an unprivileged user. +# You need to create this user manually (or you can choose +# a user/group combination that already exists (e.g., nobody). +#CELERYD_USER="celery" +#CELERYD_GROUP="celery" +CELERYD_USER="root" +CELERYD_GROUP="root" + +# If enabled pid and log directories will be created if missing, +# and owned by the userid/group configured. +#CELERY_CREATE_DIRS=1 +CELERY_CREATE_DIRS=1 +{{- end }} + +{{/* +Celery /etc/init.d/celerybeat template +*/}} +{{- define "rizz.initd-celerybeat" -}} +#!/bin/sh -e +# ========================================================= +# celerybeat - Starts the Celery periodic task scheduler. +# ========================================================= +# +# :Usage: /etc/init.d/celerybeat {start|stop|force-reload|restart|try-restart|status} +# :Configuration file: /etc/default/celerybeat or /etc/default/celeryd +# +# See https://docs.celeryq.dev/en/latest/userguide/daemonizing.html#generic-init-scripts + +### BEGIN INIT INFO +# Provides: celerybeat +# Required-Start: $network $local_fs $remote_fs +# Required-Stop: $network $local_fs $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: celery periodic task scheduler +### END INIT INFO + +# Cannot use set -e/bash -e since the kill -0 command will abort +# abnormally in the absence of a valid process ID. +#set -e +VERSION=10.1 +echo "celery init v${VERSION}." + +if [ $(id -u) -ne 0 ]; then + echo "Error: This program can only be used by the root user." + echo " Unprivileged users must use 'celery beat --detach'" + exit 1 +fi + +origin_is_runlevel_dir () { + set +e + dirname $0 | grep -q "/etc/rc.\.d" + echo $? +} + +# Can be a runlevel symlink (e.g., S02celeryd) +if [ $(origin_is_runlevel_dir) -eq 0 ]; then + SCRIPT_FILE=$(readlink "$0") +else + SCRIPT_FILE="$0" +fi +SCRIPT_NAME="$(basename "$SCRIPT_FILE")" + +# /etc/init.d/celerybeat: start and stop the celery periodic task scheduler daemon. + +# Make sure executable configuration script is owned by root +_config_sanity() { + local path="$1" + local owner=$(ls -ld "$path" | awk '{print $3}') + local iwgrp=$(ls -ld "$path" | cut -b 6) + local iwoth=$(ls -ld "$path" | cut -b 9) + + if [ "$(id -u $owner)" != "0" ]; then + echo "Error: Config script '$path' must be owned by root!" + echo + echo "Resolution:" + echo "Review the file carefully, and make sure it hasn't been " + echo "modified with mailicious intent. When sure the " + echo "script is safe to execute with superuser privileges " + echo "you can change ownership of the script:" + echo " $ sudo chown root '$path'" + exit 1 + fi + + if [ "$iwoth" != "-" ]; then # S_IWOTH + echo "Error: Config script '$path' cannot be writable by others!" + echo + echo "Resolution:" + echo "Review the file carefully, and make sure it hasn't been " + echo "modified with malicious intent. When sure the " + echo "script is safe to execute with superuser privileges " + echo "you can change the scripts permissions:" + echo " $ sudo chmod 640 '$path'" + exit 1 + fi + if [ "$iwgrp" != "-" ]; then # S_IWGRP + echo "Error: Config script '$path' cannot be writable by group!" + echo + echo "Resolution:" + echo "Review the file carefully, and make sure it hasn't been " + echo "modified with malicious intent. When sure the " + echo "script is safe to execute with superuser privileges " + echo "you can change the scripts permissions:" + echo " $ sudo chmod 640 '$path'" + exit 1 + fi +} + +scripts="" + +if test -f /etc/default/celeryd; then + scripts="/etc/default/celeryd" + _config_sanity /etc/default/celeryd + . /etc/default/celeryd +fi + +EXTRA_CONFIG="/etc/default/${SCRIPT_NAME}" +if test -f "$EXTRA_CONFIG"; then + scripts="$scripts, $EXTRA_CONFIG" + _config_sanity "$EXTRA_CONFIG" + . "$EXTRA_CONFIG" +fi + +echo "Using configuration: $scripts" + +CELERY_BIN=${CELERY_BIN:-"celery"} +DEFAULT_USER="celery" +DEFAULT_PID_FILE="/var/run/celery/beat.pid" +DEFAULT_LOG_FILE="/var/log/celery/beat.log" +DEFAULT_LOG_LEVEL="WARNING" +DEFAULT_CELERYBEAT="$CELERY_BIN" + +CELERYBEAT=${CELERYBEAT:-$DEFAULT_CELERYBEAT} +CELERYBEAT_LOG_LEVEL=${CELERYBEAT_LOG_LEVEL:-${CELERYBEAT_LOGLEVEL:-$DEFAULT_LOG_LEVEL}} + +CELERYBEAT_SU=${CELERYBEAT_SU:-"su"} +CELERYBEAT_SU_ARGS=${CELERYBEAT_SU_ARGS:-""} + +# Sets --app argument for CELERY_BIN +CELERY_APP_ARG="" +if [ ! -z "$CELERY_APP" ]; then + CELERY_APP_ARG="--app=$CELERY_APP" +fi + +CELERYBEAT_USER=${CELERYBEAT_USER:-${CELERYD_USER:-$DEFAULT_USER}} + +# Set CELERY_CREATE_DIRS to always create log/pid dirs. +CELERY_CREATE_DIRS=${CELERY_CREATE_DIRS:-0} +CELERY_CREATE_RUNDIR=$CELERY_CREATE_DIRS +CELERY_CREATE_LOGDIR=$CELERY_CREATE_DIRS +if [ -z "$CELERYBEAT_PID_FILE" ]; then + CELERYBEAT_PID_FILE="$DEFAULT_PID_FILE" + CELERY_CREATE_RUNDIR=1 +fi +if [ -z "$CELERYBEAT_LOG_FILE" ]; then + CELERYBEAT_LOG_FILE="$DEFAULT_LOG_FILE" + CELERY_CREATE_LOGDIR=1 +fi + +export CELERY_LOADER + +if [ -n "$2" ]; then + CELERYBEAT_OPTS="$CELERYBEAT_OPTS $2" +fi + +CELERYBEAT_LOG_DIR=`dirname $CELERYBEAT_LOG_FILE` +CELERYBEAT_PID_DIR=`dirname $CELERYBEAT_PID_FILE` + +# Extra start-stop-daemon options, like user/group. + +CELERYBEAT_CHDIR=${CELERYBEAT_CHDIR:-$CELERYD_CHDIR} +if [ -n "$CELERYBEAT_CHDIR" ]; then + DAEMON_OPTS="$DAEMON_OPTS --workdir=$CELERYBEAT_CHDIR" +fi + + +export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" + +check_dev_null() { + if [ ! -c /dev/null ]; then + echo "/dev/null is not a character device!" + exit 75 # EX_TEMPFAIL + fi +} + +maybe_die() { + if [ $? -ne 0 ]; then + echo "Exiting: $*" + exit 77 # EX_NOPERM + fi +} + +create_default_dir() { + if [ ! -d "$1" ]; then + echo "- Creating default directory: '$1'" + mkdir -p "$1" + maybe_die "Couldn't create directory $1" + echo "- Changing permissions of '$1' to 02755" + chmod 02755 "$1" + maybe_die "Couldn't change permissions for $1" + if [ -n "$CELERYBEAT_USER" ]; then + echo "- Changing owner of '$1' to '$CELERYBEAT_USER'" + chown "$CELERYBEAT_USER" "$1" + maybe_die "Couldn't change owner of $1" + fi + if [ -n "$CELERYBEAT_GROUP" ]; then + echo "- Changing group of '$1' to '$CELERYBEAT_GROUP'" + chgrp "$CELERYBEAT_GROUP" "$1" + maybe_die "Couldn't change group of $1" + fi + fi +} + +check_paths() { + if [ $CELERY_CREATE_LOGDIR -eq 1 ]; then + create_default_dir "$CELERYBEAT_LOG_DIR" + fi + if [ $CELERY_CREATE_RUNDIR -eq 1 ]; then + create_default_dir "$CELERYBEAT_PID_DIR" + fi +} + + +create_paths () { + create_default_dir "$CELERYBEAT_LOG_DIR" + create_default_dir "$CELERYBEAT_PID_DIR" +} + +is_running() { + pid=$1 + ps $pid > /dev/null 2>&1 +} + +wait_pid () { + pid=$1 + forever=1 + i=0 + while [ $forever -gt 0 ]; do + if ! is_running $pid; then + echo "OK" + forever=0 + else + kill -TERM "$pid" + i=$((i + 1)) + if [ $i -gt 60 ]; then + echo "ERROR" + echo "Timed out while stopping (30s)" + forever=0 + else + sleep 0.5 + fi + fi + done +} + + +stop_beat () { + echo -n "Stopping ${SCRIPT_NAME}... " + if [ -f "$CELERYBEAT_PID_FILE" ]; then + wait_pid $(cat "$CELERYBEAT_PID_FILE") + else + echo "NOT RUNNING" + fi +} + +_chuid () { + ${CELERYBEAT_SU} ${CELERYBEAT_SU_ARGS} \ + "$CELERYBEAT_USER" -c "$CELERYBEAT $*" +} + +start_beat () { + echo "Starting ${SCRIPT_NAME}..." + _chuid $CELERY_APP_ARG $DAEMON_OPTS beat --detach \ + --pidfile="$CELERYBEAT_PID_FILE" \ + --logfile="$CELERYBEAT_LOG_FILE" \ + --loglevel="$CELERYBEAT_LOG_LEVEL" \ + $CELERYBEAT_OPTS +} + + +check_status () { + local failed= + local pid_file=$CELERYBEAT_PID_FILE + if [ ! -e $pid_file ]; then + echo "${SCRIPT_NAME} is down: no pid file found" + failed=true + elif [ ! -r $pid_file ]; then + echo "${SCRIPT_NAME} is in unknown state, user cannot read pid file." + failed=true + else + local pid=`cat "$pid_file"` + local cleaned_pid=`echo "$pid" | sed -e 's/[^0-9]//g'` + if [ -z "$pid" ] || [ "$cleaned_pid" != "$pid" ]; then + echo "${SCRIPT_NAME}: bad pid file ($pid_file)" + failed=true + else + local failed= + kill -0 $pid 2> /dev/null || failed=true + if [ "$failed" ]; then + echo "${SCRIPT_NAME} (pid $pid) is down, but pid file exists!" + failed=true + else + echo "${SCRIPT_NAME} (pid $pid) is up..." + fi + fi + fi + + [ "$failed" ] && exit 1 || exit 0 +} + + +case "$1" in + start) + check_dev_null + check_paths + start_beat + ;; + stop) + check_paths + stop_beat + ;; + reload|force-reload) + echo "Use start+stop" + ;; + status) + check_status + ;; + restart) + echo "Restarting celery periodic task scheduler" + check_paths + stop_beat && check_dev_null && start_beat + ;; + create-paths) + check_dev_null + create_paths + ;; + check-paths) + check_dev_null + check_paths + ;; + *) + echo "Usage: /etc/init.d/${SCRIPT_NAME} {start|stop|restart|create-paths|status}" + exit 64 # EX_USAGE + ;; +esac + +exit 0 +{{- end }} + +{{/* +Celery /etc/init.d/celeryd template +*/}} +{{- define "rizz.initd-celeryd" -}} +#!/bin/sh -e +# ============================================ +# celeryd - Starts the Celery worker daemon. +# ============================================ +# +# :Usage: /etc/init.d/celeryd {start|stop|force-reload|restart|try-restart|status} +# :Configuration file: /etc/default/celeryd (or /usr/local/etc/celeryd on BSD) +# +# See https://docs.celeryq.dev/en/latest/userguide/daemonizing.html#generic-init-scripts + + +### BEGIN INIT INFO +# Provides: celeryd +# Required-Start: $network $local_fs $remote_fs +# Required-Stop: $network $local_fs $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: celery task worker daemon +### END INIT INFO +# +# +# To implement separate init-scripts, copy this script and give it a different +# name. That is, if your new application named "little-worker" needs an init, +# you should use: +# +# cp /etc/init.d/celeryd /etc/init.d/little-worker +# +# You can then configure this by manipulating /etc/default/little-worker. +# +VERSION=10.1 +echo "celery init v${VERSION}." +if [ $(id -u) -ne 0 ]; then + echo "Error: This program can only be used by the root user." + echo " Unprivileged users must use the 'celery multi' utility, " + echo " or 'celery worker --detach'." + exit 1 +fi + +origin_is_runlevel_dir () { + set +e + dirname $0 | grep -q "/etc/rc.\.d" + echo $? +} + +# Can be a runlevel symlink (e.g., S02celeryd) +if [ $(origin_is_runlevel_dir) -eq 0 ]; then + SCRIPT_FILE=$(readlink "$0") +else + SCRIPT_FILE="$0" +fi +SCRIPT_NAME="$(basename "$SCRIPT_FILE")" + +DEFAULT_USER="celery" +DEFAULT_PID_FILE="/var/run/celery/%n.pid" +DEFAULT_LOG_FILE="/var/log/celery/%n%I.log" +DEFAULT_LOG_LEVEL="WARNING" +DEFAULT_NODES="celery" +DEFAULT_CELERYD="-m celery worker --detach" + +if [ -d "/etc/default" ]; then + CELERY_CONFIG_DIR="/etc/default" +else + CELERY_CONFIG_DIR="/usr/local/etc" +fi + +CELERY_DEFAULTS=${CELERY_DEFAULTS:-"$CELERY_CONFIG_DIR/${SCRIPT_NAME}"} + +# Make sure executable configuration script is owned by root +_config_sanity() { + local path="$1" + local owner=$(ls -ld "$path" | awk '{print $3}') + local iwgrp=$(ls -ld "$path" | cut -b 6) + local iwoth=$(ls -ld "$path" | cut -b 9) + + if [ "$(id -u $owner)" != "0" ]; then + echo "Error: Config script '$path' must be owned by root!" + echo + echo "Resolution:" + echo "Review the file carefully, and make sure it hasn't been " + echo "modified with mailicious intent. When sure the " + echo "script is safe to execute with superuser privileges " + echo "you can change ownership of the script:" + echo " $ sudo chown root '$path'" + exit 1 + fi + + if [ "$iwoth" != "-" ]; then # S_IWOTH + echo "Error: Config script '$path' cannot be writable by others!" + echo + echo "Resolution:" + echo "Review the file carefully, and make sure it hasn't been " + echo "modified with malicious intent. When sure the " + echo "script is safe to execute with superuser privileges " + echo "you can change the scripts permissions:" + echo " $ sudo chmod 640 '$path'" + exit 1 + fi + if [ "$iwgrp" != "-" ]; then # S_IWGRP + echo "Error: Config script '$path' cannot be writable by group!" + echo + echo "Resolution:" + echo "Review the file carefully, and make sure it hasn't been " + echo "modified with malicious intent. When sure the " + echo "script is safe to execute with superuser privileges " + echo "you can change the scripts permissions:" + echo " $ sudo chmod 640 '$path'" + exit 1 + fi +} + +if [ -f "$CELERY_DEFAULTS" ]; then + _config_sanity "$CELERY_DEFAULTS" + echo "Using config script: $CELERY_DEFAULTS" + . "$CELERY_DEFAULTS" +fi + +# Sets --app argument for CELERY_BIN +CELERY_APP_ARG="" +if [ ! -z "$CELERY_APP" ]; then + CELERY_APP_ARG="--app=$CELERY_APP" +fi + +# Options to su +# can be used to enable login shell (CELERYD_SU_ARGS="-l"), +# or even to use start-stop-daemon instead of su. +CELERYD_SU=${CELERY_SU:-"su"} +CELERYD_SU_ARGS=${CELERYD_SU_ARGS:-""} + +CELERYD_USER=${CELERYD_USER:-$DEFAULT_USER} + +# Set CELERY_CREATE_DIRS to always create log/pid dirs. +CELERY_CREATE_DIRS=${CELERY_CREATE_DIRS:-0} +CELERY_CREATE_RUNDIR=$CELERY_CREATE_DIRS +CELERY_CREATE_LOGDIR=$CELERY_CREATE_DIRS +if [ -z "$CELERYD_PID_FILE" ]; then + CELERYD_PID_FILE="$DEFAULT_PID_FILE" + CELERY_CREATE_RUNDIR=1 +fi +if [ -z "$CELERYD_LOG_FILE" ]; then + CELERYD_LOG_FILE="$DEFAULT_LOG_FILE" + CELERY_CREATE_LOGDIR=1 +fi + +CELERYD_LOG_LEVEL=${CELERYD_LOG_LEVEL:-${CELERYD_LOGLEVEL:-$DEFAULT_LOG_LEVEL}} +CELERY_BIN=${CELERY_BIN:-"celery"} +CELERYD_MULTI=${CELERYD_MULTI:-"$CELERY_BIN multi"} +CELERYD_NODES=${CELERYD_NODES:-$DEFAULT_NODES} + +export CELERY_LOADER + +if [ -n "$2" ]; then + CELERYD_OPTS="$CELERYD_OPTS $2" +fi + +CELERYD_LOG_DIR=`dirname $CELERYD_LOG_FILE` +CELERYD_PID_DIR=`dirname $CELERYD_PID_FILE` + +# Extra start-stop-daemon options, like user/group. +if [ -n "$CELERYD_CHDIR" ]; then + DAEMON_OPTS="$DAEMON_OPTS --workdir=$CELERYD_CHDIR" +fi + + +check_dev_null() { + if [ ! -c /dev/null ]; then + echo "/dev/null is not a character device!" + exit 75 # EX_TEMPFAIL + fi +} + + +maybe_die() { + if [ $? -ne 0 ]; then + echo "Exiting: $* (errno $?)" + exit 77 # EX_NOPERM + fi +} + +create_default_dir() { + if [ ! -d "$1" ]; then + echo "- Creating default directory: '$1'" + mkdir -p "$1" + maybe_die "Couldn't create directory $1" + echo "- Changing permissions of '$1' to 02755" + chmod 02755 "$1" + maybe_die "Couldn't change permissions for $1" + if [ -n "$CELERYD_USER" ]; then + echo "- Changing owner of '$1' to '$CELERYD_USER'" + chown "$CELERYD_USER" "$1" + maybe_die "Couldn't change owner of $1" + fi + if [ -n "$CELERYD_GROUP" ]; then + echo "- Changing group of '$1' to '$CELERYD_GROUP'" + chgrp "$CELERYD_GROUP" "$1" + maybe_die "Couldn't change group of $1" + fi + fi +} + + +check_paths() { + if [ $CELERY_CREATE_LOGDIR -eq 1 ]; then + create_default_dir "$CELERYD_LOG_DIR" + fi + if [ $CELERY_CREATE_RUNDIR -eq 1 ]; then + create_default_dir "$CELERYD_PID_DIR" + fi +} + +create_paths() { + create_default_dir "$CELERYD_LOG_DIR" + create_default_dir "$CELERYD_PID_DIR" +} + +export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" + + +_get_pidfiles () { + # note: multi < 3.1.14 output to stderr, not stdout, hence the redirect. + ${CELERYD_MULTI} expand "${CELERYD_PID_FILE}" ${CELERYD_NODES} 2>&1 +} + + +_get_pids() { + found_pids=0 + my_exitcode=0 + + for pidfile in $(_get_pidfiles); do + local pid=`cat "$pidfile"` + local cleaned_pid=`echo "$pid" | sed -e 's/[^0-9]//g'` + if [ -z "$pid" ] || [ "$cleaned_pid" != "$pid" ]; then + echo "bad pid file ($pidfile)" + one_failed=true + my_exitcode=1 + else + found_pids=1 + echo "$pid" + fi + + if [ $found_pids -eq 0 ]; then + echo "${SCRIPT_NAME}: All nodes down" + exit $my_exitcode + fi + done +} + + +_chuid () { + ${CELERYD_SU} ${CELERYD_SU_ARGS} "$CELERYD_USER" -c "$CELERYD_MULTI $*" +} + + +start_workers () { + if [ ! -z "$CELERYD_ULIMIT" ]; then + ulimit $CELERYD_ULIMIT + fi + _chuid $* start $CELERYD_NODES $DAEMON_OPTS \ + --pidfile="$CELERYD_PID_FILE" \ + --logfile="$CELERYD_LOG_FILE" \ + --loglevel="$CELERYD_LOG_LEVEL" \ + $CELERY_APP_ARG \ + $CELERYD_OPTS +} + + +dryrun () { + (C_FAKEFORK=1 start_workers --verbose) +} + + +stop_workers () { + _chuid stopwait $CELERYD_NODES $DAEMON_OPTS --pidfile="$CELERYD_PID_FILE" +} + + +restart_workers () { + _chuid restart $CELERYD_NODES $DAEMON_OPTS \ + --pidfile="$CELERYD_PID_FILE" \ + --logfile="$CELERYD_LOG_FILE" \ + --loglevel="$CELERYD_LOG_LEVEL" \ + $CELERY_APP_ARG \ + $CELERYD_OPTS +} + + +kill_workers() { + _chuid kill $CELERYD_NODES $DAEMON_OPTS --pidfile="$CELERYD_PID_FILE" +} + + +restart_workers_graceful () { + echo "WARNING: Use with caution in production" + echo "The workers will attempt to restart, but they may not be able to." + local worker_pids= + worker_pids=`_get_pids` + [ "$one_failed" ] && exit 1 + + for worker_pid in $worker_pids; do + local failed= + kill -HUP $worker_pid 2> /dev/null || failed=true + if [ "$failed" ]; then + echo "${SCRIPT_NAME} worker (pid $worker_pid) could not be restarted" + one_failed=true + else + echo "${SCRIPT_NAME} worker (pid $worker_pid) received SIGHUP" + fi + done + + [ "$one_failed" ] && exit 1 || exit 0 +} + + +check_status () { + my_exitcode=0 + found_pids=0 + + local one_failed= + for pidfile in $(_get_pidfiles); do + if [ ! -r $pidfile ]; then + echo "${SCRIPT_NAME} down: no pidfiles found" + one_failed=true + break + fi + + local node=`basename "$pidfile" .pid` + local pid=`cat "$pidfile"` + local cleaned_pid=`echo "$pid" | sed -e 's/[^0-9]//g'` + if [ -z "$pid" ] || [ "$cleaned_pid" != "$pid" ]; then + echo "bad pid file ($pidfile)" + one_failed=true + else + local failed= + kill -0 $pid 2> /dev/null || failed=true + if [ "$failed" ]; then + echo "${SCRIPT_NAME} (node $node) (pid $pid) is down, but pidfile exists!" + one_failed=true + else + echo "${SCRIPT_NAME} (node $node) (pid $pid) is up..." + fi + fi + done + + [ "$one_failed" ] && exit 1 || exit 0 +} + + +case "$1" in + start) + check_dev_null + check_paths + start_workers + ;; + + stop) + check_dev_null + check_paths + stop_workers + ;; + + reload|force-reload) + echo "Use restart" + ;; + + status) + check_status + ;; + + restart) + check_dev_null + check_paths + restart_workers + ;; + + graceful) + check_dev_null + restart_workers_graceful + ;; + + kill) + check_dev_null + kill_workers + ;; + + dryrun) + check_dev_null + dryrun + ;; + + try-restart) + check_dev_null + check_paths + restart_workers + ;; + + create-paths) + check_dev_null + create_paths + ;; + + check-paths) + check_dev_null + check_paths + ;; + + *) + echo "Usage: /etc/init.d/${SCRIPT_NAME} {start|stop|restart|graceful|kill|dryrun|create-paths}" + exit 64 # EX_USAGE + ;; +esac + +exit 0 +{{- end }} + +{{/* +Celery /base/base/celery.py template +*/}} +{{- define "rizz.celery-py" -}} +from __future__ import absolute_import, unicode_literals +import os +from celery import Celery +from celery.schedules import crontab +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "base.settings") +app = Celery("base") +app.config_from_object("django.conf:settings", namespace="CELERY") +app.autodiscover_tasks() + + +app.conf.beat_schedule = { + # clean data + "clean_data": { + "task": "base.tasks.clean_data_task", + "schedule": crontab(hour=0, minute=0), + }, + # update data + "update_data": { + "task": "base.tasks.update_data_task", + "schedule": crontab(hour='7,12,14,16,20,22', minute=0), + }, + # check for any posts that need to be posted + "post_scheduler": { + "task": "base.tasks.post_scheduler_task", + "schedule": crontab(hour='9,13,15,17,19,21,23', minute=0), + }, +} + + +@app.task(bind=True) +def debug_task(self): + print("Request: {0!r}".format(self.request)) +{{- end }} + +{{/* +Celery /base/base/__init__.py template +*/}} +{{- define "rizz.celery-init-py" -}} +from .celery import app as celery_app + +__all__ = ("celery_app",) +{{- end }} + +{{/* +Celery /base/base/tasks.py template +*/}} +{{- define "rizz.celery-tasks-py" -}} +from __future__ import absolute_import, unicode_literals +import logging +from celery import shared_task +from base.methods import post_scheduler +from lib import rss + + +# clean data +@shared_task +def clean_data_task(): + rss.clean_data() + + +# update data +@shared_task +def update_data_task(): + rss.update_data() + + +# check for any posts that need to be posted +@shared_task +def post_scheduler_task(): + post_scheduler() +{{- end }} diff --git a/mika/rizz/templates/configmap.yaml b/mika/rizz/templates/configmap.yaml new file mode 100644 index 00000000..5de2696d --- /dev/null +++ b/mika/rizz/templates/configmap.yaml @@ -0,0 +1,121 @@ +{{- $debug := .Values.rizz.debug | default "false" | toString | quote }} +{{- $api := .Values.rizz.mastodon.api | toString | quote }} +{{- $bot := .Values.rizz.mastodon.bot | toString | quote }} +{{- $redis_service := printf "redis://%s-rizz-svc" .Release.Name | quote }} +{{- $scheduler_timezone := .Values.rizz.scheduler.timezone | default "Asia/Kuala_Lumpur" | toString | quote }} +{{- $domain := .Values.rizz.domain | default "localhost" | toString }} +{{- $feed := .Values.rizz.rss.feed | toString | quote }} +{{- $post_limit := .Values.rizz.rss.post_limit | default "3" | toString | quote }} +{{- $apscheduler := .Values.rizz.scheduler.apscheduler }} +{{- $celery := .Values.rizz.scheduler.celery }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-rizz-cm + labels: + {{- include "rizz.labels" . | nindent 4 }} +data: + DEBUG: {{ $debug }} + API_BASE_URL: {{ $api }} + BOT_ID: {{ $bot }} + RSS_FEED_URL: {{ $feed }} + RSS_POST_LIMIT: {{ $post_limit }} + {{- if $celery }} + CELERY_BROKER: {{ $redis_service }} + CELERY_BACKEND: {{ $redis_service }} + {{- end }} + {{- if or $apscheduler $celery }} + SCHEDULER_TIMEZONE: {{ $scheduler_timezone }} + {{- end }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-rizz-site-config + labels: + {{- include "rizz.labels" . | nindent 4 }} +data: + site-config.conf: |- + + {{ "ServerName $domain:443" | replace "$domain" $domain }} + UseCanonicalName On + ServerAdmin support@mikahomelab.com + DocumentRoot /base + WSGIScriptAlias / /base/base/wsgi.py + {{ "WSGIDaemonProcess $domain python-path=/base" | replace "$domain" $domain }} + {{ "WSGIProcessGroup $domain" | replace "$domain" $domain }} + + + + Require all granted + + + + Alias /static /static + + Require all granted + + + ErrorLog /var/log/apache2/apache.error.log + CustomLog /var/log/apache2/apache.access.log combined + +{{- if $apscheduler }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-rizz-apscheduler-config + labels: + {{- include "rizz.labels" . | nindent 4 }} +data: + entrypoint.sh: |- + {{- include "rizz.apscheduler-entrypoint-sh" . | nindent 4 }} +{{- else if $celery }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-rizz-default-celery-config + labels: + {{- include "rizz.labels" . | nindent 4 }} +data: + celeryd: |- + {{- include "rizz.default-celeryd" . | nindent 4 }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-rizz-initd-celery-config + labels: + {{- include "rizz.labels" . | nindent 4 }} +data: + celerybeat: |- + {{- include "rizz.initd-celerybeat" . | nindent 4 }} + celeryd: |- + {{- include "rizz.initd-celeryd" . | nindent 4 }} +{{- end }} +{{- if or $apscheduler $celery }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-rizz-scheduler-config + labels: + {{- include "rizz.labels" . | nindent 4 }} +data: + {{- if $apscheduler }} + apps.py: |- + {{- include "rizz.apscheduler-apps-py" . | nindent 4 }} + {{- else if $celery }} + celery.py: |- + {{- include "rizz.celery-py" . | nindent 4 }} + init.py: |- + {{- include "rizz.celery-init-py" . | nindent 4 }} + {{- end }} + tasks.py: |- + {{- if $apscheduler }} + {{- include "rizz.apscheduler-tasks-py" . | nindent 4 }} + {{- else if $celery }} + {{- include "rizz.celery-tasks-py" . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/mika/rizz/templates/deployment.yaml b/mika/rizz/templates/deployment.yaml new file mode 100644 index 00000000..1da4325a --- /dev/null +++ b/mika/rizz/templates/deployment.yaml @@ -0,0 +1,172 @@ +{{- $replica_count := .Values.replicaCount | default "1" | toString }} +{{- $rizz_registry := .Values.image.rizz.registry | default "ghcr.io" | toString }} +{{- $rizz_repository := .Values.image.rizz.repository | default "irfanhakim-as/rizz" | toString }} +{{- $rizz_tag := .Values.image.rizz.tag | default .Chart.AppVersion | toString }} +{{- $rizz_pullPolicy := .Values.image.rizz.pullPolicy | default "IfNotPresent" | toString | quote }} +{{- $redis_registry := .Values.image.redis.registry | default "docker.io" | toString }} +{{- $redis_repository := .Values.image.redis.repository | default "redis" | toString }} +{{- $redis_tag := .Values.image.redis.tag | default "alpine" | toString }} +{{- $redis_pullPolicy := .Values.image.redis.pullPolicy | default "IfNotPresent" | toString | quote }} +{{- $apscheduler := .Values.rizz.scheduler.apscheduler }} +{{- $celery := .Values.rizz.scheduler.celery }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-rizz + labels: + {{- include "rizz.labels" . | nindent 4 }} +spec: + replicas: {{ int $replica_count }} + selector: + matchLabels: + {{- include "rizz.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "rizz.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: rizz + image: {{ printf "%s/%s:%s" $rizz_registry $rizz_repository $rizz_tag | quote }} + imagePullPolicy: {{ $rizz_pullPolicy }} + ports: + - name: rizz + containerPort: 80 + protocol: TCP + resources: + {{- toYaml .Values.resources.rizz | nindent 12 }} + envFrom: + - configMapRef: + name: {{ .Release.Name }}-rizz-cm + - secretRef: + name: {{ .Release.Name }}-rizz-secret + volumeMounts: + - name: {{ .Release.Name }}-rizz-site-config + mountPath: /etc/apache2/sites-available/000-default.conf + subPath: site-config.conf + readOnly: true + {{- if $celery }} + - name: {{ .Release.Name }}-rizz-default-celery-config + mountPath: /etc/default/celeryd + subPath: celeryd + - name: {{ .Release.Name }}-rizz-initd-celery-config + mountPath: /etc/init.d/celerybeat + subPath: celerybeat + - name: {{ .Release.Name }}-rizz-initd-celery-config + mountPath: /etc/init.d/celeryd + subPath: celeryd + - name: {{ .Release.Name }}-rizz-scheduler-config + mountPath: /base/base/celery.py + subPath: celery.py + - name: {{ .Release.Name }}-rizz-scheduler-config + mountPath: /base/base/tasks.py + subPath: tasks.py + - name: {{ .Release.Name }}-rizz-scheduler-config + mountPath: /base/base/__init__.py + subPath: init.py + {{- end }} + - name: {{ .Release.Name }}-rizz-token-secret + mountPath: /base/base/mastodon.secret + subPath: mastodon.secret + readOnly: true + {{- if $apscheduler }} + - name: apscheduler + image: {{ printf "%s/%s:%s" $rizz_registry $rizz_repository $rizz_tag | quote }} + imagePullPolicy: {{ $rizz_pullPolicy }} + ports: + - name: rizz + containerPort: 80 + protocol: TCP + resources: + {{- toYaml .Values.resources.scheduler | nindent 12 }} + envFrom: + - configMapRef: + name: {{ .Release.Name }}-rizz-cm + - secretRef: + name: {{ .Release.Name }}-rizz-secret + volumeMounts: + - name: {{ .Release.Name }}-rizz-apscheduler-config + mountPath: /entrypoint.sh + subPath: entrypoint.sh + - name: {{ .Release.Name }}-rizz-scheduler-config + mountPath: /base/base/apps.py + subPath: apps.py + - name: {{ .Release.Name }}-rizz-scheduler-config + mountPath: /base/base/tasks.py + subPath: tasks.py + - name: {{ .Release.Name }}-rizz-token-secret + mountPath: /base/base/mastodon.secret + subPath: mastodon.secret + readOnly: true + {{- else if $celery }} + - name: redis + image: {{ printf "%s/%s:%s" $redis_registry $redis_repository $redis_tag | quote }} + imagePullPolicy: {{ $redis_pullPolicy }} + ports: + - name: redis + containerPort: 6379 + protocol: TCP + resources: + {{- toYaml .Values.resources.scheduler | nindent 12 }} + {{- end }} + volumes: + - name: {{ .Release.Name }}-rizz-site-config + configMap: + name: {{ .Release.Name }}-rizz-site-config + {{- if $apscheduler }} + - name: {{ .Release.Name }}-rizz-apscheduler-config + configMap: + name: {{ .Release.Name }}-rizz-apscheduler-config + defaultMode: 0755 + items: + - key: entrypoint.sh + path: entrypoint.sh + {{- else if $celery }} + - name: {{ .Release.Name }}-rizz-default-celery-config + configMap: + name: {{ .Release.Name }}-rizz-default-celery-config + defaultMode: 0640 + items: + - key: celeryd + path: celeryd + - name: {{ .Release.Name }}-rizz-initd-celery-config + configMap: + name: {{ .Release.Name }}-rizz-initd-celery-config + defaultMode: 0755 + items: + - key: celerybeat + path: celerybeat + - key: celeryd + path: celeryd + {{- end }} + {{- if or $apscheduler $celery }} + - name: {{ .Release.Name }}-rizz-scheduler-config + configMap: + name: {{ .Release.Name }}-rizz-scheduler-config + defaultMode: 0775 + items: + {{- if $celery }} + - key: celery.py + path: celery.py + - key: init.py + path: init.py + {{- else if $apscheduler }} + - key: apps.py + path: apps.py + {{- end }} + - key: tasks.py + path: tasks.py + {{- end }} + - name: {{ .Release.Name }}-rizz-token-secret + secret: + secretName: {{ .Release.Name }}-rizz-token-secret + securityContext: + fsGroup: 33 diff --git a/mika/rizz/templates/secret.yaml b/mika/rizz/templates/secret.yaml new file mode 100644 index 00000000..d45334ac --- /dev/null +++ b/mika/rizz/templates/secret.yaml @@ -0,0 +1,34 @@ +{{- $secret := .Values.rizz.secret | toString | b64enc }} +{{- $db_type := .Values.db.type | default "postgresql" | toString | b64enc }} +{{- $db_name := .Values.db.name | toString | b64enc }} +{{- $db_user := .Values.db.user | toString | b64enc }} +{{- $db_password := .Values.db.password | toString | b64enc }} +{{- $db_host := .Values.db.host | toString | b64enc }} +{{- $db_port := .Values.db.port | default "5432" | toString | b64enc }} +{{- $token := .Values.rizz.mastodon.token | toString | b64enc }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Release.Name }}-rizz-secret + labels: + {{- include "rizz.labels" . | nindent 4 }} +type: Opaque +data: + SECRET_KEY: {{ $secret }} + DB_TYPE: {{ $db_type }} + DB_NAME: {{ $db_name }} + DB_USER: {{ $db_user }} + DB_PASS: {{ $db_password }} + DB_HOST: {{ $db_host }} + DB_PORT: {{ $db_port }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Release.Name }}-rizz-token-secret + labels: + {{- include "rizz.labels" . | nindent 4 }} +type: Opaque +data: + mastodon.secret: |- + {{ $token | nindent 4 }} diff --git a/mika/rizz/templates/service.yaml b/mika/rizz/templates/service.yaml new file mode 100644 index 00000000..d288ee0c --- /dev/null +++ b/mika/rizz/templates/service.yaml @@ -0,0 +1,22 @@ +{{- $celery := .Values.rizz.scheduler.celery }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-rizz-svc + labels: + {{- include "rizz.labels" . | nindent 4 }} +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: rizz + protocol: TCP + name: {{ .Release.Name }}-rizz + {{- if $celery }} + - port: 6379 + targetPort: redis + protocol: TCP + name: {{ .Release.Name }}-redis + {{- end }} + selector: + {{- include "rizz.selectorLabels" . | nindent 4 }} diff --git a/mika/rizz/values.yaml b/mika/rizz/values.yaml new file mode 100644 index 00000000..fd36999c --- /dev/null +++ b/mika/rizz/values.yaml @@ -0,0 +1,177 @@ +# Default values for rizz. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# The desired number of running replicas for Rizz. +# Default: "1" +replicaCount: "" + +# Container images used for Rizz. +image: + # Rizz container image configurations. + rizz: + # The registry where the Rizz container image is hosted. + # Default: "ghcr.io" + registry: "" + # The name of the repository that contains the Rizz container image used. + # Default: "irfanhakim-as/rizz" + repository: "" + # The tag that specifies the version of the Rizz container image used. + # Default: Chart appVersion + tag: "" + # The policy that determines when Kubernetes should pull the Rizz container image. + # Default: "IfNotPresent" + pullPolicy: "" + # Redis container image configurations. + redis: + # The registry where the Redis container image is hosted. + # Default: "docker.io" + registry: "" + # The name of the repository that contains the Redis container image used. + # Default: "redis" + repository: "" + # The tag that specifies the version of the Redis container image used. + # Default: "alpine" + tag: "" + # The policy that determines when Kubernetes should pull the Redis container image. + # Default: "IfNotPresent" + pullPolicy: "" + +# Credentials used to securely authenticate and authorise the pulling of container images from private registries. +# Example: +# imagePullSecrets: +# - name: "ghcr-token-secret" +imagePullSecrets: [] + +# Rizz configurations. +rizz: + # Specifies whether Rizz should run in debug mode. + # Default: false + # Example: + # debug: true + debug: false + # The domain name of the Rizz service. + # Default: "localhost" + # Example: + # domain: "localhost" + domain: "" + # A 50-character secret key used for secure session management and cryptographic operations within the Rizz service. + # Example: + # secret: "6&p4%t)-$8a14fmfh92py8j55+us51r6%e52dzy&=a3-6yd4#e" + secret: "" + # Rizz Mastodon configurations. + mastodon: + # API endpoint or URL for the Mastodon instance of the Rizz bot. + # Example: + # api: "https://botsin.space/" + api: "" + # The username or user account for the Mastodon instance of the Rizz bot. + # Example: + # bot: "rizz" + bot: "" + # A secure token required to authenticate the Rizz service with the Mastodon instance's API. + # Example: + # token: "6&p4%t)-$8a14fmfh92py8j55+us51r6%e52dzy&=a3-6yd4#e" + token: "" + # Rizz RSS configurations. + rss: + # The URL of the RSS feed to be tracked by Rizz. + # Example: + # feed: "https://www.reddit.com/r/programming/.rss" + feed: "" + # The limit number of posts to be scheduled for posting by Rizz per run. + # Default: "3" + # Example: + # post_limit: "5" + post_limit: "" + # Rizz scheduler configurations. + scheduler: + # Specifies whether APScheduler should be used by Rizz as the task scheduler. + # Example: + # apscheduler: false + apscheduler: true + # Specifies whether Celery should be used by Rizz as the task scheduler. + # Example: + # celery: true + celery: false + # The timezone for the task scheduler used by Rizz to schedule time-dependent operations. + # Default: "Asia/Kuala_Lumpur" + # Example: + # timezone: "Asia/Kuala_Lumpur" + timezone: "" + +# Database configurations. +db: + # The type of the database used by Rizz. + # Default: "postgresql" + # Example: + # type: "postgresql" + type: "" + # The name of the database used by Rizz. + # Example: + # name: "rizz" + name: "" + # The username or user account for accessing the Rizz database. + # Example: + # user: "root" + user: "" + # The password associated with the Rizz database's user. + # Example: + # password: "password" + password: "" + # The hostname or IP address of the Rizz database server. + # Example: + # host: "rizz.default.svc.cluster.local" + host: "" + # The port number on which the Rizz database server is listening. + # Default: "5432" + # Example: + # port: "5432" + port: "" + +# Resource requirements and limits for Rizz containers. +resources: + # Rizz container resources. + rizz: + # The minimum amount of resources required by Rizz to run. + requests: + # The minimum amount of CPU resources required by Rizz. + # Example: + # cpu: "20m" + cpu: "30m" + # The minimum amount of memory required by Rizz. + # Example: + # memory: "250Mi" + memory: "60Mi" + # The maximum amount of resources allowed for Rizz. + limits: + # The maximum amount of CPU resources allowed for Rizz. + # Example: + # cpu: "50m" + cpu: "50m" + # The maximum amount of memory allowed for Rizz. + # Example: + # memory: "450Mi" + memory: "120Mi" + # Scheduler container resources. + scheduler: + # The minimum amount of resources required by Scheduler to run. + requests: + # The minimum amount of CPU resources required by Scheduler. + # Example: + # cpu: "5m" + cpu: "10m" + # The minimum amount of memory required by Scheduler. + # Example: + # memory: "30Mi" + memory: "100Mi" + # The maximum amount of resources allowed for Scheduler. + limits: + # The maximum amount of CPU resources allowed for Scheduler. + # Example: + # cpu: "15m" + cpu: "20m" + # The maximum amount of memory allowed for Scheduler. + # Example: + # memory: "50Mi" + memory: "200Mi" From 2f2ab258266fd63f2cd79e77870ef7e5ad78fbb7 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Mon, 5 Jun 2023 19:32:19 +0700 Subject: [PATCH 057/117] Fix wrong cron --- mika/rizz/templates/_helpers.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mika/rizz/templates/_helpers.tpl b/mika/rizz/templates/_helpers.tpl index 3891816f..5f726cce 100644 --- a/mika/rizz/templates/_helpers.tpl +++ b/mika/rizz/templates/_helpers.tpl @@ -116,7 +116,7 @@ def start(): scheduler.add_job(rss.update_data, 'cron', hour='7,12,14,16,20,22', id=job_name, replace_existing=True) job_name = "post_scheduler" - scheduler.add_job(post_scheduler, 'cron', second='9,13,15,17,19,21,23', id=job_name, replace_existing=True) + scheduler.add_job(post_scheduler, 'cron', hour='9,13,15,17,19,21,23', id=job_name, replace_existing=True) scheduler.start() {{- end }} From ff01ef2697992fc24f5935875a45b924c37790fb Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 9 Jun 2023 02:36:42 +0800 Subject: [PATCH 058/117] Add another hour to run post_scheduler --- mika/rizz/templates/_helpers.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mika/rizz/templates/_helpers.tpl b/mika/rizz/templates/_helpers.tpl index 5f726cce..bbb59207 100644 --- a/mika/rizz/templates/_helpers.tpl +++ b/mika/rizz/templates/_helpers.tpl @@ -116,7 +116,7 @@ def start(): scheduler.add_job(rss.update_data, 'cron', hour='7,12,14,16,20,22', id=job_name, replace_existing=True) job_name = "post_scheduler" - scheduler.add_job(post_scheduler, 'cron', hour='9,13,15,17,19,21,23', id=job_name, replace_existing=True) + scheduler.add_job(post_scheduler, 'cron', hour='9,10,13,15,17,19,21,23', id=job_name, replace_existing=True) scheduler.start() {{- end }} @@ -961,7 +961,7 @@ app.conf.beat_schedule = { # check for any posts that need to be posted "post_scheduler": { "task": "base.tasks.post_scheduler_task", - "schedule": crontab(hour='9,13,15,17,19,21,23', minute=0), + "schedule": crontab(hour='9,10,13,15,17,19,21,23', minute=0), }, } From a765763f96f8dd63dd24b610dbce001e5ddf1dfe Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 15 Jun 2023 19:35:24 +0800 Subject: [PATCH 059/117] Use double quotes --- mika/rizz/templates/_helpers.tpl | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/mika/rizz/templates/_helpers.tpl b/mika/rizz/templates/_helpers.tpl index bbb59207..6f64b49e 100644 --- a/mika/rizz/templates/_helpers.tpl +++ b/mika/rizz/templates/_helpers.tpl @@ -85,7 +85,7 @@ APScheduler /base/base/apps.py template from django.apps import AppConfig class BaseConfig(AppConfig): - name = 'base' + name = "base" def ready(self): from . import signals @@ -110,13 +110,13 @@ def start(): scheduler = BlockingScheduler(timezone=SCHEDULER_TIMEZONE) job_name = "clean_data" - scheduler.add_job(rss.clean_data, 'cron', hour='0', id=job_name, replace_existing=True) + scheduler.add_job(rss.clean_data, "cron", hour="0", id=job_name, replace_existing=True) job_name = "update_data" - scheduler.add_job(rss.update_data, 'cron', hour='7,12,14,16,20,22', id=job_name, replace_existing=True) + scheduler.add_job(rss.update_data, "cron", hour="7,12,14,16,20,22", id=job_name, replace_existing=True) job_name = "post_scheduler" - scheduler.add_job(post_scheduler, 'cron', hour='9,10,13,15,17,19,21,23', id=job_name, replace_existing=True) + scheduler.add_job(post_scheduler, "cron", hour="9,10,13,15,17,19,21,23", id=job_name, replace_existing=True) scheduler.start() {{- end }} @@ -949,19 +949,19 @@ app.autodiscover_tasks() app.conf.beat_schedule = { # clean data - "clean_data": { - "task": "base.tasks.clean_data_task", - "schedule": crontab(hour=0, minute=0), + "clean_data" : { + "task" : "base.tasks.clean_data_task", + "schedule" : crontab(hour=0, minute=0), }, # update data - "update_data": { - "task": "base.tasks.update_data_task", - "schedule": crontab(hour='7,12,14,16,20,22', minute=0), + "update_data" : { + "task" : "base.tasks.update_data_task", + "schedule" : crontab(hour="7,12,14,16,20,22", minute=0), }, # check for any posts that need to be posted - "post_scheduler": { - "task": "base.tasks.post_scheduler_task", - "schedule": crontab(hour='9,10,13,15,17,19,21,23', minute=0), + "post_scheduler" : { + "task" : "base.tasks.post_scheduler_task", + "schedule" : crontab(hour="9,10,13,15,17,19,21,23", minute=0), }, } From 28779766cc5106ae843fca2e02c294f34b076384 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 15 Jun 2023 19:36:47 +0800 Subject: [PATCH 060/117] Remove redundant default value --- mika/rizz/templates/_helpers.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mika/rizz/templates/_helpers.tpl b/mika/rizz/templates/_helpers.tpl index 6f64b49e..088f7a8c 100644 --- a/mika/rizz/templates/_helpers.tpl +++ b/mika/rizz/templates/_helpers.tpl @@ -103,7 +103,7 @@ from lib import rss from apscheduler.schedulers.blocking import BlockingScheduler -SCHEDULER_TIMEZONE = getattr(settings, "SCHEDULER_TIMEZONE", None) +SCHEDULER_TIMEZONE = getattr(settings, "SCHEDULER_TIMEZONE") def start(): From 7c05df960f3cbf5e22702a2e80f9ebce47372f95 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 15 Jun 2023 19:36:56 +0800 Subject: [PATCH 061/117] Remove unused import --- mika/rizz/templates/_helpers.tpl | 1 - 1 file changed, 1 deletion(-) diff --git a/mika/rizz/templates/_helpers.tpl b/mika/rizz/templates/_helpers.tpl index 088f7a8c..8011ce5d 100644 --- a/mika/rizz/templates/_helpers.tpl +++ b/mika/rizz/templates/_helpers.tpl @@ -985,7 +985,6 @@ Celery /base/base/tasks.py template */}} {{- define "rizz.celery-tasks-py" -}} from __future__ import absolute_import, unicode_literals -import logging from celery import shared_task from base.methods import post_scheduler from lib import rss From e7dd5a0506a2382c7d988648e10fc8b718ed872c Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 15 Jun 2023 19:39:04 +0800 Subject: [PATCH 062/117] Remove indented line --- mika/rizz/templates/configmap.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mika/rizz/templates/configmap.yaml b/mika/rizz/templates/configmap.yaml index 5de2696d..364c6119 100644 --- a/mika/rizz/templates/configmap.yaml +++ b/mika/rizz/templates/configmap.yaml @@ -44,7 +44,7 @@ data: WSGIScriptAlias / /base/base/wsgi.py {{ "WSGIDaemonProcess $domain python-path=/base" | replace "$domain" $domain }} {{ "WSGIProcessGroup $domain" | replace "$domain" $domain }} - + Require all granted @@ -55,7 +55,7 @@ data: Require all granted - + ErrorLog /var/log/apache2/apache.error.log CustomLog /var/log/apache2/apache.access.log combined From 8dab5f7765af959c23f949cb14d75cf241f81c90 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 15 Jun 2023 21:02:36 +0800 Subject: [PATCH 063/117] Pass value to celery crontab schedule as string --- mika/rizz/templates/_helpers.tpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mika/rizz/templates/_helpers.tpl b/mika/rizz/templates/_helpers.tpl index 8011ce5d..61781d34 100644 --- a/mika/rizz/templates/_helpers.tpl +++ b/mika/rizz/templates/_helpers.tpl @@ -951,17 +951,17 @@ app.conf.beat_schedule = { # clean data "clean_data" : { "task" : "base.tasks.clean_data_task", - "schedule" : crontab(hour=0, minute=0), + "schedule" : crontab(hour="0", minute="0"), }, # update data "update_data" : { "task" : "base.tasks.update_data_task", - "schedule" : crontab(hour="7,12,14,16,20,22", minute=0), + "schedule" : crontab(hour="7,12,14,16,20,22", minute="0"), }, # check for any posts that need to be posted "post_scheduler" : { "task" : "base.tasks.post_scheduler_task", - "schedule" : crontab(hour="9,10,13,15,17,19,21,23", minute=0), + "schedule" : crontab(hour="9,10,13,15,17,19,21,23", minute="0"), }, } From ff9b16d9e0a8121f2575f82dd752b875f36aa17f Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 15 Jun 2023 22:58:06 +0800 Subject: [PATCH 064/117] Add ability to adjust schedule hours --- mika/rizz/README.md | 3 +++ mika/rizz/templates/_helpers.tpl | 12 ++++++------ mika/rizz/templates/configmap.yaml | 7 +++++-- mika/rizz/values.yaml | 17 +++++++++++++++++ 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/mika/rizz/README.md b/mika/rizz/README.md index 33e19a95..8af26ef7 100644 --- a/mika/rizz/README.md +++ b/mika/rizz/README.md @@ -110,5 +110,8 @@ helm uninstall $release_name --namespace $namespace --wait | rizz.rss.post_limit | string | `""` | The limit number of posts to be scheduled for posting by Rizz per run. Default: `"3"`. | | rizz.scheduler.apscheduler | bool | `true` | Specifies whether APScheduler should be used by Rizz as the task scheduler. | | rizz.scheduler.celery | bool | `false` | Specifies whether Celery should be used by Rizz as the task scheduler. | +| rizz.scheduler.schedule.clean_data | string | `""` | The hours at which the task scheduler cleans up the database. Default: `"0"`. | +| rizz.scheduler.schedule.post_scheduler | string | `""` | The hours at which the task scheduler posts scheduled posts. Default: `"8-23/3"`. | +| rizz.scheduler.schedule.update_data | string | `""` | The hours at which the task scheduler updates the database. Default: `"7-22/3"`. | | rizz.scheduler.timezone | string | `""` | The timezone for the task scheduler used by Rizz to schedule time-dependent operations. Default: `"Asia/Kuala_Lumpur"`. | | rizz.secret | string | `""` | A 50-character secret key used for secure session management and cryptographic operations within the Rizz service. | diff --git a/mika/rizz/templates/_helpers.tpl b/mika/rizz/templates/_helpers.tpl index 61781d34..c529f352 100644 --- a/mika/rizz/templates/_helpers.tpl +++ b/mika/rizz/templates/_helpers.tpl @@ -110,13 +110,13 @@ def start(): scheduler = BlockingScheduler(timezone=SCHEDULER_TIMEZONE) job_name = "clean_data" - scheduler.add_job(rss.clean_data, "cron", hour="0", id=job_name, replace_existing=True) + scheduler.add_job(rss.clean_data, "cron", hour=CLEAN_DATA_HOURS, id=job_name, replace_existing=True) job_name = "update_data" - scheduler.add_job(rss.update_data, "cron", hour="7,12,14,16,20,22", id=job_name, replace_existing=True) + scheduler.add_job(rss.update_data, "cron", hour=UPDATE_DATA_HOURS, id=job_name, replace_existing=True) job_name = "post_scheduler" - scheduler.add_job(post_scheduler, "cron", hour="9,10,13,15,17,19,21,23", id=job_name, replace_existing=True) + scheduler.add_job(post_scheduler, "cron", hour=POST_SCHEDULER_HOURS, id=job_name, replace_existing=True) scheduler.start() {{- end }} @@ -951,17 +951,17 @@ app.conf.beat_schedule = { # clean data "clean_data" : { "task" : "base.tasks.clean_data_task", - "schedule" : crontab(hour="0", minute="0"), + "schedule" : crontab(hour=CLEAN_DATA_HOURS, minute="0"), }, # update data "update_data" : { "task" : "base.tasks.update_data_task", - "schedule" : crontab(hour="7,12,14,16,20,22", minute="0"), + "schedule" : crontab(hour=UPDATE_DATA_HOURS, minute="0"), }, # check for any posts that need to be posted "post_scheduler" : { "task" : "base.tasks.post_scheduler_task", - "schedule" : crontab(hour="9,10,13,15,17,19,21,23", minute="0"), + "schedule" : crontab(hour=POST_SCHEDULER_HOURS, minute="0"), }, } diff --git a/mika/rizz/templates/configmap.yaml b/mika/rizz/templates/configmap.yaml index 364c6119..856072b9 100644 --- a/mika/rizz/templates/configmap.yaml +++ b/mika/rizz/templates/configmap.yaml @@ -8,6 +8,9 @@ {{- $post_limit := .Values.rizz.rss.post_limit | default "3" | toString | quote }} {{- $apscheduler := .Values.rizz.scheduler.apscheduler }} {{- $celery := .Values.rizz.scheduler.celery }} +{{- $clean_data := .Values.rizz.scheduler.schedule.clean_data | default "0" | toString | quote }} +{{- $post_scheduler := .Values.rizz.scheduler.schedule.post_scheduler | default "8-23/3" | toString | quote }} +{{- $update_data := .Values.rizz.scheduler.schedule.update_data | default "7-22/3" | toString | quote }} apiVersion: v1 kind: ConfigMap metadata: @@ -114,8 +117,8 @@ data: {{- end }} tasks.py: |- {{- if $apscheduler }} - {{- include "rizz.apscheduler-tasks-py" . | nindent 4 }} + {{- include "rizz.apscheduler-tasks-py" . | replace "CLEAN_DATA_HOURS" $clean_data | replace "UPDATE_DATA_HOURS" $update_data | replace "POST_SCHEDULER_HOURS" $post_scheduler | nindent 4 }} {{- else if $celery }} - {{- include "rizz.celery-tasks-py" . | nindent 4 }} + {{- include "rizz.celery-tasks-py" . | replace "CLEAN_DATA_HOURS" $clean_data | replace "UPDATE_DATA_HOURS" $update_data | replace "POST_SCHEDULER_HOURS" $post_scheduler | nindent 4 }} {{- end }} {{- end }} diff --git a/mika/rizz/values.yaml b/mika/rizz/values.yaml index fd36999c..87fb7574 100644 --- a/mika/rizz/values.yaml +++ b/mika/rizz/values.yaml @@ -94,6 +94,23 @@ rizz: # Example: # celery: true celery: false + # The schedule for the task scheduler used by Rizz. + schedule: + # The hours at which the task scheduler cleans up the database. + # Default: "0" + # Example: + # clean_data: "0" + clean_data: "" + # The hours at which the task scheduler posts scheduled posts. + # Default: "8-23/3" + # Example: + # post_scheduler: "9,10,13,15,17,19,21,23" + post_scheduler: "" + # The hours at which the task scheduler updates the database. + # Default: "7-22/3" + # Example: + # update_data: "7,12,14,16,20,22" + update_data: "" # The timezone for the task scheduler used by Rizz to schedule time-dependent operations. # Default: "Asia/Kuala_Lumpur" # Example: From 8727b8c1a5c043c51030ee96d34a83f5fcd283f7 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 15 Jun 2023 23:02:11 +0800 Subject: [PATCH 065/117] Update example value --- mika/rizz/values.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mika/rizz/values.yaml b/mika/rizz/values.yaml index 87fb7574..0e054324 100644 --- a/mika/rizz/values.yaml +++ b/mika/rizz/values.yaml @@ -99,17 +99,17 @@ rizz: # The hours at which the task scheduler cleans up the database. # Default: "0" # Example: - # clean_data: "0" + # clean_data: "0,6,12,18" clean_data: "" # The hours at which the task scheduler posts scheduled posts. # Default: "8-23/3" # Example: - # post_scheduler: "9,10,13,15,17,19,21,23" + # post_scheduler: "*" post_scheduler: "" # The hours at which the task scheduler updates the database. # Default: "7-22/3" # Example: - # update_data: "7,12,14,16,20,22" + # update_data: "9-18" update_data: "" # The timezone for the task scheduler used by Rizz to schedule time-dependent operations. # Default: "Asia/Kuala_Lumpur" From 5957a4db411fe4e9851bef17dfb10b7b52f115a9 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 15 Jun 2023 23:45:32 +0800 Subject: [PATCH 066/117] Move site-config.conf template to helpers --- mika/rizz/templates/_helpers.tpl | 29 +++++++++++++++++++++++++++++ mika/rizz/templates/configmap.yaml | 24 +----------------------- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/mika/rizz/templates/_helpers.tpl b/mika/rizz/templates/_helpers.tpl index c529f352..546a174e 100644 --- a/mika/rizz/templates/_helpers.tpl +++ b/mika/rizz/templates/_helpers.tpl @@ -61,6 +61,35 @@ Create the name of the service account to use {{- end }} {{- end }} +{{/* +Apache site-config.conf template +*/}} +{{- define "rizz.site-config-conf" -}} + + ServerName DOMAIN:443 + UseCanonicalName On + ServerAdmin support@mikahomelab.com + DocumentRoot /base + WSGIScriptAlias / /base/base/wsgi.py + WSGIDaemonProcess DOMAIN python-path=/base + WSGIProcessGroup DOMAIN + + + + Require all granted + + + + Alias /static /static + + Require all granted + + + ErrorLog /var/log/apache2/apache.error.log + CustomLog /var/log/apache2/apache.access.log combined + +{{- end }} + {{/* APScheduler /entrypoint.sh template */}} diff --git a/mika/rizz/templates/configmap.yaml b/mika/rizz/templates/configmap.yaml index 856072b9..f5b66998 100644 --- a/mika/rizz/templates/configmap.yaml +++ b/mika/rizz/templates/configmap.yaml @@ -39,29 +39,7 @@ metadata: {{- include "rizz.labels" . | nindent 4 }} data: site-config.conf: |- - - {{ "ServerName $domain:443" | replace "$domain" $domain }} - UseCanonicalName On - ServerAdmin support@mikahomelab.com - DocumentRoot /base - WSGIScriptAlias / /base/base/wsgi.py - {{ "WSGIDaemonProcess $domain python-path=/base" | replace "$domain" $domain }} - {{ "WSGIProcessGroup $domain" | replace "$domain" $domain }} - - - - Require all granted - - - - Alias /static /static - - Require all granted - - - ErrorLog /var/log/apache2/apache.error.log - CustomLog /var/log/apache2/apache.access.log combined - + {{- include "rizz.site-config-conf" . | replace "DOMAIN" $domain | nindent 4 }} {{- if $apscheduler }} --- apiVersion: v1 From 8ad843a336e2fdd9958c011a392c0dff2676f041 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 00:25:22 +0800 Subject: [PATCH 067/117] Reorder image config --- template/CHART_NAME/values.yaml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/template/CHART_NAME/values.yaml b/template/CHART_NAME/values.yaml index 92266643..cabff22a 100644 --- a/template/CHART_NAME/values.yaml +++ b/template/CHART_NAME/values.yaml @@ -8,20 +8,6 @@ replicaCount: "" # Container images used for CHART_NAME. image: - # Init container image configurations. - init: - # The registry where the Init container image is hosted. - # Default: "docker.io" - registry: "" - # The name of the repository that contains the Init container image used. - # Default: "busybox" - repository: "" - # The tag that specifies the version of the Init container image used. - # Default: "1.34" - tag: "" - # The policy that determines when Kubernetes should pull the Init container image. - # Default: "IfNotPresent" - pullPolicy: "" # CHART_NAME container image configurations. CHART_NAME: # The registry where the CHART_NAME container image is hosted. @@ -36,6 +22,20 @@ image: # The policy that determines when Kubernetes should pull the CHART_NAME container image. # Default: "IfNotPresent" pullPolicy: "" + # Init container image configurations. + init: + # The registry where the Init container image is hosted. + # Default: "docker.io" + registry: "" + # The name of the repository that contains the Init container image used. + # Default: "busybox" + repository: "" + # The tag that specifies the version of the Init container image used. + # Default: "1.34" + tag: "" + # The policy that determines when Kubernetes should pull the Init container image. + # Default: "IfNotPresent" + pullPolicy: "" # CHART_NAME configurations. CHART_NAME: From 3dd54a8c6838c24a50f37c5c8dea025a1a09ea56 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 00:28:01 +0800 Subject: [PATCH 068/117] Add imagePullSecrets in template chart --- template/CHART_NAME/README.md | 1 + template/CHART_NAME/templates/deployment.yaml | 4 ++++ template/CHART_NAME/values.yaml | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/template/CHART_NAME/README.md b/template/CHART_NAME/README.md index ebde9ea0..de7d4d88 100644 --- a/template/CHART_NAME/README.md +++ b/template/CHART_NAME/README.md @@ -81,6 +81,7 @@ helm uninstall $release_name --namespace $namespace --wait | image.init.registry | string | `""` | The registry where the Init container image is hosted. Default: `"docker.io"`. | | image.init.repository | string | `""` | The name of the repository that contains the Init container image used. Default: `"busybox"`. | | image.init.tag | string | `""` | The tag that specifies the version of the Init container image used. Default: `"1.34"`. | +| imagePullSecrets | list | `[]` | Credentials used to securely authenticate and authorise the pulling of container images from private registries. | | replicaCount | int | `""` | The desired number of running replicas for CHART_NAME. Default: `"1"`. | | resources.limits.cpu | string | `"250m"` | The maximum amount of CPU resources allowed for CHART_NAME. | | resources.limits.memory | string | `"250Mi"` | The maximum amount of memory allowed for CHART_NAME. | diff --git a/template/CHART_NAME/templates/deployment.yaml b/template/CHART_NAME/templates/deployment.yaml index 8274a980..6708f51e 100644 --- a/template/CHART_NAME/templates/deployment.yaml +++ b/template/CHART_NAME/templates/deployment.yaml @@ -27,6 +27,10 @@ spec: labels: {{- include "CHART_NAME.selectorLabels" . | nindent 8 }} spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} initContainers: - name: init image: {{ printf "%s/%s:%s" $init_registry $init_repository $init_tag | quote }} diff --git a/template/CHART_NAME/values.yaml b/template/CHART_NAME/values.yaml index cabff22a..115219e2 100644 --- a/template/CHART_NAME/values.yaml +++ b/template/CHART_NAME/values.yaml @@ -37,6 +37,12 @@ image: # Default: "IfNotPresent" pullPolicy: "" +# Credentials used to securely authenticate and authorise the pulling of container images from private registries. +# Example: +# imagePullSecrets: +# - name: "ghcr-token-secret" +imagePullSecrets: [] + # CHART_NAME configurations. CHART_NAME: # The value of the CHART_NAME foo. From 5612b0115b66476c80856c9b5aa2047fc3ec69d4 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 00:30:20 +0800 Subject: [PATCH 069/117] Add step to upgrade --- mika/rizz/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mika/rizz/README.md b/mika/rizz/README.md index 8af26ef7..e2092112 100644 --- a/mika/rizz/README.md +++ b/mika/rizz/README.md @@ -65,6 +65,14 @@ Verify that your chart has been installed. Replace `$namespace` and `$release_na helm ls --namespace $namespace | grep "$release_name" ``` +## How to upgrade + +After making any necessary changes to the `values.yaml` file, upgrade the desired chart. Replace `$release_name` and `$namespace` accordingly. + +```sh +helm upgrade $release_name mika/rizz --namespace $namespace --values values.yaml --wait +``` + ## How to uninstall Uninstall the desired chart. Replace `$release_name` and `$namespace` accordingly. From c7e2005e5314ca8bbf18a87d58e085a23fdb4285 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 00:37:49 +0800 Subject: [PATCH 070/117] Use envFrom in template chart --- template/CHART_NAME/templates/deployment.yaml | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/template/CHART_NAME/templates/deployment.yaml b/template/CHART_NAME/templates/deployment.yaml index 6708f51e..a4603f7a 100644 --- a/template/CHART_NAME/templates/deployment.yaml +++ b/template/CHART_NAME/templates/deployment.yaml @@ -54,17 +54,11 @@ spec: protocol: TCP resources: {{- toYaml .Values.resources | nindent 12 }} - env: - - name: FOO - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-CHART_NAME-cm - key: FOO - - name: BAR - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-CHART_NAME-secret - key: BAR + envFrom: + - configMapRef: + name: {{ .Release.Name }}-CHART_NAME-cm + - secretRef: + name: {{ .Release.Name }}-CHART_NAME-secret volumeMounts: - name: {{ .Release.Name }}-CHART_NAME-data mountPath: /opt/CHART_NAME From 8741c32e3bab791d48f99750d5770495607f6ea6 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 00:38:35 +0800 Subject: [PATCH 071/117] Reorder declaraations alphabetically --- template/CHART_NAME/templates/deployment.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/template/CHART_NAME/templates/deployment.yaml b/template/CHART_NAME/templates/deployment.yaml index a4603f7a..e302ac4e 100644 --- a/template/CHART_NAME/templates/deployment.yaml +++ b/template/CHART_NAME/templates/deployment.yaml @@ -1,12 +1,12 @@ -{{- $replica_count := .Values.replicaCount | default "1" | toString }} -{{- $init_registry := .Values.image.init.registry | default "docker.io" | toString }} -{{- $init_repository := .Values.image.init.repository | default "busybox" | toString }} -{{- $init_tag := .Values.image.init.tag | default "1.34" | toString }} -{{- $init_pullPolicy := .Values.image.init.pullPolicy | default "IfNotPresent" | toString | quote }} {{- $CHART_NAME_registry := .Values.image.CHART_NAME.registry | default "docker.io" | toString }} {{- $CHART_NAME_repository := .Values.image.CHART_NAME.repository | default "CHART_NAME" | toString }} {{- $CHART_NAME_tag := .Values.image.CHART_NAME.tag | default .Chart.AppVersion | toString }} {{- $CHART_NAME_pullPolicy := .Values.image.CHART_NAME.pullPolicy | default "IfNotPresent" | toString | quote }} +{{- $init_registry := .Values.image.init.registry | default "docker.io" | toString }} +{{- $init_repository := .Values.image.init.repository | default "busybox" | toString }} +{{- $init_tag := .Values.image.init.tag | default "1.34" | toString }} +{{- $init_pullPolicy := .Values.image.init.pullPolicy | default "IfNotPresent" | toString | quote }} +{{- $replica_count := .Values.replicaCount | default "1" | toString }} apiVersion: apps/v1 kind: Deployment metadata: From b9afd9c9b47e136592feeefe5785dff49e231cec Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 00:45:24 +0800 Subject: [PATCH 072/117] Add How to upgrade step --- mika/postgres/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mika/postgres/README.md b/mika/postgres/README.md index 9aedf416..fd58753b 100644 --- a/mika/postgres/README.md +++ b/mika/postgres/README.md @@ -49,6 +49,14 @@ Verify that your chart has been installed. Replace `$namespace` and `$release_na helm ls --namespace $namespace | grep "$release_name" ``` +## How to upgrade + +After making any necessary changes to the `values.yaml` file, upgrade the desired chart. Replace `$release_name` and `$namespace` accordingly. + +```sh +helm upgrade $release_name mika/postgres --namespace $namespace --values values.yaml --wait +``` + ## How to uninstall Uninstall the desired chart. Replace `$release_name` and `$namespace` accordingly. From 4be11b90c62282c4367af1c74e4b2ee20b6fc66d Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 01:19:55 +0800 Subject: [PATCH 073/117] Add step to upgrade --- mika/postgres-agent/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mika/postgres-agent/README.md b/mika/postgres-agent/README.md index c0486573..1189d54e 100644 --- a/mika/postgres-agent/README.md +++ b/mika/postgres-agent/README.md @@ -55,6 +55,14 @@ Verify that your chart has been installed. Replace `$namespace` and `$release_na helm ls --namespace $namespace | grep "$release_name" ``` +## How to upgrade + +After making any necessary changes to the `values.yaml` file, upgrade the desired chart. Replace `$release_name` and `$namespace` accordingly. + +```sh +helm upgrade $release_name mika/postgres-agent --namespace $namespace --values values.yaml --wait +``` + ## How to uninstall Uninstall the desired chart. Replace `$release_name` and `$namespace` accordingly. From 1eabdd2e719b31016f2807aeb041011b46783ef0 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 01:20:06 +0800 Subject: [PATCH 074/117] Update values description --- mika/postgres-agent/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mika/postgres-agent/values.yaml b/mika/postgres-agent/values.yaml index 3cd49c1c..6abb0720 100644 --- a/mika/postgres-agent/values.yaml +++ b/mika/postgres-agent/values.yaml @@ -2,7 +2,7 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -# Container images used for PostgreSQL. +# Container image used for PostgreSQL. image: # PostgreSQL container image configurations. postgres: From 8658325c6a6606237486e646606e95e5c23903df Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 01:20:39 +0800 Subject: [PATCH 075/117] Update chart keyword --- mika/postgres-agent/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mika/postgres-agent/Chart.yaml b/mika/postgres-agent/Chart.yaml index 8e120614..fec6238d 100644 --- a/mika/postgres-agent/Chart.yaml +++ b/mika/postgres-agent/Chart.yaml @@ -5,7 +5,7 @@ type: application version: 0.1.2 appVersion: "13.3" keywords: - - "postgres" + - "postgresql" - "agent" - "job" home: "https://github.com/irfanhakim-as/charts" From 4bdd1fc00da291803295eed9bde5b06edc43d40a Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 01:22:27 +0800 Subject: [PATCH 076/117] Update post-install notes --- mika/postgres-agent/templates/NOTES.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mika/postgres-agent/templates/NOTES.txt b/mika/postgres-agent/templates/NOTES.txt index 2aa928c7..2074f3de 100644 --- a/mika/postgres-agent/templates/NOTES.txt +++ b/mika/postgres-agent/templates/NOTES.txt @@ -1 +1,5 @@ -postgres-agent job has been deployed for {{ .Release.Name }}. +postgres-agent job has been deployed for {{ .Release.Name | toString }}. + +See the values.yaml file of this chart for more configuration options. + +Please refer to the official documentation for more information on how to use postgres-agent. From c83b7e6dbe7ade2a02f8e03dbe58d7f599f18f7b Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 01:59:13 +0800 Subject: [PATCH 077/117] Update cloudflared templates --- mika/cloudflared/Chart.yaml | 18 +++---- mika/cloudflared/README.md | 56 +++++++++++++-------- mika/cloudflared/templates/NOTES.txt | 6 ++- mika/cloudflared/templates/configmap.yaml | 3 +- mika/cloudflared/templates/deployment.yaml | 10 +++- mika/cloudflared/values.yaml | 57 ++++++++++++++++------ 6 files changed, 103 insertions(+), 47 deletions(-) diff --git a/mika/cloudflared/Chart.yaml b/mika/cloudflared/Chart.yaml index b1deedd5..996ce495 100644 --- a/mika/cloudflared/Chart.yaml +++ b/mika/cloudflared/Chart.yaml @@ -5,14 +5,14 @@ type: application version: 0.1.0 appVersion: "2022.3.0" keywords: - - cloudflared - - cloudflare - - tunnel -home: https://github.com/irfanhakim-as/charts -icon: https://irfanhakim-as.github.io/charts/logos/cloudflare.png + - "cloudflared" + - "cloudflare" + - "tunnel" +home: "https://github.com/irfanhakim-as/charts" +icon: "https://irfanhakim-as.github.io/charts/logos/cloudflare.png" sources: - - https://github.com/irfanhakim-as/charts + - "https://github.com/irfanhakim-as/charts" maintainers: - - name: Irfan Hakim - email: irfanhakim.as@yahoo.com - url: https://github.com/irfanhakim-as + - name: "Irfan Hakim" + email: "irfanhakim.as@yahoo.com" + url: "https://github.com/irfanhakim-as" diff --git a/mika/cloudflared/README.md b/mika/cloudflared/README.md index 41245218..8cd79fc5 100644 --- a/mika/cloudflared/README.md +++ b/mika/cloudflared/README.md @@ -15,14 +15,18 @@ cloudflared tunnel login ### Create Cloudflare tunnel +Replace `$tunnel` accordingly. + ```sh -cloudflared tunnel create +cloudflared tunnel create $tunnel ``` ### Associate Cloudflare tunnel with a DNS record +Replace `$tunnel` and `$hostname` accordingly. + ```sh -cloudflared tunnel route dns +cloudflared tunnel route dns $tunnel $hostname ``` ## How to add repo @@ -61,11 +65,11 @@ Install the desired chart. Replace `$release_name`, `$namespace` and `$credentia ```sh helm install $release_name \ - --namespace $namespace \ - --create-namespace \ - --set-file tunnel.file=$credentials.json \ - --values values.yaml \ - --wait mika/cloudflared +--namespace $namespace \ +--create-namespace \ +--set-file tunnel.file=$credentials.json \ +--values values.yaml \ +--wait mika/cloudflared ``` Verify that your chart has been installed. Replace `$namespace` and `$release_name` accordingly. @@ -74,6 +78,18 @@ Verify that your chart has been installed. Replace `$namespace` and `$release_na helm ls --namespace $namespace | grep "$release_name" ``` +## How to upgrade + +After making any necessary changes to the `values.yaml` file, upgrade the desired chart. Replace `$release_name`, `$namespace` and `$credentials.json` accordingly. + +```sh +helm upgrade $release_name \ +--namespace $namespace \ +--set-file tunnel.file=$credentials.json \ +--values values.yaml \ +--wait mika/cloudflared +``` + ## How to uninstall Uninstall the desired chart. Replace `$release_name` and `$namespace` accordingly. @@ -82,19 +98,19 @@ Uninstall the desired chart. Replace `$release_name` and `$namespace` accordingl helm uninstall $release_name --namespace $namespace --wait ``` -## Configuration +## Configurations | Key | Type | Default | Description | |-----|------|---------|-------------| -| image.cloudflared.pullPolicy | string | `"IfNotPresent"` | Cloudflared image pull policy | -| image.cloudflared.registry | string | `"docker.io"` | Cloudflared image registry | -| image.cloudflared.repository | string | `"cloudflare/cloudflared"` | Cloudflared image repository | -| image.cloudflared.tag | string | `""` | Cloudflared image version | -| ingress | list | `[]` | Cloudflare ingress rules | -| replicaCount | int | `1` | Cloudflared replica count | -| resources.limits.cpu | string | `"500m"` | Maximum cpu allocation | -| resources.limits.memory | string | `"500Mi"` | Maximum ram allocation | -| resources.requests.cpu | string | `"10m"` | Minimum cpu allocation | -| resources.requests.memory | string | `"10Mi"` | Minimum ram allocation | -| tunnel.file | file | `""` | Cloudflare tunnel credentials file | -| tunnel.name | string | `""` | Cloudflare tunnel name | \ No newline at end of file +| image.cloudflared.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the Cloudflared container image. Default: `"IfNotPresent"`. | +| image.cloudflared.registry | string | `""` | The registry where the Cloudflared container image is hosted. Default: `"docker.io"`. | +| image.cloudflared.repository | string | `""` | The name of the repository that contains the Cloudflared container image used. Default: `"cloudflare/cloudflared"`. | +| image.cloudflared.tag | string | `""` | The tag that specifies the version of the Cloudflared container image used. Default: `Chart appVersion`. | +| ingress | list | `[]` | Cloudflare ingress configurations. | +| replicaCount | string | `""` | The desired number of running replicas for Cloudflared. Default: `"1"`. | +| resources.limits.cpu | string | `"500m"` | The maximum amount of CPU resources allowed for Cloudflared. | +| resources.limits.memory | string | `"500Mi"` | The maximum amount of memory allowed for Cloudflared. | +| resources.requests.cpu | string | `"10m"` | The minimum amount of CPU resources required by Cloudflared. | +| resources.requests.memory | string | `"10Mi"` | The minimum amount of memory required by Cloudflared. | +| tunnel.file | file | `""` | The Cloudflare tunnel's credentials JSON file. | +| tunnel.name | string | `""` | The name of the Cloudflare tunnel. | diff --git a/mika/cloudflared/templates/NOTES.txt b/mika/cloudflared/templates/NOTES.txt index 0930fb86..d61b850f 100644 --- a/mika/cloudflared/templates/NOTES.txt +++ b/mika/cloudflared/templates/NOTES.txt @@ -1 +1,5 @@ -cloudflared for {{ .Release.Name }} is now installed and configured. +cloudflared is now installed and configured for {{ .Release.Name | toString }}. + +See the values.yaml file of this chart for more configuration options. + +Please refer to the official documentation for more information on how to use cloudflared. diff --git a/mika/cloudflared/templates/configmap.yaml b/mika/cloudflared/templates/configmap.yaml index c1e73253..392be2de 100644 --- a/mika/cloudflared/templates/configmap.yaml +++ b/mika/cloudflared/templates/configmap.yaml @@ -1,3 +1,4 @@ +{{- $name := .Values.tunnel.name | toString | quote }} apiVersion: v1 kind: ConfigMap metadata: @@ -7,7 +8,7 @@ metadata: data: config.yaml: | # Name of the tunnel you want to run - tunnel: {{ .Values.tunnel.name }} + tunnel: {{ $name }} credentials-file: /etc/cloudflared/creds/credentials.json # Serves the metrics server under /metrics and the readiness server under /ready metrics: 0.0.0.0:2000 diff --git a/mika/cloudflared/templates/deployment.yaml b/mika/cloudflared/templates/deployment.yaml index 6ec127a5..5f5e6eac 100644 --- a/mika/cloudflared/templates/deployment.yaml +++ b/mika/cloudflared/templates/deployment.yaml @@ -1,3 +1,8 @@ +{{- $replica_count := .Values.replicaCount | default "1" | toString }} +{{- $registry := .Values.image.cloudflared.registry | default "docker.io" | toString }} +{{- $repository := .Values.image.cloudflared.repository | default "cloudflare/cloudflared" | toString }} +{{- $tag := .Values.image.cloudflared.tag | default .Chart.AppVersion | toString }} +{{- $pullPolicy := .Values.image.cloudflared.pullPolicy | default "IfNotPresent" | toString | quote }} apiVersion: apps/v1 kind: Deployment metadata: @@ -5,7 +10,7 @@ metadata: labels: {{- include "cloudflared.labels" . | nindent 4 }} spec: - replicas: {{ .Values.replicaCount | default 1 }} + replicas: {{ int $replica_count }} selector: matchLabels: {{- include "cloudflared.selectorLabels" . | nindent 6 }} @@ -20,7 +25,8 @@ spec: spec: containers: - name: cloudflared - image: "{{ .Values.image.cloudflared.registry }}/{{ .Values.image.cloudflared.repository }}:{{ .Values.image.cloudflared.tag | default .Chart.AppVersion }}" + image: {{ printf "%s/%s:%s" $registry $repository $tag | quote }} + imagePullPolicy: {{ $pullPolicy }} resources: {{- toYaml .Values.resources | nindent 12 }} args: diff --git a/mika/cloudflared/values.yaml b/mika/cloudflared/values.yaml index 62611869..62c98fd0 100644 --- a/mika/cloudflared/values.yaml +++ b/mika/cloudflared/values.yaml @@ -2,39 +2,68 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -replicaCount: 1 +# The desired number of running replicas for Cloudflared. +# Default: "1" +replicaCount: "" -# Cloudflared image configuration +# Container image used for Cloudflared. image: + # Cloudflared container image configurations. cloudflared: - registry: docker.io - repository: cloudflare/cloudflared + # The registry where the Cloudflared container image is hosted. + # Default: "docker.io" + registry: "" + # The name of the repository that contains the Cloudflared container image used. + # Default: "cloudflare/cloudflared" + repository: "" + # The tag that specifies the version of the Cloudflared container image used. + # Default: Chart appVersion tag: "" - pullPolicy: IfNotPresent + # The policy that determines when Kubernetes should pull the Cloudflared container image. + # Default: "IfNotPresent" + pullPolicy: "" -# Cloudflare tunnel configuration +# Cloudflare tunnel configurations. tunnel: - # Cloudflare tunnel name + # The name of the Cloudflare tunnel. + # Example: + # name: "cloudflare" name: "" - # Cloudflare tunnel credentials file + # The Cloudflare tunnel's credentials JSON file. file: "" -# Ingress rules +# Cloudflare ingress configurations. # Example: # ingress: # - hostname: cloudflared.example.com # service: cloudflared.default.svc.cluster.local +# - hostname: dashboard.example.com +# service: http://11.22.64.13 +# - hostname: network.example.com +# originRequest: +# noTLSVerify: true +# service: https://11.22.64.15 ingress: [] -# Cloudflared system resources +# Resource requirements and limits for Cloudflared container. resources: + # The minimum amount of resources required by Cloudflared to run. requests: - # Minimum cpu allocation + # The minimum amount of CPU resources required by Cloudflared. + # Example: + # cpu: "20m" cpu: "10m" - # Minimum ram allocation + # The minimum amount of memory required by Cloudflared. + # Example: + # memory: "250Mi" memory: "10Mi" + # The maximum amount of resources allowed for Cloudflared. limits: - # Maximum cpu allocation + # The maximum amount of CPU resources allowed for Cloudflared. + # Example: + # cpu: "50m" cpu: "500m" - # Maximum ram allocation + # The maximum amount of memory allowed for Cloudflared. + # Example: + # memory: "450Mi" memory: "500Mi" From 94822163e9a21e0cf6bc4861eabb4be754fefd6a Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 02:00:04 +0800 Subject: [PATCH 078/117] Update header --- mika/postgres/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mika/postgres/README.md b/mika/postgres/README.md index fd58753b..2c7954af 100644 --- a/mika/postgres/README.md +++ b/mika/postgres/README.md @@ -65,7 +65,7 @@ Uninstall the desired chart. Replace `$release_name` and `$namespace` accordingl helm uninstall $release_name --namespace $namespace --wait ``` -## Configuration +## Configurations | Key | Type | Default | Description | |-----|------|---------|-------------| From d891c88a59490b4cdfd2d95837bb39eaff9b5b84 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 10:53:56 +0800 Subject: [PATCH 079/117] Add step to upgrade --- mika/waktusolat/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mika/waktusolat/README.md b/mika/waktusolat/README.md index 5803923b..9638db84 100644 --- a/mika/waktusolat/README.md +++ b/mika/waktusolat/README.md @@ -65,6 +65,14 @@ Verify that your chart has been installed. Replace `$namespace` and `$release_na helm ls --namespace $namespace | grep "$release_name" ``` +## How to upgrade + +After making any necessary changes to the `values.yaml` file, upgrade the desired chart. Replace `$release_name` and `$namespace` accordingly. + +```sh +helm upgrade $release_name mika/waktusolat --namespace $namespace --values values.yaml --wait +``` + ## How to uninstall Uninstall the desired chart. Replace `$release_name` and `$namespace` accordingly. From fa973e7461b9f38a2db1fc0a38442dba89294c8f Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 10:57:21 +0800 Subject: [PATCH 080/117] Move site-config.conf to helpers template --- mika/waktusolat/templates/_helpers.tpl | 29 ++++++++++++++++++++++++ mika/waktusolat/templates/configmap.yaml | 24 +------------------- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/mika/waktusolat/templates/_helpers.tpl b/mika/waktusolat/templates/_helpers.tpl index 28dba842..9049dd00 100644 --- a/mika/waktusolat/templates/_helpers.tpl +++ b/mika/waktusolat/templates/_helpers.tpl @@ -61,6 +61,35 @@ Create the name of the service account to use {{- end }} {{- end }} +{{/* +Apache site-config.conf template +*/}} +{{- define "waktusolat.site-config-conf" -}} + + ServerName DOMAIN:443 + UseCanonicalName On + ServerAdmin support@mikahomelab.com + DocumentRoot /base + WSGIScriptAlias / /base/base/wsgi.py + WSGIDaemonProcess DOMAIN python-path=/base + WSGIProcessGroup DOMAIN + + + + Require all granted + + + + Alias /static /static + + Require all granted + + + ErrorLog /var/log/apache2/apache.error.log + CustomLog /var/log/apache2/apache.access.log combined + +{{- end }} + {{/* APScheduler /entrypoint.sh template */}} diff --git a/mika/waktusolat/templates/configmap.yaml b/mika/waktusolat/templates/configmap.yaml index 171c2f7e..b18a89f2 100644 --- a/mika/waktusolat/templates/configmap.yaml +++ b/mika/waktusolat/templates/configmap.yaml @@ -34,29 +34,7 @@ metadata: {{- include "waktusolat.labels" . | nindent 4 }} data: site-config.conf: |- - - {{ "ServerName $domain:443" | replace "$domain" $domain }} - UseCanonicalName On - ServerAdmin support@mikahomelab.com - DocumentRoot /base - WSGIScriptAlias / /base/base/wsgi.py - {{ "WSGIDaemonProcess $domain python-path=/base" | replace "$domain" $domain }} - {{ "WSGIProcessGroup $domain" | replace "$domain" $domain }} - - - - Require all granted - - - - Alias /static /static - - Require all granted - - - ErrorLog /var/log/apache2/apache.error.log - CustomLog /var/log/apache2/apache.access.log combined - + {{- include "waktusolat.site-config-conf" . | replace "DOMAIN" $domain | nindent 4 }} {{- if $apscheduler }} --- apiVersion: v1 From 9eb890c70de46342cbd35d5f2e3f50aff4d2e0bc Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 10:59:02 +0800 Subject: [PATCH 081/117] Change celery log level to warning --- mika/waktusolat/templates/_helpers.tpl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mika/waktusolat/templates/_helpers.tpl b/mika/waktusolat/templates/_helpers.tpl index 9049dd00..7833bd14 100644 --- a/mika/waktusolat/templates/_helpers.tpl +++ b/mika/waktusolat/templates/_helpers.tpl @@ -190,7 +190,7 @@ CELERYD_OPTS="--time-limit=300 --concurrency=8 --without-gossip --without-mingle # Set logging level #CELERYD_LOG_LEVEL="DEBUG" -CELERYD_LOG_LEVEL="INFO" +CELERYD_LOG_LEVEL="WARNING" # %n will be replaced with the first part of the nodename. #CELERYD_LOG_FILE="/var/log/celery/%n%I.log" @@ -327,7 +327,7 @@ CELERY_BIN=${CELERY_BIN:-"celery"} DEFAULT_USER="celery" DEFAULT_PID_FILE="/var/run/celery/beat.pid" DEFAULT_LOG_FILE="/var/log/celery/beat.log" -DEFAULT_LOG_LEVEL="INFO" +DEFAULT_LOG_LEVEL="WARNING" DEFAULT_CELERYBEAT="$CELERY_BIN" CELERYBEAT=${CELERYBEAT:-$DEFAULT_CELERYBEAT} @@ -606,7 +606,7 @@ SCRIPT_NAME="$(basename "$SCRIPT_FILE")" DEFAULT_USER="celery" DEFAULT_PID_FILE="/var/run/celery/%n.pid" DEFAULT_LOG_FILE="/var/log/celery/%n%I.log" -DEFAULT_LOG_LEVEL="INFO" +DEFAULT_LOG_LEVEL="WARNING" DEFAULT_NODES="celery" DEFAULT_CELERYD="-m celery worker --detach" From 5e36df207fec5d210455485dc27d35283f433564 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 14:32:41 +0800 Subject: [PATCH 082/117] Update telego templates --- mika/telego/Chart.yaml | 20 ++-- mika/telego/templates/NOTES.txt | 6 +- mika/telego/templates/_helpers.tpl | 29 ++++++ mika/telego/templates/configmap.yaml | 67 +++++-------- mika/telego/templates/deployment.yaml | 131 +++++++------------------- mika/telego/templates/pvc.yaml | 7 +- mika/telego/templates/secret.yaml | 30 ++++-- 7 files changed, 129 insertions(+), 161 deletions(-) diff --git a/mika/telego/Chart.yaml b/mika/telego/Chart.yaml index 678c46e5..16529238 100644 --- a/mika/telego/Chart.yaml +++ b/mika/telego/Chart.yaml @@ -5,15 +5,15 @@ type: application version: 0.1.9 appVersion: "0.0.3-stable" keywords: - - Telego - - Telegram - - Bot -home: https://github.com/irfanhakim-as/telego -icon: https://irfanhakim-as.github.io/charts/logos/telego.png + - "Telego" + - "Telegram" + - "Bot" +home: "https://github.com/irfanhakim-as/telego" +icon: "https://irfanhakim-as.github.io/charts/logos/telego.png" sources: - - https://github.com/irfanhakim-as/telego - - https://irfanhakim-as.github.io/charts/mika/telego + - "https://github.com/irfanhakim-as/telego" + - "https://irfanhakim-as.github.io/charts/mika/telego" maintainers: - - name: Irfan Hakim - email: irfanhakim.as@yahoo.com - url: https://github.com/irfanhakim-as + - name: "Irfan Hakim" + email: "irfanhakim.as@yahoo.com" + url: "https://github.com/irfanhakim-as" diff --git a/mika/telego/templates/NOTES.txt b/mika/telego/templates/NOTES.txt index 534f8c81..f929226a 100644 --- a/mika/telego/templates/NOTES.txt +++ b/mika/telego/templates/NOTES.txt @@ -1 +1,5 @@ -Telego for {{ .Release.Name }} is now installed and configured. +Telego is now installed and configured for {{ .Release.Name | toString }}. + +See the values.yaml file of this chart for more configuration options. + +Please refer to the official documentation for more information on how to use Telego. diff --git a/mika/telego/templates/_helpers.tpl b/mika/telego/templates/_helpers.tpl index 5f664925..445df4ca 100644 --- a/mika/telego/templates/_helpers.tpl +++ b/mika/telego/templates/_helpers.tpl @@ -60,3 +60,32 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Apache site-config.conf template +*/}} +{{- define "telego.site-config-conf" -}} + + ServerName DOMAIN:443 + UseCanonicalName On + ServerAdmin support@domain.org + DocumentRoot /telego + WSGIScriptAlias / /telego/telego/wsgi.py + WSGIDaemonProcess DOMAIN python-path=/telego + WSGIProcessGroup DOMAIN + + + + Require all granted + + + + Alias /static /static + + Require all granted + + + ErrorLog /telego/logs/apache.error.log + CustomLog /telego/logs/apache.access.log combined + +{{- end }} diff --git a/mika/telego/templates/configmap.yaml b/mika/telego/templates/configmap.yaml index 9a69f2d0..aaff90a0 100644 --- a/mika/telego/templates/configmap.yaml +++ b/mika/telego/templates/configmap.yaml @@ -1,4 +1,11 @@ +{{- $name := .Values.telego.name | default "Telego" | toString | quote }} +{{- $debug := .Values.telego.debug | default "false" | toString | quote }} +{{- $webhook := .Values.telego.telegram.webhook | default "telegram/webhooks/" | toString | quote }} +{{- $redis_service := printf "redis://%s-telego-svc" .Release.Name | quote }} +{{- $celery_timezone := .Values.telego.celery_timezone | default "Asia/Kuala_Lumpur" | toString | quote }} {{- $domain := .Values.telego.cloudflared.domain | default "localhost" | toString }} +{{- $cloudflared := .Values.telego.cloudflared.enabled }} +{{- $ngrok := .Values.telego.ngrok.enabled }} apiVersion: v1 kind: ConfigMap metadata: @@ -6,16 +13,26 @@ metadata: labels: {{- include "telego.labels" . | nindent 4 }} data: - APP_NAME: {{ .Values.telego.name | toString | quote }} - DEBUG: {{ .Values.telego.debug | toString | quote }} - DJANGO_WEBHOOK_URI: {{ .Values.telego.webhook | toString | quote }} - CELERY_BROKER: redis://{{ .Release.Name }}-telego-svc - CELERY_BACKEND: redis://{{ .Release.Name }}-telego-svc - CELERY_TIMEZONE: {{ .Values.telego.celery_timezone | toString | quote }} - NGROK: {{ .Values.telego.ngrok.enabled | toString | quote }} - {{- if .Values.telego.cloudflared.enabled }} - DOMAIN: {{ .Values.telego.cloudflared.domain | toString | quote }} + APP_NAME: {{ $name }} + DEBUG: {{ $debug }} + DJANGO_WEBHOOK_URI: {{ $webhook }} + CELERY_BROKER: {{ $redis_service }} + CELERY_BACKEND: {{ $redis_service }} + CELERY_TIMEZONE: {{ $celery_timezone }} + NGROK: {{ $ngrok | default "true" | toString | quote }} + {{- if $cloudflared }} + DOMAIN: {{ $domain }} {{- end }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-telego-site-config + labels: + {{- include "telego.labels" . | nindent 4 }} +data: + site-config.conf: |- + {{- include "telego.site-config-conf" . | replace "DOMAIN" $domain | nindent 4 }} {{- if .Values.telego.commands }} --- apiVersion: v1 @@ -40,35 +57,3 @@ data: messages.py: |- {{ .Values.telego.messages | toString | nindent 4 | trim }} {{- end }} ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ .Release.Name }}-telego-site-config - labels: - {{- include "telego.labels" . | nindent 4 }} -data: - site-config.conf: |- - - {{ "ServerName $domain:443" | replace "$domain" $domain }} - UseCanonicalName On - ServerAdmin support@domain.org - DocumentRoot /telego - WSGIScriptAlias / /telego/telego/wsgi.py - {{ "WSGIDaemonProcess $domain python-path=/telego" | replace "$domain" $domain }} - {{ "WSGIProcessGroup $domain" | replace "$domain" $domain }} - - - - Require all granted - - - - Alias /static /static - - Require all granted - - - ErrorLog /telego/logs/apache.error.log - CustomLog /telego/logs/apache.access.log combined - diff --git a/mika/telego/templates/deployment.yaml b/mika/telego/templates/deployment.yaml index 6084634d..e5f36dc4 100644 --- a/mika/telego/templates/deployment.yaml +++ b/mika/telego/templates/deployment.yaml @@ -1,3 +1,17 @@ +{{- $replica_count := .Values.replicaCount | default "1" | toString }} +{{- $telego_registry := .Values.image.telego.registry | default "ghcr.io" | toString }} +{{- $telego_repository := .Values.image.telego.repository | default "irfanhakim-as/telego" | toString }} +{{- $telego_tag := .Values.image.telego.tag | default .Chart.AppVersion | toString }} +{{- $telego_pullPolicy := .Values.image.telego.pullPolicy | default "IfNotPresent" | toString | quote }} +{{- $redis_registry := .Values.image.redis.registry | default "docker.io" | toString }} +{{- $redis_repository := .Values.image.redis.repository | default "redis" | toString }} +{{- $redis_tag := .Values.image.redis.tag | default "alpine" | toString }} +{{- $redis_pullPolicy := .Values.image.redis.pullPolicy | default "IfNotPresent" | toString | quote }} +{{- $ngrok_registry := .Values.image.ngrok.registry | default "docker.io" | toString }} +{{- $ngrok_repository := .Values.image.ngrok.repository | default "wernight/ngrok" | toString }} +{{- $ngrok_tag := .Values.image.ngrok.tag | default "latest" | toString }} +{{- $ngrok_pullPolicy := .Values.image.ngrok.pullPolicy | default "IfNotPresent" | toString | quote }} +{{- $cloudflared := .Values.telego.cloudflared.enabled }} apiVersion: apps/v1 kind: Deployment metadata: @@ -5,7 +19,7 @@ metadata: labels: {{- include "telego.labels" . | nindent 4 }} spec: - replicas: {{ .Values.replicaCount | default 1 }} + replicas: {{ int $replica_count }} selector: matchLabels: {{- include "telego.selectorLabels" . | nindent 6 }} @@ -25,109 +39,36 @@ spec: {{- end }} containers: - name: telego - image: "{{ .Values.image.telego.registry }}/{{ .Values.image.telego.repository }}:{{ .Values.image.telego.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.telego.pullPolicy }} + image: {{ printf "%s/%s:%s" $telego_registry $telego_repository $telego_tag | quote }} + imagePullPolicy: {{ $telego_pullPolicy }} ports: - name: telego containerPort: 80 protocol: TCP resources: {{- toYaml .Values.resources.telego | nindent 12 }} + {{- if $cloudflared }} env: - - name: APP_NAME - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-telego-cm - key: APP_NAME - - name: DB_HOST - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-telego-database-secret - key: DB_HOST - - name: DB_PORT - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-telego-database-secret - key: DB_PORT - - name: DB_TYPE - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-telego-database-secret - key: DB_TYPE - - name: DB_NAME - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-telego-database-secret - key: DB_NAME - - name: DB_USER - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-telego-database-secret - key: DB_USER - - name: DB_PASS - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-telego-database-secret - key: DB_PASS - - name: DEBUG - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-telego-cm - key: DEBUG - - name: SECRET_KEY - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-telego-secret - key: SECRET_KEY - - name: TELEGRAM_BOT_TOKEN - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-telego-secret - key: TELEGRAM_BOT_TOKEN - {{- if .Values.telego.ngrok.enabled }} - - name: NGROK_AUTH_TOKEN - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-telego-secret - key: NGROK_AUTH_TOKEN - {{- end }} - - name: DJANGO_WEBHOOK_URI - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-telego-cm - key: DJANGO_WEBHOOK_URI - - name: NGROK - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-telego-cm - key: NGROK - - name: CELERY_BROKER - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-telego-cm - key: CELERY_BROKER - - name: CELERY_BACKEND - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-telego-cm - key: CELERY_BACKEND - - name: CELERY_TIMEZONE - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-telego-cm - key: CELERY_TIMEZONE - {{- if .Values.telego.cloudflared.enabled }} - name: ALLOWED_HOSTS valueFrom: configMapKeyRef: name: {{ .Release.Name }}-telego-cm key: DOMAIN - {{- end }} + {{- end }} + envFrom: + - configMapRef: + name: {{ .Release.Name }}-telego-cm + - secretRef: + name: {{ .Release.Name }}-telego-secret + - secretRef: + name: {{ .Release.Name }}-telego-database-secret volumeMounts: - name: {{ .Release.Name }}-telego-site-config mountPath: /etc/apache2/sites-available/000-default.conf subPath: site-config.conf readOnly: true + - name: {{ .Release.Name }}-telego-logs + mountPath: /telego/logs {{- if .Values.telego.commands }} - name: {{ .Release.Name }}-telego-commands-cm mountPath: /telego/telego/commands.py @@ -140,11 +81,9 @@ spec: subPath: messages.py readOnly: true {{- end }} - - name: {{ .Release.Name }}-telego-logs - mountPath: /telego/logs - name: redis - image: "{{ .Values.image.redis.registry }}/{{ .Values.image.redis.repository }}:{{ .Values.image.redis.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.redis.pullPolicy }} + image: {{ printf "%s/%s:%s" $redis_registry $redis_repository $redis_tag | quote }} + imagePullPolicy: {{ $redis_pullPolicy }} ports: - name: redis containerPort: 6379 @@ -153,8 +92,8 @@ spec: {{- toYaml .Values.resources.redis | nindent 12 }} {{- if .Values.telego.ngrok.enabled }} - name: ngrok - image: "{{ .Values.image.ngrok.registry }}/{{ .Values.image.ngrok.repository }}:{{ .Values.image.ngrok.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.ngrok.pullPolicy }} + image: {{ printf "%s/%s:%s" $ngrok_registry $ngrok_repository $ngrok_tag | quote }} + imagePullPolicy: {{ $ngrok_pullPolicy }} command: ["/bin/sh"] args: - -c @@ -176,6 +115,9 @@ spec: - name: {{ .Release.Name }}-telego-site-config configMap: name: {{ .Release.Name }}-telego-site-config + - name: {{ .Release.Name }}-telego-logs + persistentVolumeClaim: + claimName: {{ .Release.Name }}-telego-logs-pvc {{- if .Values.telego.commands }} - name: {{ .Release.Name }}-telego-commands-cm configMap: @@ -186,6 +128,3 @@ spec: configMap: name: {{ .Release.Name }}-telego-messages-cm {{- end }} - - name: {{ .Release.Name }}-telego-logs - persistentVolumeClaim: - claimName: {{ .Release.Name }}-telego-logs-pvc diff --git a/mika/telego/templates/pvc.yaml b/mika/telego/templates/pvc.yaml index ec817267..2079906a 100644 --- a/mika/telego/templates/pvc.yaml +++ b/mika/telego/templates/pvc.yaml @@ -1,4 +1,5 @@ -# helm pvc +{{- $storage := .Values.pvc.logs.storage | default "10Mi" | toString | quote }} +{{- $storage_class_name := .Values.pvc.logs.storageClassName | default "longhorn" | toString | quote }} apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -10,5 +11,5 @@ spec: - ReadWriteMany resources: requests: - storage: {{ .Values.pvc.logs.storage }} - storageClassName: {{ .Values.pvc.logs.storageClassName }} + storage: {{ $storage }} + storageClassName: {{ $storage_class_name }} diff --git a/mika/telego/templates/secret.yaml b/mika/telego/templates/secret.yaml index 359329b8..05d95013 100644 --- a/mika/telego/templates/secret.yaml +++ b/mika/telego/templates/secret.yaml @@ -1,3 +1,13 @@ +{{- $secret := .Values.telego.secret | toString | b64enc }} +{{- $telegram_token := .Values.telego.telegram.token | toString | b64enc }} +{{- $ngrok_token := .Values.telego.ngrok.token | toString | b64enc }} +{{- $db_type := .Values.db.type | default "postgresql" | toString | b64enc }} +{{- $db_name := .Values.db.name | toString | b64enc }} +{{- $db_user := .Values.db.user | toString | b64enc }} +{{- $db_password := .Values.db.password | toString | b64enc }} +{{- $db_host := .Values.db.host | toString | b64enc }} +{{- $db_port := .Values.db.port | default "5432" | toString | b64enc }} +{{- $ngrok := .Values.telego.ngrok.enabled }} apiVersion: v1 kind: Secret metadata: @@ -6,10 +16,10 @@ metadata: {{- include "telego.labels" . | nindent 4 }} type: Opaque data: - SECRET_KEY: {{ .Values.telego.secret | toString | b64enc }} - TELEGRAM_BOT_TOKEN: {{ .Values.telego.telegram.token | toString | b64enc }} - {{- if .Values.telego.ngrok.enabled }} - NGROK_AUTH_TOKEN: {{ .Values.telego.ngrok.token | toString | b64enc }} + SECRET_KEY: {{ $secret }} + TELEGRAM_BOT_TOKEN: {{ $telegram_token }} + {{- if $ngrok }} + NGROK_AUTH_TOKEN: {{ $ngrok_token }} {{- end }} --- apiVersion: v1 @@ -20,9 +30,9 @@ metadata: {{- include "telego.labels" . | nindent 4 }} type: Opaque data: - DB_TYPE: {{ .Values.db.type | toString | b64enc }} - DB_USER: {{ .Values.db.user | toString | b64enc }} - DB_PASS: {{ .Values.db.password | toString | b64enc }} - DB_HOST: {{ .Values.db.host | toString | b64enc }} - DB_PORT: {{ .Values.db.port | toString | b64enc }} - DB_NAME: {{ .Values.db.name | toString | b64enc }} + DB_TYPE: {{ $db_type }} + DB_USER: {{ $db_user }} + DB_PASS: {{ $db_password }} + DB_HOST: {{ $db_host }} + DB_PORT: {{ $db_port }} + DB_NAME: {{ $db_name }} From ec84f078c34f9013ede4f51352e148e6659e83a9 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 15:19:02 +0800 Subject: [PATCH 083/117] Remove default value for ngrok --- mika/telego/templates/configmap.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mika/telego/templates/configmap.yaml b/mika/telego/templates/configmap.yaml index aaff90a0..a6f69a18 100644 --- a/mika/telego/templates/configmap.yaml +++ b/mika/telego/templates/configmap.yaml @@ -19,7 +19,7 @@ data: CELERY_BROKER: {{ $redis_service }} CELERY_BACKEND: {{ $redis_service }} CELERY_TIMEZONE: {{ $celery_timezone }} - NGROK: {{ $ngrok | default "true" | toString | quote }} + NGROK: {{ $ngrok | toString | quote }} {{- if $cloudflared }} DOMAIN: {{ $domain }} {{- end }} From a5d6d4a1faa03e56060ae4e33a356b14ab8fbccd Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 15:19:11 +0800 Subject: [PATCH 084/117] Update values and make log persistence optional --- mika/telego/templates/pvc.yaml | 7 +- mika/telego/values.yaml | 230 ++++++++++++++++++++++++++------- 2 files changed, 187 insertions(+), 50 deletions(-) diff --git a/mika/telego/templates/pvc.yaml b/mika/telego/templates/pvc.yaml index 2079906a..e6274d35 100644 --- a/mika/telego/templates/pvc.yaml +++ b/mika/telego/templates/pvc.yaml @@ -1,5 +1,7 @@ -{{- $storage := .Values.pvc.logs.storage | default "10Mi" | toString | quote }} -{{- $storage_class_name := .Values.pvc.logs.storageClassName | default "longhorn" | toString | quote }} +{{- $storage := .Values.telego.persistence.storage | default "10Mi" | toString | quote }} +{{- $storage_class_name := .Values.telego.persistence.storageClassName | default "longhorn" | toString | quote }} +{{- $persistence := .Values.telego.persistence.enabled }} +{{- if $persistence }} apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -13,3 +15,4 @@ spec: requests: storage: {{ $storage }} storageClassName: {{ $storage_class_name }} +{{- end }} diff --git a/mika/telego/values.yaml b/mika/telego/values.yaml index 1a9115dc..e9cb591c 100644 --- a/mika/telego/values.yaml +++ b/mika/telego/values.yaml @@ -2,72 +2,206 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -replicaCount: 1 +# The desired number of running replicas for Telego. +# Default: "1" +replicaCount: "" +# Container images used for Telego. image: + # Telego container image configurations. telego: - registry: ghcr.io - repository: irfanhakim-as/telego + # The registry where the Telego container image is hosted. + # Default: "ghcr.io" + registry: "" + # The name of the repository that contains the Telego container image used. + # Default: "irfanhakim-as/telego" + repository: "" + # The tag that specifies the version of the Telego container image used. + # Default: Chart appVersion tag: "" - pullPolicy: IfNotPresent - + # The policy that determines when Kubernetes should pull the Telego container image. + # Default: "IfNotPresent" + pullPolicy: "" + # Redis container image configurations. redis: - registry: docker.io - repository: redis - tag: "alpine" - pullPolicy: IfNotPresent - - ngrok: - registry: docker.io - repository: wernight/ngrok - tag: "latest" - pullPolicy: IfNotPresent + # The registry where the Redis container image is hosted. + # Default: "docker.io" + registry: "" + # The name of the repository that contains the Redis container image used. + # Default: "redis" + repository: "" + # The tag that specifies the version of the Redis container image used. + # Default: "alpine" + tag: "" + # The policy that determines when Kubernetes should pull the Redis container image. + # Default: "IfNotPresent" + pullPolicy: "" + # Ngrok container image configurations. + redis: + # The registry where the Ngrok container image is hosted. + # Default: "docker.io" + registry: "" + # The name of the repository that contains the Ngrok container image used. + # Default: "wernight/ngrok" + repository: "" + # The tag that specifies the version of the Ngrok container image used. + # Default: "latest" + tag: "" + # The policy that determines when Kubernetes should pull the Ngrok container image. + # Default: "IfNotPresent" + pullPolicy: "" -imagePullSecrets: - - name: ghcr-token-secret # name of the secret containing the token to access the telego image +# Credentials used to securely authenticate and authorise the pulling of container images from private registries. +# Example: +# imagePullSecrets: +# - name: "ghcr-token-secret" +imagePullSecrets: [] +# Telego configurations. telego: - name: "Telego" # telego name - debug: false # django debug mode - secret: "" # django secret key - celery_timezone: "Asia/Kuala_Lumpur" # scheduler timezone + # The name of the Telego service. + # Default: "Telego" + # Example: + # name: "Telego" + name: "" + # Specifies whether Telego should run in debug mode. + # Default: false + # Example: + # debug: true + debug: "" + # A 50-character secret key used for secure session management and cryptographic operations within the Telego service. + # Example: + # secret: "6&p4%t)-$8a14fmfh92py8j55+us51r6%e52dzy&=a3-6yd4#e" + secret: "" + # The timezone for the task scheduler used by Telego to schedule time-dependent operations. + # Default: "Asia/Kuala_Lumpur" + # Example: + # timezone: "Asia/Kuala_Lumpur" + celery_timezone: "" + # Telego Telegram configurations. telegram: - token: "" # telegram bot token - webhook: "telegram/webhooks/" # telegram webhook path + # The Telegram bot token used by Telego to communicate with Telegram. + # Example: + # token: "1282813559:RrqoFIuWZwNfMLrx3Jd2mdFJnxrMObgQEvz" + token: "" + # The Telegram bot webhook path used by Telego to communicate with Telegram. + # Default: "telegram/webhooks/" + # Example: + # webhook: "bot/jbbhb73f6s/" + webhook: "telegram/webhooks/" + # Telego log persistence configurations. + persistence: + # Specifies whether Telego should persist its logs. + # Example: + # enabled: true + enabled: false + # The amount of persistent storage allocated for Telego logs. + # Default: "10Mi" + # Example: + # storage: "1Gi" + storage: "" + # The storage class name used for dynamically provisioning a persistent volume for the Telego logs storage. + # Default: "longhorn" + # Example: + # storageClassName: "longhorn" + storageClassName: "" + # Telego Ngrok configurations. ngrok: - enabled: true # enable ngrok - token: "" # ngrok auth token + # Specifies whether Telego should run using Ngrok. + # Example: + # enabled: true + enabled: false + # Ngrok authentication token. + # Example: + # token: "s7Ed4IO23nw1HWRJwumSgcyB7BtcXr4ZYLtziJCDDLIVDv7uq" + token: "" + # Telego Cloudflare configurations. cloudflared: - enabled: false # enable cloudflared - domain: "" # cloudflared domain - commands: "" # custom telegram commands.py file - messages: "" # custom telegram messages.py file + # Specifies whether Telego should run using Cloudflare. + # Example: + # enabled: true + enabled: false + # Cloudflare domain name used for Telego. + # Example: + # domain: "telego.example.com" + domain: "" + # Custom Telegram commands.py file for Telego. + commands: "" + # Custom Telegram messages.py file for Telego. + messages: "" +# Database configurations. db: - type: "postgresql" # database type - host: "postgres.default.svc.cluster.local" # database server - port: "5432" # database port - name: "" # database name - user: "" # database user - password: "" # database user password - -pvc: - logs: - storage: "10Mi" # log files storage size - storageClassName: "longhorn" # log files storage class name + # The type of the database used by Telego. + # Default: "postgresql" + # Example: + # type: "postgresql" + type: "" + # The name of the database used by Telego. + # Example: + # name: "telego" + name: "" + # The username or user account for accessing the Telego database. + # Example: + # user: "root" + user: "" + # The password associated with the Telego database's user. + # Example: + # password: "password" + password: "" + # The hostname or IP address of the Telego database server. + # Example: + # host: "telego.default.svc.cluster.local" + host: "" + # The port number on which the Telego database server is listening. + # Default: "5432" + # Example: + # port: "5432" + port: "" +# Resource requirements and limits for Telego containers. resources: + # Telego container resources. telego: + # The minimum amount of resources required by Telego to run. requests: - cpu: "10m" # telego cpu request - memory: "250Mi" # telego memory request + # The minimum amount of CPU resources required by Telego. + # Example: + # cpu: "20m" + cpu: "10m" + # The minimum amount of memory required by Telego. + # Example: + # memory: "250Mi" + memory: "250Mi" + # The maximum amount of resources allowed for Telego. limits: - cpu: "50m" # telego cpu limit - memory: "500Mi" # telego memory limit + # The maximum amount of CPU resources allowed for Telego. + # Example: + # cpu: "50m" + cpu: "50m" + # The maximum amount of memory allowed for Telego. + # Example: + # memory: "450Mi" + memory: "500Mi" + # Redis container resources. redis: + # The minimum amount of resources required by Redis to run. requests: - cpu: "5m" # redis cpu request - memory: "30Mi" # redis memory request + # The minimum amount of CPU resources required by Redis. + # Example: + # cpu: "5m" + cpu: "5m" + # The minimum amount of memory required by Redis. + # Example: + # memory: "30Mi" + memory: "30Mi" + # The maximum amount of resources allowed for Redis. limits: - cpu: "15m" # redis cpu limit - memory: "60Mi" # redis memory limit + # The maximum amount of CPU resources allowed for Redis. + # Example: + # cpu: "15m" + cpu: "15m" + # The maximum amount of memory allowed for Redis. + # Example: + # memory: "50Mi" + memory: "60Mi" From babfdababc33ba74037fd3c92188515894a25fd9 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 17:51:20 +0800 Subject: [PATCH 085/117] Remove placeholder value --- mika/telego/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mika/telego/values.yaml b/mika/telego/values.yaml index e9cb591c..f7ce7280 100644 --- a/mika/telego/values.yaml +++ b/mika/telego/values.yaml @@ -88,7 +88,7 @@ telego: # Default: "telegram/webhooks/" # Example: # webhook: "bot/jbbhb73f6s/" - webhook: "telegram/webhooks/" + webhook: "" # Telego log persistence configurations. persistence: # Specifies whether Telego should persist its logs. From d57c75f0a903b5b55c2359cbd020ed4720718584 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 18:16:16 +0800 Subject: [PATCH 086/117] Update wrong image config in values --- mika/telego/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mika/telego/values.yaml b/mika/telego/values.yaml index f7ce7280..3df367bc 100644 --- a/mika/telego/values.yaml +++ b/mika/telego/values.yaml @@ -37,7 +37,7 @@ image: # Default: "IfNotPresent" pullPolicy: "" # Ngrok container image configurations. - redis: + ngrok: # The registry where the Ngrok container image is hosted. # Default: "docker.io" registry: "" From a53a58a7fdcbb7b1972d6c8bf13a1b2562694db2 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 18:27:41 +0800 Subject: [PATCH 087/117] Update value descriptions --- mika/telego/values.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mika/telego/values.yaml b/mika/telego/values.yaml index 3df367bc..bf895dd3 100644 --- a/mika/telego/values.yaml +++ b/mika/telego/values.yaml @@ -107,7 +107,7 @@ telego: storageClassName: "" # Telego Ngrok configurations. ngrok: - # Specifies whether Telego should run using Ngrok. + # Specifies whether Telego should run using an Ngrok tunnel. # Example: # enabled: true enabled: false @@ -117,11 +117,11 @@ telego: token: "" # Telego Cloudflare configurations. cloudflared: - # Specifies whether Telego should run using Cloudflare. + # Specifies whether Telego should run using a Cloudflare tunnel. # Example: # enabled: true enabled: false - # Cloudflare domain name used for Telego. + # Registered domain name on Cloudflare used for Telego. # Example: # domain: "telego.example.com" domain: "" From f5326488901698ec0d5b2dd2c187bc419e6da234 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Fri, 16 Jun 2023 18:27:51 +0800 Subject: [PATCH 088/117] Update chart doc --- mika/telego/README.md | 195 +++++++++++++++++++++--------------------- 1 file changed, 96 insertions(+), 99 deletions(-) diff --git a/mika/telego/README.md b/mika/telego/README.md index bd8a41ac..4c471578 100644 --- a/mika/telego/README.md +++ b/mika/telego/README.md @@ -15,7 +15,7 @@ Replace `$github-username`, `$github-pass`, `$github-email` and `$namespace` acc kubectl create secret docker-registry ghcr-token-secret --docker-server=https://ghcr.io --docker-username="$github-username" --docker-password="$github-pass" --docker-email="$github-email" -n $namespace ``` -### Generate secret key for [`secret.telego.SECRET_KEY`](values.yaml) +### Generate secret key for [`telego.secret`](values.yaml) ```sh python -c 'import random; print("".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)]))' @@ -49,7 +49,7 @@ Copy `values.yaml` from the chart you would like to install. cp mika/telego/values.yaml . ``` -Edit `values.yaml` with the appropriate values. Refer to the [Configuration](#Configuration) section for the available options. +Edit `values.yaml` with the appropriate values. Refer to the [Configurations](#Configurations) section for the available options. ```sh nano values.yaml @@ -74,10 +74,6 @@ helm ls --namespace $namespace | grep "$release_name" To implement additional Telegram commands, create a custom `commands.py` file with a `Commands` class inheriting from `telego.methods.BaseCommand`. ```python -""" -Commands repository for the telego project. -Telegram commands for the telego module should be placed and called from here. -""" from telego.methods import ( BaseCommand, gen_inline_keyboard, @@ -98,81 +94,81 @@ class Commands(BaseCommand): # add command details self.commands.update({ - 'test': { - 'description': 'simple debug command returning your input', - 'emoji': '🤵‍♂️', - 'method': self.test, + "test" : { + "description" : "simple debug command returning your input", + "emoji" : "🤵‍♂️", + "method" : self.test, + "admin" : True, }, - 'menu': { - 'description': 'returns a menu of command prompts to choose from', - 'emoji': '🔮', - 'method': self.menu, + "menu" : { + "description" : "returns a menu of command prompts to choose from", + "emoji" : "🔮", + "method" : self.menu, }, }) # add command methods def test(self, **kwargs): - msg = None - inline_keyboard = None - sender = kwargs.get('sender') - first_name = kwargs.get('first_name') - command = kwargs.get('command') - param = kwargs.get('param') - - msg = message('TEST_COMMAND', chat_id=sender, first_name=first_name, command=command, param=param) - return msg,inline_keyboard + user = kwargs.get("user") + command = kwargs.get("command") + command_obj = self.commands.get(command) + param = kwargs.get("param") + + if param and (param.lower() == "help" or param.lower() == "?"): + msg = message("TEST_HELP", emoji=command_obj.get("emoji"), command=command) + else: + msg = message("TEST_COMMAND", emoji=command_obj.get("emoji"), chat_id=user.chat_id, first_name=user.first_name, command=command, param=param) + return msg, inline_keyboard def menu(self, **kwargs): - msg = None - inline_keyboard = None - command_dict = {} - - for command in self.commands.keys(): - emoji = self.commands.get(command).get('emoji') - command_dict[command] = '%s %s' % (emoji, command.title()) - msg=message('MENU_COMMAND') - inline_keyboard=gen_inline_keyboard(command_dict) - return msg,inline_keyboard + command_prompts = dict() + user = kwargs.get("user") + command = kwargs.get("command") + commands = self.commands + command_obj = commands.get(command) + + for key, command_dict in commands.items(): + emoji = command_dict.get("emoji") + if not command_dict.get("admin") or is_admin(user): + command_prompts[key] = "%s %s" % (emoji, key.title()) + + msg = message("MENU_COMMAND", emoji=command_obj.get("emoji")) + inline_keyboard = gen_inline_keyboard(command_prompts) + return msg, inline_keyboard ``` To add additional Telegram messages, create a custom `messages.py` file with both `messages` and `icons` dict. ```python -""" -Messages for the telego project. -Messages for the telego module should be placed and called from here. -""" - - # messages dict messages = { - "TEST_COMMAND" : '🤵‍♂️ Chat ID: {chat_id}' \ - '\n📛 First name: {first_name}' \ - '\n🎤 Command: {command}' \ - '\n💬 Param: {param}', - "MENU_COMMAND" : '🔮 Please select a command', + "TEST_COMMAND" : "{emoji} Chat ID: {chat_id}" \ + "\n📛 First name: {first_name}" \ + "\n🎤 Command: {command}" \ + "\n💬 Param: {param}", + "TEST_HELP" : "{emoji} `{command}`" \ + "\n• Submit the command '`{command}`' as is to receive a simple response from the bot" \ + "\n• Option: Add whatever message after the command to verify that the bot receives your message correctly" \ + "\n• Example: '`{command} abc 123`' to test if the bot receives '`abc 123`' as a parameter correctly", + "MENU_COMMAND" : "{emoji} Please select a command", } # icons dict icons = { - 'OK' : '✅', - 'ATTENTION' : '🛎', - 'USER' : '🙋🏻‍♂️', - 'EXPIRE' : '⌛️', - 'ACTIVE' : '⏳', - 'WARNING' : '⚠️', - 'DELETE' : '🗑', - 'TOKEN' : '🔐', - 'KEY' : '🔑', - 'GLOBE' : '🌐', - 'APP' : '🧑🏼‍💻', + "MENU" : "crystal_ball", + "TEST" : "man_in_tuxedo", } ``` Upgrade (or install) the chart while adding the `commands.py` and `messages.py files with the `--set-file` flag. ```sh -helm upgrade $release_name mika/telego --namespace $namespace --create-namespace --values values.yaml --set-file configmap.telego.CUSTOM_COMMANDS=commands.py --set-file configmap.telego.CUSTOM_MESSAGES=messages.py --wait +helm upgrade --install $release_name mika/telego \ +--namespace $namespace \ +--values values.yaml \ +--set-file telego.commands=commands.py \ +--set-file telego.messages=messages.py \ +--wait ``` ## How to uninstall @@ -187,49 +183,50 @@ helm uninstall $release_name --namespace $namespace --wait Install [`mika/postgres-dropdb`](../postgres-dropdb/). -## Configuration +## Configurations | Key | Type | Default | Description | |-----|------|---------|-------------| -| db.host | string | `"postgres.default.svc.cluster.local"` | Database server | -| db.name | string | `""` | Database name | -| db.password | string | `""` | Database user password | -| db.port | string | `"5432"` | Database port | -| db.type | string | `"postgresql"` | Database type | -| db.user | string | `""` | Database user | -| image.ngrok.pullPolicy | string | `"IfNotPresent"` | Ngrok image pull policy | -| image.ngrok.registry | string | `"docker.io"` | Ngrok image registry | -| image.ngrok.repository | string | `"wernight/ngrok"` | Ngrok image repository | -| image.ngrok.tag | string | `"latest"` | Ngrok image version | -| image.redis.pullPolicy | string | `"IfNotPresent"` | Redis image pull policy | -| image.redis.registry | string | `"docker.io"` | Redis image registry | -| image.redis.repository | string | `"redis"` | Redis image repository | -| image.redis.tag | string | `"alpine"` | Redis image version | -| image.telego.pullPolicy | string | `"IfNotPresent"` | Telego image pull policy | -| image.telego.registry | string | `"ghcr.io"` | Telego image registry | -| image.telego.repository | string | `"irfanhakim-as/telego"` | Telego image repository | -| image.telego.tag | string | `""` | Telego image version | -| imagePullSecrets[0].name | string | `"ghcr-token-secret"` | Name of the image pull secret | -| pvc.logs.storage | string | `"10Mi"` | Log files storage size | -| pvc.logs.storageClassName | string | `"longhorn"` | Log files storage class name | -| replicaCount | int | `1` | Telego replica count | -| resources.redis.limits.cpu | string | `"15m"` | Redis maximum CPU allocation | -| resources.redis.limits.memory | string | `"60Mi"` | Redis maximum memory allocation | -| resources.redis.requests.cpu | string | `"5m"` | Redis minimum CPU allocation | -| resources.redis.requests.memory | string | `"30Mi"` | Redis minimum memory allocation | -| resources.telego.limits.cpu | string | `"50m"` | Telego maximum CPU allocation | -| resources.telego.limits.memory | string | `"500Mi"` | Telego maximum memory allocation | -| resources.telego.requests.cpu | string | `"10m"` | Telego minimum CPU allocation | -| resources.telego.requests.memory | string | `"250Mi"` | Telego minimum memory allocation | -| telego.celery_timezone | string | `"Asia/Kuala_Lumpur"` | Background scheduler timezone | -| telego.cloudflared.domain | string | `""` | Telego domain | -| telego.cloudflared.enabled | bool | `false` | Enable cloudflare tunnel | -| telego.commands | file | `""` | Custom `commands.py` file | -| telego.debug | bool | `false` | Enable debug mode | -| telego.messages | file | `""` | Custom `messages.py` file | -| telego.name | string | `"Telego"` | Telego application name | -| telego.ngrok.enabled | bool | `true` | Enable ngrok tunnel | -| telego.ngrok.token | string | `""` | Ngrok authentication token | -| telego.secret | string | `""` | Telego secret key | -| telego.telegram.token | string | `""` | Telegram bot token | -| telego.telegram.webhook | string | `"telegram/webhooks/"` | Telegram webhook path | +| db.host | string | `""` | The hostname or IP address of the Telego database server. | +| db.name | string | `""` | The name of the database used by Telego. | +| db.password | string | `""` | The password associated with the Telego database's user. | +| db.port | string | `""` | The port number on which the Telego database server is listening. Default: `"5432"`. | +| db.type | string | `""` | The type of the database used by Telego. Default: `"postgresql"`. | +| db.user | string | `""` | The username or user account for accessing the Telego database. | +| image.ngrok.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the Ngrok container image. Default: `"IfNotPresent"`. | +| image.ngrok.registry | string | `""` | The registry where the Ngrok container image is hosted. Default: `"docker.io"`. | +| image.ngrok.repository | string | `""` | The name of the repository that contains the Ngrok container image used. Default: `"wernight/ngrok"`. | +| image.ngrok.tag | string | `""` | The tag that specifies the version of the Ngrok container image used. Default: `"latest"`. | +| image.redis.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the Redis container image. Default: `"IfNotPresent"`. | +| image.redis.registry | string | `""` | The registry where the Redis container image is hosted. Default: `"docker.io"`. | +| image.redis.repository | string | `""` | The name of the repository that contains the Redis container image used. Default: `"redis"`. | +| image.redis.tag | string | `""` | The tag that specifies the version of the Redis container image used. Default: `"alpine"`. | +| image.telego.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the Telego container image. Default: `"IfNotPresent"`. | +| image.telego.registry | string | `""` | The registry where the Telego container image is hosted. Default: `"ghcr.io"`. | +| image.telego.repository | string | `""` | The name of the repository that contains the Telego container image used. Default: `"irfanhakim-as/telego"`. | +| image.telego.tag | string | `""` | The tag that specifies the version of the Telego container image used. Default: `"Chart appVersion"`. | +| imagePullSecrets | list | `[]` | Credentials used to securely authenticate and authorise the pulling of container images from private registries. | +| replicaCount | string | `""` | The desired number of running replicas for Telego. Default: `"1"`. | +| resources.redis.limits.cpu | string | `"15m"` | The maximum amount of CPU resources allowed for Redis. | +| resources.redis.limits.memory | string | `"60Mi"` | The maximum amount of memory allowed for Redis. | +| resources.redis.requests.cpu | string | `"5m"` | The minimum amount of CPU resources required by Redis. | +| resources.redis.requests.memory | string | `"30Mi"` | The minimum amount of memory required by Redis. | +| resources.telego.limits.cpu | string | `"50m"` | The maximum amount of CPU resources allowed for Telego. | +| resources.telego.limits.memory | string | `"500Mi"` | The maximum amount of memory allowed for Telego. | +| resources.telego.requests.cpu | string | `"10m"` | The minimum amount of CPU resources required by Telego. | +| resources.telego.requests.memory | string | `"250Mi"` | The minimum amount of memory required by Telego. | +| telego.celery_timezone | string | `""` | The timezone for the task scheduler used by Telego to schedule time-dependent operations. Default: `"Asia/Kuala_Lumpur"`. | +| telego.cloudflared.domain | string | `""` | Registered domain name on Cloudflare used for Telego. | +| telego.cloudflared.enabled | bool | `false` | Specifies whether Telego should run using a Cloudflare tunnel. | +| telego.commands | file | `""` | Custom Telegram `commands.py` file for Telego. | +| telego.debug | string | `""` | Specifies whether Telego should run in debug mode. Default: `false`. | +| telego.messages | file | `""` | Custom Telegram `messages.py` file for Telego. | +| telego.name | string | `""` | The name of the Telego service. Default: `"Telego"`. | +| telego.ngrok.enabled | bool | `false` | Specifies whether Telego should run using an Ngrok tunnel. | +| telego.ngrok.token | string | `""` | Ngrok authentication token. | +| telego.persistence.enabled | bool | `false` | Specifies whether Telego should persist its logs. | +| telego.persistence.storage | string | `""` | The amount of persistent storage allocated for Telego logs. Default: `"10Mi"`. | +| telego.persistence.storageClassName | string | `""` | The storage class name used for dynamically provisioning a persistent volume for the Telego logs storage. Default: `"longhorn"`. | +| telego.secret | string | `""` | A 50-character secret key used for secure session management and cryptographic operations within the Telego service. | +| telego.telegram.token | string | `""` | The Telegram bot token used by Telego to communicate with Telegram. | +| telego.telegram.webhook | string | `""` | The Telegram bot webhook path used by Telego to communicate with Telegram. | From 805f76076c9570fa387868a6007edc60de5919bf Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sat, 17 Jun 2023 12:05:41 +0800 Subject: [PATCH 089/117] Exclude pvc if persistence is disabled --- mika/telego/templates/deployment.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mika/telego/templates/deployment.yaml b/mika/telego/templates/deployment.yaml index e5f36dc4..77ec2cae 100644 --- a/mika/telego/templates/deployment.yaml +++ b/mika/telego/templates/deployment.yaml @@ -12,6 +12,7 @@ {{- $ngrok_tag := .Values.image.ngrok.tag | default "latest" | toString }} {{- $ngrok_pullPolicy := .Values.image.ngrok.pullPolicy | default "IfNotPresent" | toString | quote }} {{- $cloudflared := .Values.telego.cloudflared.enabled }} +{{- $persistence := .Values.telego.persistence.enabled }} apiVersion: apps/v1 kind: Deployment metadata: @@ -67,8 +68,10 @@ spec: mountPath: /etc/apache2/sites-available/000-default.conf subPath: site-config.conf readOnly: true + {{- if $persistence }} - name: {{ .Release.Name }}-telego-logs mountPath: /telego/logs + {{- end }} {{- if .Values.telego.commands }} - name: {{ .Release.Name }}-telego-commands-cm mountPath: /telego/telego/commands.py @@ -115,9 +118,11 @@ spec: - name: {{ .Release.Name }}-telego-site-config configMap: name: {{ .Release.Name }}-telego-site-config + {{- if $persistence }} - name: {{ .Release.Name }}-telego-logs persistentVolumeClaim: claimName: {{ .Release.Name }}-telego-logs-pvc + {{- end }} {{- if .Values.telego.commands }} - name: {{ .Release.Name }}-telego-commands-cm configMap: From f06487731570d2b02824a58468a0181c92021eed Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sat, 17 Jun 2023 12:28:00 +0800 Subject: [PATCH 090/117] Use variables instead of referencing values directly --- mika/telego/templates/configmap.yaml | 10 ++++++---- mika/telego/templates/deployment.yaml | 13 ++++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/mika/telego/templates/configmap.yaml b/mika/telego/templates/configmap.yaml index a6f69a18..448f0448 100644 --- a/mika/telego/templates/configmap.yaml +++ b/mika/telego/templates/configmap.yaml @@ -6,6 +6,8 @@ {{- $domain := .Values.telego.cloudflared.domain | default "localhost" | toString }} {{- $cloudflared := .Values.telego.cloudflared.enabled }} {{- $ngrok := .Values.telego.ngrok.enabled }} +{{- $commands := .Values.telego.commands }} +{{- $messages := .Values.telego.messages }} apiVersion: v1 kind: ConfigMap metadata: @@ -33,7 +35,7 @@ metadata: data: site-config.conf: |- {{- include "telego.site-config-conf" . | replace "DOMAIN" $domain | nindent 4 }} -{{- if .Values.telego.commands }} +{{- if $commands }} --- apiVersion: v1 kind: ConfigMap @@ -43,9 +45,9 @@ metadata: {{- include "telego.labels" . | nindent 4 }} data: commands.py: |- - {{ .Values.telego.commands | toString | nindent 4 | trim }} + {{ $commands | toString | nindent 4 | trim }} {{- end }} -{{- if .Values.telego.messages }} +{{- if $messages }} --- apiVersion: v1 kind: ConfigMap @@ -55,5 +57,5 @@ metadata: {{- include "telego.labels" . | nindent 4 }} data: messages.py: |- - {{ .Values.telego.messages | toString | nindent 4 | trim }} + {{ $messages | toString | nindent 4 | trim }} {{- end }} diff --git a/mika/telego/templates/deployment.yaml b/mika/telego/templates/deployment.yaml index 77ec2cae..4a6744e9 100644 --- a/mika/telego/templates/deployment.yaml +++ b/mika/telego/templates/deployment.yaml @@ -12,7 +12,10 @@ {{- $ngrok_tag := .Values.image.ngrok.tag | default "latest" | toString }} {{- $ngrok_pullPolicy := .Values.image.ngrok.pullPolicy | default "IfNotPresent" | toString | quote }} {{- $cloudflared := .Values.telego.cloudflared.enabled }} +{{- $ngrok := .Values.telego.ngrok.enabled }} {{- $persistence := .Values.telego.persistence.enabled }} +{{- $commands := .Values.telego.commands }} +{{- $messages := .Values.telego.messages }} apiVersion: apps/v1 kind: Deployment metadata: @@ -72,13 +75,13 @@ spec: - name: {{ .Release.Name }}-telego-logs mountPath: /telego/logs {{- end }} - {{- if .Values.telego.commands }} + {{- if $commands }} - name: {{ .Release.Name }}-telego-commands-cm mountPath: /telego/telego/commands.py subPath: commands.py readOnly: true {{- end }} - {{- if .Values.telego.messages }} + {{- if $messages }} - name: {{ .Release.Name }}-telego-messages-cm mountPath: /telego/telego/messages.py subPath: messages.py @@ -93,7 +96,7 @@ spec: protocol: TCP resources: {{- toYaml .Values.resources.redis | nindent 12 }} - {{- if .Values.telego.ngrok.enabled }} + {{- if $ngrok }} - name: ngrok image: {{ printf "%s/%s:%s" $ngrok_registry $ngrok_repository $ngrok_tag | quote }} imagePullPolicy: {{ $ngrok_pullPolicy }} @@ -123,12 +126,12 @@ spec: persistentVolumeClaim: claimName: {{ .Release.Name }}-telego-logs-pvc {{- end }} - {{- if .Values.telego.commands }} + {{- if $commands }} - name: {{ .Release.Name }}-telego-commands-cm configMap: name: {{ .Release.Name }}-telego-commands-cm {{- end }} - {{- if .Values.telego.messages }} + {{- if $messages }} - name: {{ .Release.Name }}-telego-messages-cm configMap: name: {{ .Release.Name }}-telego-messages-cm From 8f9b02712bcf6d987aeab57645640930d77ac35b Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sat, 17 Jun 2023 13:06:00 +0800 Subject: [PATCH 091/117] Update chart templates --- mika/vpbot/Chart.yaml | 22 +-- mika/vpbot/templates/NOTES.txt | 6 +- mika/vpbot/templates/_helpers.tpl | 34 ++++ mika/vpbot/templates/configmap.yaml | 58 ++---- mika/vpbot/templates/deployment.yaml | 154 ++++------------ mika/vpbot/templates/pvc.yaml | 20 +- mika/vpbot/templates/secret.yaml | 39 ++-- mika/vpbot/values.yaml | 263 +++++++++++++++++++++------ 8 files changed, 354 insertions(+), 242 deletions(-) diff --git a/mika/vpbot/Chart.yaml b/mika/vpbot/Chart.yaml index 6e540b5b..02ded2cb 100644 --- a/mika/vpbot/Chart.yaml +++ b/mika/vpbot/Chart.yaml @@ -5,16 +5,16 @@ type: application version: 0.2.1 appVersion: "1.5.6-stable" keywords: - - vpbot - - quarantine-bot - - telegram - - bot -home: https://github.com/irfanhakim-as/quarantine-bot -icon: https://irfanhakim-as.github.io/charts/logos/vpbot.png + - "vpbot" + - "quarantine-bot" + - "telegram" + - "bot" +home: "https://github.com/irfanhakim-as/quarantine-bot" +icon: "https://irfanhakim-as.github.io/charts/logos/vpbot.png" sources: - - https://github.com/irfanhakim-as/quarantine-bot - - https://irfanhakim-as.github.io/charts/mika/vpbot + - "https://github.com/irfanhakim-as/quarantine-bot" + - "https://irfanhakim-as.github.io/charts/mika/vpbot" maintainers: - - name: Irfan Hakim - email: irfanhakim.as@yahoo.com - url: https://github.com/irfanhakim-as + - name: "Irfan Hakim" + email: "irfanhakim.as@yahoo.com" + url: "https://github.com/irfanhakim-as" diff --git a/mika/vpbot/templates/NOTES.txt b/mika/vpbot/templates/NOTES.txt index 51c1b6da..a273b202 100644 --- a/mika/vpbot/templates/NOTES.txt +++ b/mika/vpbot/templates/NOTES.txt @@ -1 +1,5 @@ -Vpbot for {{ .Release.Name }} is now installed and configured. +Vpbot is now installed and configured for {{ .Release.Name | toString }}. + +See the values.yaml file of this chart for more configuration options. + +Please refer to the official documentation for more information on how to use Vpbot. diff --git a/mika/vpbot/templates/_helpers.tpl b/mika/vpbot/templates/_helpers.tpl index d50224b3..3ea9949c 100644 --- a/mika/vpbot/templates/_helpers.tpl +++ b/mika/vpbot/templates/_helpers.tpl @@ -60,3 +60,37 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Apache site-config.conf template +*/}} +{{- define "vpbot.site-config-conf" -}} + + ServerName DOMAIN:443 + UseCanonicalName On + ServerAdmin support@mikahomelab.com + DocumentRoot /quarantine-bot + WSGIScriptAlias / /quarantine-bot/quarantine_bot/wsgi.py + WSGIDaemonProcess DOMAIN python-path=/quarantine-bot + WSGIProcessGroup DOMAIN + + + + Require all granted + + + + Alias /static /static + + Require all granted + + + Alias /media /quarantine-bot/media + + Require all granted + + + ErrorLog /quarantine-bot/logs/apache.error.log + CustomLog /quarantine-bot/logs/apache.access.log combined + +{{- end }} diff --git a/mika/vpbot/templates/configmap.yaml b/mika/vpbot/templates/configmap.yaml index 2e016faf..a1d027dd 100644 --- a/mika/vpbot/templates/configmap.yaml +++ b/mika/vpbot/templates/configmap.yaml @@ -1,4 +1,13 @@ +{{- $name := .Values.vpbot.name | default "Vpbot" | toString | quote }} +{{- $debug := .Values.vpbot.debug | default "false" | toString | quote }} +{{- $redis_service := printf "redis://%s-vpbot-svc" .Release.Name | quote }} +{{- $celery_timezone := .Values.vpbot.celery_timezone | default "Asia/Kuala_Lumpur" | toString | quote }} +{{- $webhook := .Values.telegram.webhook | default "telegram/webhooks/" | toString | quote }} +{{- $log_size_limit := .Values.vpbot.log_size_limit | default "4" | toString | quote }} +{{- $app_version := .Values.image.vpbot.tag | default .Chart.AppVersion | toString | quote }} {{- $domain := .Values.vpbot.cloudflared.domain | default "localhost" | toString }} +{{- $cloudflared := .Values.vpbot.cloudflared.enabled }} +{{- $ngrok := .Values.vpbot.ngrok.enabled }} apiVersion: v1 kind: ConfigMap metadata: @@ -6,18 +15,18 @@ metadata: labels: {{- include "vpbot.labels" . | nindent 4 }} data: - APP_NAME: {{ .Values.vpbot.name | toString | quote }} - DEBUG: {{ .Values.vpbot.debug | toString | quote }} - CELERY_BROKER: redis://{{ .Release.Name }}-vpbot-svc - CELERY_BACKEND: redis://{{ .Release.Name }}-vpbot-svc - CELERY_TIMEZONE: {{ .Values.vpbot.celery_timezone | toString | quote }} - NGROK: {{ .Values.vpbot.ngrok.enabled | toString | quote }} - {{- if .Values.vpbot.cloudflared.enabled }} + APP_NAME: {{ $name }} + DEBUG: {{ $debug }} + CELERY_BROKER: {{ $redis_service }} + CELERY_BACKEND: {{ $redis_service }} + CELERY_TIMEZONE: {{ $celery_timezone }} + NGROK: {{ $ngrok | toString | quote }} + DJANGO_WEBHOOK_URI: {{ $webhook }} + LOG_SIZE_LIMIT: {{ $log_size_limit }} + APP_VERSION: {{ $app_version }} + {{- if $cloudflared }} DOMAIN: {{ $domain | quote }} {{- end }} - DJANGO_WEBHOOK_URI: {{ .Values.telegram.webhook | toString | quote }} - LOG_SIZE_LIMIT: {{ .Values.vpbot.log_size_limit | toString | quote }} - APP_VERSION: {{ .Values.image.vpbot.tag | default .Chart.AppVersion | toString | quote }} --- apiVersion: v1 kind: ConfigMap @@ -27,31 +36,4 @@ metadata: {{- include "vpbot.labels" . | nindent 4 }} data: site-config.conf: |- - - {{ "ServerName $domain:443" | replace "$domain" $domain }} - UseCanonicalName On - ServerAdmin support@mika-homelab.com - DocumentRoot /quarantine-bot - WSGIScriptAlias / /quarantine-bot/quarantine_bot/wsgi.py - {{ "WSGIDaemonProcess $domain python-path=/quarantine-bot" | replace "$domain" $domain }} - {{ "WSGIProcessGroup $domain" | replace "$domain" $domain }} - - - - Require all granted - - - - Alias /static /static - - Require all granted - - - Alias /media /quarantine-bot/media - - Require all granted - - - ErrorLog /quarantine-bot/logs/apache.error.log - CustomLog /quarantine-bot/logs/apache.access.log combined - + {{- include "vpbot.site-config-conf" . | replace "DOMAIN" $domain | nindent 4 }} diff --git a/mika/vpbot/templates/deployment.yaml b/mika/vpbot/templates/deployment.yaml index 122b0a67..b6c063a6 100644 --- a/mika/vpbot/templates/deployment.yaml +++ b/mika/vpbot/templates/deployment.yaml @@ -1,3 +1,19 @@ +{{- $replica_count := .Values.replicaCount | default "1" | toString }} +{{- $vpbot_registry := .Values.image.vpbot.registry | default "ghcr.io" | toString }} +{{- $vpbot_repository := .Values.image.vpbot.repository | default "irfanhakim-as/quarantine-bot" | toString }} +{{- $vpbot_tag := .Values.image.vpbot.tag | default .Chart.AppVersion | toString }} +{{- $vpbot_pullPolicy := .Values.image.vpbot.pullPolicy | default "IfNotPresent" | toString | quote }} +{{- $redis_registry := .Values.image.redis.registry | default "docker.io" | toString }} +{{- $redis_repository := .Values.image.redis.repository | default "redis" | toString }} +{{- $redis_tag := .Values.image.redis.tag | default "alpine" | toString }} +{{- $redis_pullPolicy := .Values.image.redis.pullPolicy | default "IfNotPresent" | toString | quote }} +{{- $ngrok_registry := .Values.image.ngrok.registry | default "docker.io" | toString }} +{{- $ngrok_repository := .Values.image.ngrok.repository | default "wernight/ngrok" | toString }} +{{- $ngrok_tag := .Values.image.ngrok.tag | default "latest" | toString }} +{{- $ngrok_pullPolicy := .Values.image.ngrok.pullPolicy | default "IfNotPresent" | toString | quote }} +{{- $cloudflared := .Values.vpbot.cloudflared.enabled }} +{{- $ngrok := .Values.vpbot.ngrok.enabled }} +{{- $persistence := .Values.vpbot.persistence.enabled }} apiVersion: apps/v1 kind: Deployment metadata: @@ -5,7 +21,7 @@ metadata: labels: {{- include "vpbot.labels" . | nindent 4 }} spec: - replicas: {{ .Values.replicaCount | default 1 }} + replicas: {{ int $replica_count }} selector: matchLabels: {{- include "vpbot.selectorLabels" . | nindent 6 }} @@ -24,153 +40,55 @@ spec: {{- end }} containers: - name: vpbot - image: "{{ .Values.image.vpbot.registry }}/{{ .Values.image.vpbot.repository }}:{{ .Values.image.vpbot.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.vpbot.pullPolicy }} + image: {{ printf "%s/%s:%s" $vpbot_registry $vpbot_repository $vpbot_tag | quote }} + imagePullPolicy: {{ $vpbot_pullPolicy }} ports: - name: vpbot containerPort: 80 protocol: TCP resources: {{- toYaml .Values.resources.vpbot | nindent 12 }} + {{- if $cloudflared }} env: - - name: SECRET_KEY - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-vpbot-secret - key: SECRET_KEY - - name: APP_NAME - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-vpbot-cm - key: APP_NAME - - name: DEBUG - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-vpbot-cm - key: DEBUG - - name: CELERY_BROKER - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-vpbot-cm - key: CELERY_BROKER - - name: CELERY_BACKEND - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-vpbot-cm - key: CELERY_BACKEND - - name: CELERY_TIMEZONE - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-vpbot-cm - key: CELERY_TIMEZONE - - name: NGROK - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-vpbot-cm - key: NGROK - {{- if .Values.vpbot.cloudflared.enabled }} - name: ALLOWED_HOSTS valueFrom: configMapKeyRef: name: {{ .Release.Name }}-vpbot-cm key: DOMAIN - {{- end }} - - name: DJANGO_WEBHOOK_URI - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-vpbot-cm - key: DJANGO_WEBHOOK_URI - - name: LOG_SIZE_LIMIT - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-vpbot-cm - key: LOG_SIZE_LIMIT - - name: APP_VERSION - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-vpbot-cm - key: APP_VERSION - - name: TELEGRAM_BOT_TOKEN - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-vpbot-secret - key: TELEGRAM_BOT_TOKEN - - name: TELEGRAM_ADMIN_ID - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-vpbot-secret - key: TELEGRAM_ADMIN_ID - - name: TELEGRAM_DEVEL_ID - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-vpbot-secret - key: TELEGRAM_DEVEL_ID - - name: DEFAULT_USER_PASS - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-vpbot-secret - key: DEFAULT_USER_PASS - {{- if .Values.vpbot.ngrok.enabled }} - - name: NGROK_AUTH_TOKEN - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-vpbot-secret - key: NGROK_AUTH_TOKEN - {{- end }} - - name: DB_HOST - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-vpbot-postgres-secret - key: DB_HOST - - name: DB_TYPE - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-vpbot-postgres-secret - key: DB_TYPE - - name: DB_PORT - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-vpbot-postgres-secret - key: DB_PORT - - name: DB_NAME - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-vpbot-postgres-secret - key: DB_NAME - - name: DB_USER - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-vpbot-postgres-secret - key: DB_USER - - name: DB_PASS - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-vpbot-postgres-secret - key: DB_PASS + {{- end }} + envFrom: + - configMapRef: + name: {{ .Release.Name }}-vpbot-cm + - secretRef: + name: {{ .Release.Name }}-vpbot-secret + - secretRef: + name: {{ .Release.Name }}-vpbot-postgres-secret volumeMounts: - name: {{ .Release.Name }}-vpbot-site-config mountPath: /etc/apache2/sites-available/000-default.conf subPath: site-config.conf readOnly: true + {{- if $persistence }} - name: {{ .Release.Name }}-vpbot-static mountPath: /static - name: {{ .Release.Name }}-vpbot-logs mountPath: /quarantine-bot/logs - name: {{ .Release.Name }}-vpbot-migrations mountPath: /quarantine-bot/quarantine_bot/migrations + {{- end }} - name: redis - image: "{{ .Values.image.redis.registry }}/{{ .Values.image.redis.repository }}:{{ .Values.image.redis.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.redis.pullPolicy }} + image: {{ printf "%s/%s:%s" $redis_registry $redis_repository $redis_tag | quote }} + imagePullPolicy: {{ $redis_pullPolicy }} ports: - name: redis containerPort: 6379 protocol: TCP resources: {{- toYaml .Values.resources.redis | nindent 12 }} - {{- if .Values.vpbot.ngrok.enabled }} + {{- if $ngrok }} - name: ngrok - image: "{{ .Values.image.ngrok.registry }}/{{ .Values.image.ngrok.repository }}:{{ .Values.image.ngrok.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.ngrok.pullPolicy }} + image: {{ printf "%s/%s:%s" $ngrok_registry $ngrok_repository $ngrok_tag | quote }} + imagePullPolicy: {{ $ngrok_pullPolicy }} command: ["/bin/sh"] args: - -c @@ -192,6 +110,7 @@ spec: - name: {{ .Release.Name }}-vpbot-site-config configMap: name: {{ .Release.Name }}-vpbot-site-config + {{- if $persistence }} - name: {{ .Release.Name }}-vpbot-static persistentVolumeClaim: claimName: {{ .Release.Name }}-vpbot-static-pvc @@ -201,3 +120,4 @@ spec: - name: {{ .Release.Name }}-vpbot-migrations persistentVolumeClaim: claimName: {{ .Release.Name }}-vpbot-migrations-pvc + {{- end }} diff --git a/mika/vpbot/templates/pvc.yaml b/mika/vpbot/templates/pvc.yaml index 2e9a8bff..ab6bb3e7 100644 --- a/mika/vpbot/templates/pvc.yaml +++ b/mika/vpbot/templates/pvc.yaml @@ -1,4 +1,9 @@ -# helm pvc +{{- $logs_storage := .Values.vpbot.persistence.logs.storage | default "50Mi" | toString | quote }} +{{- $static_storage := .Values.vpbot.persistence.static.storage | default "50Mi" | toString | quote }} +{{- $migrations_storage := .Values.vpbot.persistence.migrations.storage | default "50Mi" | toString | quote }} +{{- $storage_class_name := .Values.vpbot.persistence.storageClassName | default "longhorn" | toString | quote }} +{{- $persistence := .Values.vpbot.persistence.enabled }} +{{- if $persistence }} apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -10,8 +15,8 @@ spec: - ReadWriteMany resources: requests: - storage: {{ .Values.pvc.logs.storage }} - storageClassName: {{ .Values.pvc.logs.storageClassName }} + storage: {{ $logs_storage }} + storageClassName: {{ $storage_class_name }} --- apiVersion: v1 kind: PersistentVolumeClaim @@ -24,8 +29,8 @@ spec: - ReadWriteMany resources: requests: - storage: {{ .Values.pvc.static.storage }} - storageClassName: {{ .Values.pvc.static.storageClassName }} + storage: {{ $static_storage }} + storageClassName: {{ $storage_class_name }} --- apiVersion: v1 kind: PersistentVolumeClaim @@ -38,5 +43,6 @@ spec: - ReadWriteMany resources: requests: - storage: {{ .Values.pvc.migrations.storage }} - storageClassName: {{ .Values.pvc.migrations.storageClassName }} + storage: {{ $migrations_storage }} + storageClassName: {{ $storage_class_name }} +{{- end }} diff --git a/mika/vpbot/templates/secret.yaml b/mika/vpbot/templates/secret.yaml index ad68dd34..b0e53cb2 100644 --- a/mika/vpbot/templates/secret.yaml +++ b/mika/vpbot/templates/secret.yaml @@ -1,3 +1,16 @@ +{{- $secret := .Values.vpbot.secret | toString | b64enc }} +{{- $telegram_token := .Values.telegram.token | toString | b64enc }} +{{- $admin_id := .Values.telegram.admin_id | toString | b64enc }} +{{- $devel_id := .Values.telegram.devel_id | toString | b64enc }} +{{- $user_pass := .Values.vpbot.user_pass | toString | b64enc }} +{{- $ngrok_token := .Values.vpbot.ngrok.token | toString | b64enc }} +{{- $db_type := .Values.db.type | default "postgresql" | toString | b64enc }} +{{- $db_name := .Values.db.name | toString | b64enc }} +{{- $db_user := .Values.db.user | toString | b64enc }} +{{- $db_password := .Values.db.password | toString | b64enc }} +{{- $db_host := .Values.db.host | toString | b64enc }} +{{- $db_port := .Values.db.port | default "5432" | toString | b64enc }} +{{- $ngrok := .Values.vpbot.ngrok.enabled }} apiVersion: v1 kind: Secret metadata: @@ -6,13 +19,13 @@ metadata: {{- include "vpbot.labels" . | nindent 4 }} type: Opaque data: - SECRET_KEY: {{ .Values.vpbot.secret | toString | b64enc }} - TELEGRAM_BOT_TOKEN: {{ .Values.telegram.token | toString | b64enc }} - TELEGRAM_ADMIN_ID: {{ .Values.telegram.admin_id | toString | b64enc }} - TELEGRAM_DEVEL_ID: {{ .Values.telegram.devel_id | toString | b64enc }} - DEFAULT_USER_PASS: {{ .Values.vpbot.user_pass | toString | b64enc }} - {{- if .Values.vpbot.ngrok.enabled }} - NGROK_AUTH_TOKEN: {{ .Values.vpbot.ngrok.auth_token | toString | b64enc }} + SECRET_KEY: {{ $secret }} + TELEGRAM_BOT_TOKEN: {{ $telegram_token }} + TELEGRAM_ADMIN_ID: {{ $admin_id }} + TELEGRAM_DEVEL_ID: {{ $devel_id }} + DEFAULT_USER_PASS: {{ $user_pass }} + {{- if $ngrok }} + NGROK_AUTH_TOKEN: {{ $ngrok_token }} {{- end }} --- apiVersion: v1 @@ -23,9 +36,9 @@ metadata: {{- include "vpbot.labels" . | nindent 4 }} type: Opaque data: - DB_HOST: {{ .Values.db.host | toString | b64enc }} - DB_TYPE: {{ .Values.db.type | toString | b64enc }} - DB_PORT: {{ .Values.db.port | toString | b64enc }} - DB_NAME: {{ .Values.db.name | toString | b64enc }} - DB_USER: {{ .Values.db.user | toString | b64enc }} - DB_PASS: {{ .Values.db.pass | toString | b64enc }} + DB_HOST: {{ $db_host }} + DB_TYPE: {{ $db_type }} + DB_PORT: {{ $db_port }} + DB_NAME: {{ $db_name }} + DB_USER: {{ $db_user }} + DB_PASS: {{ $db_password }} diff --git a/mika/vpbot/values.yaml b/mika/vpbot/values.yaml index 1501faf4..4fe0cc71 100644 --- a/mika/vpbot/values.yaml +++ b/mika/vpbot/values.yaml @@ -2,81 +2,234 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -replicaCount: 1 +# The desired number of running replicas for Vpbot. +# Default: "1" +replicaCount: "" +# Container images used for Vpbot. image: + # Vpbot container image configurations. vpbot: - registry: ghcr.io - repository: irfanhakim-as/quarantine-bot + # The registry where the Vpbot container image is hosted. + # Default: "ghcr.io" + registry: "" + # The name of the repository that contains the Vpbot container image used. + # Default: "irfanhakim-as/quarantine-bot" + repository: "" + # The tag that specifies the version of the Vpbot container image used. + # Default: Chart appVersion tag: "" - pullPolicy: IfNotPresent - + # The policy that determines when Kubernetes should pull the Vpbot container image. + # Default: "IfNotPresent" + pullPolicy: "" + # Redis container image configurations. redis: - registry: docker.io - repository: redis - tag: "alpine" - pullPolicy: IfNotPresent - + # The registry where the Redis container image is hosted. + # Default: "docker.io" + registry: "" + # The name of the repository that contains the Redis container image used. + # Default: "redis" + repository: "" + # The tag that specifies the version of the Redis container image used. + # Default: "alpine" + tag: "" + # The policy that determines when Kubernetes should pull the Redis container image. + # Default: "IfNotPresent" + pullPolicy: "" + # Ngrok container image configurations. ngrok: - registry: docker.io - repository: wernight/ngrok - tag: "latest" - pullPolicy: IfNotPresent + # The registry where the Ngrok container image is hosted. + # Default: "docker.io" + registry: "" + # The name of the repository that contains the Ngrok container image used. + # Default: "wernight/ngrok" + repository: "" + # The tag that specifies the version of the Ngrok container image used. + # Default: "latest" + tag: "" + # The policy that determines when Kubernetes should pull the Ngrok container image. + # Default: "IfNotPresent" + pullPolicy: "" -imagePullSecrets: - - name: ghcr-token-secret # name of the secret containing the token to access the vpbot image +# Credentials used to securely authenticate and authorise the pulling of container images from private registries. +# Example: +# imagePullSecrets: +# - name: "ghcr-token-secret" +imagePullSecrets: [] +# Vpbot configurations. vpbot: - name: "Vpbot" # application name - debug: false # django debug mode - log_size_limit: "4" # log file size limit in MiB - secret: "" # django secret key - user_pass: "" # default user password - celery_timezone: "Asia/Kuala_Lumpur" # scheduler timezone + # The name of the Vpbot service. + # Default: "Vpbot" + # Example: + # name: "Vpbot" + name: "" + # Specifies whether Vpbot should run in debug mode. + # Default: false + # Example: + # debug: true + debug: "" + # The log file size limit in megabytes. + # Default: "4" + # Example: + # log_size_limit: "3" + log_size_limit: "" + # A 50-character secret key used for secure session management and cryptographic operations within the Vpbot service. + # Example: + # secret: "6&p4%t)-$8a14fmfh92py8j55+us51r6%e52dzy&=a3-6yd4#e" + secret: "" + # default user password + user_pass: "" + # The timezone for the task scheduler used by Vpbot to schedule time-dependent operations. + # Default: "Asia/Kuala_Lumpur" + # Example: + # timezone: "Asia/Kuala_Lumpur" + celery_timezone: "" + # Vpbot storage persistence configurations. + persistence: + # Specifies whether Vpbot should persist its storage. + # Example: + # enabled: true + enabled: false + # The storage class name used for dynamically provisioning a persistent volume for the Vpbot storage. + # Default: "longhorn" + # Example: + # storageClassName: "longhorn" + storageClassName: "" + # Vpbot logs persistence configurations. + logs: + # The amount of persistent storage allocated for Vpbot logs. + # Default: "50Mi" + # Example: + # storage: "1Gi" + storage: "" + # Vpbot static files persistence configurations. + static: + # The amount of persistent storage allocated for Vpbot static files. + # Default: "50Mi" + # Example: + # storage: "1Gi" + storage: "" + # Vpbot migration files persistence configurations. + migrations: + # The amount of persistent storage allocated for Vpbot migration files. + # Default: "50Mi" + # Example: + # storage: "1Gi" + storage: "" + # Vpbot Ngrok configurations. ngrok: - enabled: false # enable ngrok - auth_token: "" # ngrok auth token + # Specifies whether Vpbot should run using an Ngrok tunnel. + # Example: + # enabled: true + enabled: false + # Ngrok authentication token. + # Example: + # token: "s7Ed4IO23nw1HWRJwumSgcyB7BtcXr4ZYLtziJCDDLIVDv7uq" + token: "" + # Vpbot Cloudflare configurations. cloudflared: - enabled: true # enable cloudflared - domain: "" # cloudflared domain + # Specifies whether Vpbot should run using a Cloudflare tunnel. + # Example: + # enabled: true + enabled: true + # Registered domain name on Cloudflare used for Vpbot. + # Example: + # domain: "vpbot.example.com" + domain: "" +# Vpbot Telegram configurations. telegram: - webhook: "telegram/webhooks/" # telegram webhook path - token: "" # telegram bot token - admin_id: "" # admin telegram chat id - devel_id: "" # admin telegram chat id + # The Telegram bot webhook path used by Vpbot to communicate with Telegram. + # Default: "telegram/webhooks/" + # Example: + # webhook: "bot/jbbhb73f6s/" + webhook: "" + # The Telegram bot token used by Vpbot to communicate with Telegram. + # Example: + # token: "1282813559:RrqoFIuWZwNfMLrx3Jd2mdFJnxrMObgQEvz" + token: "" + # The unique Telegram chat ID of the Vpbot administrator. + # Example: + # admin_id: "6649538406" + admin_id: "" + # The unique Telegram chat ID of the Vpbot developer. + # Example: + # devel_id: "4637142749" + devel_id: "" +# Database configurations. db: - host: "postgres.default.svc.cluster.local" # database host - type: "postgresql" # database type - port: "5432" # database port - name: "" # database name - user: "" # database user - pass: "" # database user password - -pvc: - static: - storage: "50Mi" # static files storage size - storageClassName: "longhorn" # static files storage class name - logs: - storage: "50Mi" # log files storage size - storageClassName: "longhorn" # log files storage class name - migrations: - storage: "50Mi" # migrations files storage size - storageClassName: "longhorn" # migrations files storage class name + # The type of the database used by Vpbot. + # Default: "postgresql" + # Example: + # type: "postgresql" + type: "" + # The name of the database used by Vpbot. + # Example: + # name: "vpbot" + name: "" + # The username or user account for accessing the Vpbot database. + # Example: + # user: "root" + user: "" + # The password associated with the Vpbot database's user. + # Example: + # password: "password" + password: "" + # The hostname or IP address of the Vpbot database server. + # Example: + # host: "vpbot.default.svc.cluster.local" + host: "" + # The port number on which the Vpbot database server is listening. + # Default: "5432" + # Example: + # port: "5432" + port: "" +# Resource requirements and limits for Vpbot containers. resources: + # Vpbot container resources. vpbot: + # The minimum amount of resources required by Vpbot to run. requests: - cpu: "10m" # vpbot cpu request - memory: "250Mi" # vpbot memory request + # The minimum amount of CPU resources required by Vpbot. + # Example: + # cpu: "20m" + cpu: "10m" + # The minimum amount of memory required by Vpbot. + # Example: + # memory: "250Mi" + memory: "250Mi" + # The maximum amount of resources allowed for Vpbot. limits: - cpu: "50m" # vpbot cpu limit - memory: "500Mi" # vpbot memory limit + # The maximum amount of CPU resources allowed for Vpbot. + # Example: + # cpu: "50m" + cpu: "50m" + # The maximum amount of memory allowed for Vpbot. + # Example: + # memory: "450Mi" + memory: "500Mi" + # Redis container resources. redis: + # The minimum amount of resources required by Redis to run. requests: - cpu: "5m" # redis cpu request - memory: "30Mi" # redis memory request + # The minimum amount of CPU resources required by Redis. + # Example: + # cpu: "5m" + cpu: "5m" + # The minimum amount of memory required by Redis. + # Example: + # memory: "30Mi" + memory: "30Mi" + # The maximum amount of resources allowed for Redis. limits: - cpu: "15m" # redis cpu limit - memory: "60Mi" # redis memory limit + # The maximum amount of CPU resources allowed for Redis. + # Example: + # cpu: "15m" + cpu: "15m" + # The maximum amount of memory allowed for Redis. + # Example: + # memory: "50Mi" + memory: "60Mi" From a0efd562fecc39b6cc143a86c48fa0c149349ad8 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sat, 17 Jun 2023 13:22:04 +0800 Subject: [PATCH 092/117] Add missing description --- mika/vpbot/values.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mika/vpbot/values.yaml b/mika/vpbot/values.yaml index 4fe0cc71..1d1c7170 100644 --- a/mika/vpbot/values.yaml +++ b/mika/vpbot/values.yaml @@ -78,7 +78,9 @@ vpbot: # Example: # secret: "6&p4%t)-$8a14fmfh92py8j55+us51r6%e52dzy&=a3-6yd4#e" secret: "" - # default user password + # The default user password for users created by Vpbot. + # Example: + # user_pass: "password" user_pass: "" # The timezone for the task scheduler used by Vpbot to schedule time-dependent operations. # Default: "Asia/Kuala_Lumpur" From c7157f6a0488205296de181e22e908c9058aef15 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sat, 17 Jun 2023 13:25:26 +0800 Subject: [PATCH 093/117] Default cloudflared to false --- mika/vpbot/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mika/vpbot/values.yaml b/mika/vpbot/values.yaml index 1d1c7170..e225cbcf 100644 --- a/mika/vpbot/values.yaml +++ b/mika/vpbot/values.yaml @@ -134,7 +134,7 @@ vpbot: # Specifies whether Vpbot should run using a Cloudflare tunnel. # Example: # enabled: true - enabled: true + enabled: false # Registered domain name on Cloudflare used for Vpbot. # Example: # domain: "vpbot.example.com" From 62c8f83ae8fe20f000c5e9615927ba24a393954d Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sat, 17 Jun 2023 13:26:49 +0800 Subject: [PATCH 094/117] Update documentation --- mika/vpbot/README.md | 107 +++++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 50 deletions(-) diff --git a/mika/vpbot/README.md b/mika/vpbot/README.md index e2242dd0..df46c709 100644 --- a/mika/vpbot/README.md +++ b/mika/vpbot/README.md @@ -49,7 +49,7 @@ Copy `values.yaml` from the chart you would like to install. cp mika/vpbot/values.yaml . ``` -Edit `values.yaml` with the appropriate values. Refer to the [Configuration](#Configuration) section for the available options. +Edit `values.yaml` with the appropriate values. Refer to the [Configurations](#Configurations) section for the available options. ```sh nano values.yaml @@ -69,6 +69,14 @@ Verify that your chart has been installed. Replace `$namespace` and `$release_na helm ls --namespace $namespace | grep "$release_name" ``` +## How to upgrade + +After making any necessary changes to the `values.yaml` file, upgrade the desired chart. Replace `$release_name` and `$namespace` accordingly. + +```sh +helm upgrade $release_name mika/vpbot --namespace $namespace --values values.yaml --wait +``` + ## How to uninstall Uninstall the desired chart. Replace `$release_name` and `$namespace` accordingly. @@ -81,55 +89,54 @@ helm uninstall $release_name --namespace $namespace --wait Install [`mika/postgres-dropdb`](../postgres-dropdb/). -## Configuration +## Configurations | Key | Type | Default | Description | |-----|------|---------|-------------| -| db.host | string | `"postgres.default.svc.cluster.local"` | Database server | -| db.name | string | `""` | Database name | -| db.pass | string | `""` | Database user password | -| db.port | string | `"5432"` | Database port | -| db.type | string | `"postgresql"` | Database type | -| db.user | string | `""` | Database user | -| image.ngrok.pullPolicy | string | `"IfNotPresent"` | Ngrok image pull policy | -| image.ngrok.registry | string | `"docker.io"` | Ngrok image registry | -| image.ngrok.repository | string | `"wernight/ngrok"` | Ngrok image repository | -| image.ngrok.tag | string | `"latest"` | Ngrok image version | -| image.redis.pullPolicy | string | `"IfNotPresent"` | Redis image pull policy | -| image.redis.registry | string | `"docker.io"` | Redis image registry | -| image.redis.repository | string | `"redis"` | Redis image repository | -| image.redis.tag | string | `"alpine"` | Redis image version | -| image.vpbot.pullPolicy | string | `"IfNotPresent"` | Vpbot image pull policy | -| image.vpbot.registry | string | `"ghcr.io"` | Vpbot image registry | -| image.vpbot.repository | string | `"irfanhakim-as/quarantine-bot"` | Vpbot image repository | -| image.vpbot.tag | string | `""` | Vpbot image version | -| imagePullSecrets[0].name | string | `"ghcr-token-secret"` | Name of the image pull secret | -| pvc.logs.storage | string | `"50Mi"` | Logs storage size | -| pvc.logs.storageClassName | string | `"longhorn"` | Logs storage class name | -| pvc.migrations.storage | string | `"50Mi"` | Migrations storage size | -| pvc.migrations.storageClassName | string | `"longhorn"` | Migrations storage class name | -| pvc.static.storage | string | `"50Mi"` | Static files storage size | -| pvc.static.storageClassName | string | `"longhorn"` | Static files storage class name | -| replicaCount | int | `1` | Vpbot replica count | -| resources.redis.limits.cpu | string | `"15m"` | Redis maximum CPU allocation | -| resources.redis.limits.memory | string | `"60Mi"` | Redis maximum memory allocation | -| resources.redis.requests.cpu | string | `"5m"` | Redis minimum CPU allocation | -| resources.redis.requests.memory | string | `"30Mi"` | Redis minimum memory allocation | -| resources.vpbot.limits.cpu | string | `"50m"` | Vpbot maximum CPU allocation | -| resources.vpbot.limits.memory | string | `"500Mi"` | Vpbot maximum memory allocation | -| resources.vpbot.requests.cpu | string | `"10m"` | Vpbot minimum CPU allocation | -| resources.vpbot.requests.memory | string | `"250Mi"` | Vpbot minimum memory allocation | -| telegram.admin_id | string | `""` | Telegram admin Chat ID | -| telegram.devel_id | string | `""` | Telegram developer Chat ID | -| telegram.token | string | `""` | Telegram bot token | -| telegram.webhook | string | `"telegram/webhooks/"` | Telegram webhook path | -| vpbot.celery_timezone | string | `"Asia/Kuala_Lumpur"` | Background scheduler timezone | -| vpbot.cloudflared.domain | string | `""` | Vpbot domain | -| vpbot.cloudflared.enabled | bool | `true` | Enable cloudflare tunnel | -| vpbot.debug | bool | `false` | Enable debug mode | -| vpbot.log_size_limit | string | `"4"` | Individual log file size limit | -| vpbot.name | string | `"Vpbot"` | Application name | -| vpbot.ngrok.auth_token | string | `""` | Ngrok authentication token | -| vpbot.ngrok.enabled | bool | `false` | Enable ngrok tunnel | -| vpbot.secret | string | `""` | Vpbot secret key | -| vpbot.user_pass | string | `""` | Vpbot default user password | +| db.host | string | `""` | The hostname or IP address of the Vpbot database server. | +| db.name | string | `""` | The name of the database used by Vpbot. | +| db.password | string | `""` | The password associated with the Vpbot database's user. | +| db.port | string | `""` | The port number on which the Vpbot database server is listening. Default: `"5432"`. | +| db.type | string | `""` | The type of the database used by Vpbot. Default: `"postgresql"`. | +| db.user | string | `""` | The username or user account for accessing the Vpbot database. | +| image.ngrok.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the Ngrok container image. Default: `"IfNotPresent"`. | +| image.ngrok.registry | string | `""` | The registry where the Ngrok container image is hosted. Default: `"docker.io"`. | +| image.ngrok.repository | string | `""` | The name of the repository that contains the Ngrok container image used. Default: `"wernight/ngrok"`. | +| image.ngrok.tag | string | `""` | The tag that specifies the version of the Ngrok container image used. Default: `"latest"`. | +| image.redis.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the Redis container image. Default: `"IfNotPresent"`. | +| image.redis.registry | string | `""` | The registry where the Redis container image is hosted. Default: `"docker.io"`. | +| image.redis.repository | string | `""` | The name of the repository that contains the Redis container image used. Default: `"redis"`. | +| image.redis.tag | string | `""` | The tag that specifies the version of the Redis container image used. Default: `"alpine"`. | +| image.vpbot.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the Vpbot container image. Default: `"IfNotPresent"`. | +| image.vpbot.registry | string | `""` | The registry where the Vpbot container image is hosted. Default: `"ghcr.io"`. | +| image.vpbot.repository | string | `""` | The name of the repository that contains the Vpbot container image used. Default: `"irfanhakim-as/vpbot"`. | +| image.vpbot.tag | string | `""` | The tag that specifies the version of the Vpbot container image used. Default: `"Chart appVersion"`. | +| imagePullSecrets | list | `[]` | Credentials used to securely authenticate and authorise the pulling of container images from private registries. | +| replicaCount | string | `""` | The desired number of running replicas for Vpbot. Default: `"1"`. | +| resources.redis.limits.cpu | string | `"15m"` | The maximum amount of CPU resources allowed for Redis. | +| resources.redis.limits.memory | string | `"60Mi"` | The maximum amount of memory allowed for Redis. | +| resources.redis.requests.cpu | string | `"5m"` | The minimum amount of CPU resources required by Redis. | +| resources.redis.requests.memory | string | `"30Mi"` | The minimum amount of memory required by Redis. | +| resources.vpbot.limits.cpu | string | `"50m"` | The maximum amount of CPU resources allowed for Vpbot. | +| resources.vpbot.limits.memory | string | `"500Mi"` | The maximum amount of memory allowed for Vpbot. | +| resources.vpbot.requests.cpu | string | `"10m"` | The minimum amount of CPU resources required by Vpbot. | +| resources.vpbot.requests.memory | string | `"250Mi"` | The minimum amount of memory required by Vpbot. | +| telegram.admin_id | string | `""` | The unique Telegram chat ID of the Vpbot administrator. | +| telegram.devel_id | string | `""` | The unique Telegram chat ID of the Vpbot developer. | +| telegram.token | string | `""` | The Telegram bot token used by Vpbot to communicate with Telegram. | +| telegram.webhook | string | `""` | The Telegram bot webhook path used by Vpbot to communicate with Telegram. Default: `"telegram/webhooks/"`. | +| vpbot.celery_timezone | string | `""` | The timezone for the task scheduler used by Vpbot to schedule time-dependent operations. Default: `"Asia/Kuala_Lumpur"`. | +| vpbot.cloudflared.domain | string | `""` | Registered domain name on Cloudflare used for Vpbot. | +| vpbot.cloudflared.enabled | bool | `false` | Specifies whether Vpbot should run using a Cloudflare tunnel. | +| vpbot.debug | string | `""` | Specifies whether Vpbot should run in debug mode. Default: `false`. | +| vpbot.log_size_limit | string | `""` | The log file size limit in megabytes. Default: `"4"`. | +| vpbot.name | string | `""` | The name of the Vpbot service. Default: `"Vpbot"`. | +| vpbot.ngrok.enabled | bool | `false` | Specifies whether Vpbot should run using an Ngrok tunnel. | +| vpbot.ngrok.token | string | `""` | Ngrok authentication token. | +| vpbot.persistence.enabled | bool | `false` | Specifies whether Vpbot should persist its storage. | +| vpbot.persistence.logs.storage | string | `""` | The amount of persistent storage allocated for Vpbot logs. Default: `"50Mi"`. | +| vpbot.persistence.migrations.storage | string | `""` | The amount of persistent storage allocated for Vpbot migration files. Default: `"50Mi"`. | +| vpbot.persistence.static.storage | string | `""` | The amount of persistent storage allocated for Vpbot static files. Default: `"50Mi"`. | +| vpbot.persistence.storageClassName | string | `""` | The storage class name used for dynamically provisioning a persistent volume for the Vpbot storage. Default: `"longhorn"`. | +| vpbot.secret | string | `""` | A 50-character secret key used for secure session management and cryptographic operations within the Vpbot service. | +| vpbot.user_pass | string | `""` | The default user password for users created by Vpbot. | From 26d9fd7cdee232b3cdd753135ff873482bfd5907 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sun, 18 Jun 2023 15:45:20 +0800 Subject: [PATCH 095/117] Add quote --- mika/telego/templates/configmap.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mika/telego/templates/configmap.yaml b/mika/telego/templates/configmap.yaml index 448f0448..1242dd4f 100644 --- a/mika/telego/templates/configmap.yaml +++ b/mika/telego/templates/configmap.yaml @@ -23,7 +23,7 @@ data: CELERY_TIMEZONE: {{ $celery_timezone }} NGROK: {{ $ngrok | toString | quote }} {{- if $cloudflared }} - DOMAIN: {{ $domain }} + DOMAIN: {{ $domain | quote }} {{- end }} --- apiVersion: v1 From 891d1787f64cc8a7c89fc05de157b11b005d4e6a Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sun, 18 Jun 2023 17:04:14 +0800 Subject: [PATCH 096/117] Update chart templates --- mika/clog/Chart.yaml | 17 ++++---- mika/clog/templates/NOTES.txt | 6 ++- mika/clog/templates/_helpers.tpl | 34 ++++++++++++++++ mika/clog/templates/configmap.yaml | 53 +++++------------------- mika/clog/templates/deployment.yaml | 63 +++++++++++++++-------------- mika/clog/templates/pvc.yaml | 28 ++++++++----- mika/clog/templates/secret.yaml | 23 ++++++++--- 7 files changed, 126 insertions(+), 98 deletions(-) diff --git a/mika/clog/Chart.yaml b/mika/clog/Chart.yaml index 368bfd83..3e062e62 100644 --- a/mika/clog/Chart.yaml +++ b/mika/clog/Chart.yaml @@ -5,13 +5,14 @@ type: application version: 0.1.10 appVersion: "0.0.1-stable" keywords: - - clog -home: https://github.com/irfanhakim-as/clog -icon: https://irfanhakim-as.github.io/charts/logos/clog.png + - "clog" + - "blog" +home: "https://github.com/irfanhakim-as/clog" +icon: "https://irfanhakim-as.github.io/charts/logos/clog.png" sources: - - https://github.com/irfanhakim-as/clog - - https://github.com/irfanhakim-as/charts + - "https://github.com/irfanhakim-as/clog" + - "https://github.com/irfanhakim-as/charts" maintainers: - - name: Irfan Hakim - email: irfanhakim.as@yahoo.com - url: https://github.com/irfanhakim-as + - name: "Irfan Hakim" + email: "irfanhakim.as@yahoo.com" + url: "https://github.com/irfanhakim-as" diff --git a/mika/clog/templates/NOTES.txt b/mika/clog/templates/NOTES.txt index bcad16af..a7bceb78 100644 --- a/mika/clog/templates/NOTES.txt +++ b/mika/clog/templates/NOTES.txt @@ -1 +1,5 @@ -clog is now installed and configured. +Clog is now installed and configured for {{ .Release.Name | toString }}. + +See the values.yaml file of this chart for more configuration options. + +Please refer to the official documentation for more information on how to use Clog. diff --git a/mika/clog/templates/_helpers.tpl b/mika/clog/templates/_helpers.tpl index 1140b352..4a18a3d6 100644 --- a/mika/clog/templates/_helpers.tpl +++ b/mika/clog/templates/_helpers.tpl @@ -60,3 +60,37 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Apache site-config.conf template +*/}} +{{- define "clog.site-config-conf" -}} + + ServerName DOMAIN:443 + UseCanonicalName On + ServerAdmin support@mikahomelab.com + DocumentRoot /clog + WSGIScriptAlias / /clog/clog/wsgi.py + WSGIDaemonProcess DOMAIN python-path=/clog + WSGIProcessGroup DOMAIN + + + + Require all granted + + + + Alias /static /static + + Require all granted + + + Alias /media /clog/media + + Require all granted + + + ErrorLog /var/log/apache2/apache.error.log + CustomLog /var/log/apache2/apache.access.log combined + +{{- end }} diff --git a/mika/clog/templates/configmap.yaml b/mika/clog/templates/configmap.yaml index 57da8cf7..b7a296e9 100644 --- a/mika/clog/templates/configmap.yaml +++ b/mika/clog/templates/configmap.yaml @@ -1,4 +1,8 @@ +{{- $name := .Values.clog.name | default "Clog" | toString | quote }} +{{- $debug := .Values.clog.debug | default "false" | toString | quote }} {{- $domain := .Values.clog.cloudflared.domain | default "localhost" | toString }} +{{- $cloudflared := .Values.clog.cloudflared.enabled }} +{{- $ngrok := .Values.clog.ngrok.enabled }} apiVersion: v1 kind: ConfigMap metadata: @@ -6,56 +10,19 @@ metadata: labels: {{- include "clog.labels" . | nindent 4 }} data: - SITE_NAME: "{{ .Values.clog.site_name | toString }}" - DEBUG: "{{ .Values.clog.debug | toString }}" - NGROK: "{{ .Values.clog.ngrok.enabled | toString }}" - {{- if .Values.clog.cloudflared.enabled }} - DOMAIN: "{{ $domain }}" + SITE_NAME: {{ $name }} + DEBUG: {{ $debug }} + NGROK: {{ $ngrok | toString | quote }} + {{- if $cloudflared }} + DOMAIN: {{ $domain | quote }} {{- end }} --- apiVersion: v1 kind: ConfigMap -metadata: - name: {{ .Release.Name }}-clog-postgres-cm - labels: - {{- include "clog.labels" . | nindent 4 }} -data: - DB_HOST: "{{ .Values.db.host | toString }}" - DB_NAME: "{{ .Values.db.name | toString }}" ---- -apiVersion: v1 -kind: ConfigMap metadata: name: {{ .Release.Name }}-clog-site-config labels: {{- include "clog.labels" . | nindent 4 }} data: site-config.conf: |- - - {{ "ServerName $domain:443" | replace "$domain" $domain }} - UseCanonicalName On - ServerAdmin support@mika-homelab.com - DocumentRoot /clog - WSGIScriptAlias / /clog/clog/wsgi.py - {{ "WSGIDaemonProcess $domain python-path=/clog" | replace "$domain" $domain }} - {{ "WSGIProcessGroup $domain" | replace "$domain" $domain }} - - - - Require all granted - - - - Alias /static /static - - Require all granted - - - Alias /media /clog/media - - Require all granted - - - ErrorLog /var/log/apache2/apache.error.log - CustomLog /var/log/apache2/apache.access.log combined - + {{- include "clog.site-config-conf" . | replace "DOMAIN" $domain | nindent 4 }} diff --git a/mika/clog/templates/deployment.yaml b/mika/clog/templates/deployment.yaml index 3621e2db..01ebda2c 100644 --- a/mika/clog/templates/deployment.yaml +++ b/mika/clog/templates/deployment.yaml @@ -1,3 +1,15 @@ +{{- $replica_count := .Values.replicaCount | default "1" | toString }} +{{- $clog_registry := .Values.image.clog.registry | default "ghcr.io" | toString }} +{{- $clog_repository := .Values.image.clog.repository | default "irfanhakim-as/clog" | toString }} +{{- $clog_tag := .Values.image.clog.tag | default .Chart.AppVersion | toString }} +{{- $clog_pullPolicy := .Values.image.clog.pullPolicy | default "IfNotPresent" | toString | quote }} +{{- $ngrok_registry := .Values.image.ngrok.registry | default "docker.io" | toString }} +{{- $ngrok_repository := .Values.image.ngrok.repository | default "wernight/ngrok" | toString }} +{{- $ngrok_tag := .Values.image.ngrok.tag | default "latest" | toString }} +{{- $ngrok_pullPolicy := .Values.image.ngrok.pullPolicy | default "IfNotPresent" | toString | quote }} +{{- $cloudflared := .Values.clog.cloudflared.enabled }} +{{- $ngrok := .Values.clog.ngrok.enabled }} +{{- $persistence := .Values.clog.persistence.enabled }} apiVersion: apps/v1 kind: Deployment metadata: @@ -5,7 +17,7 @@ metadata: labels: {{- include "clog.labels" . | nindent 4 }} spec: - replicas: {{ .Values.replicaCount | default 1 }} + replicas: {{ int $replica_count }} selector: matchLabels: {{- include "clog.selectorLabels" . | nindent 6 }} @@ -24,8 +36,8 @@ spec: {{- end }} containers: - name: clog - image: "{{ .Values.image.clog.registry }}/{{ .Values.image.clog.repository }}:{{ .Values.image.clog.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.clog.pullPolicy }} + image: {{ printf "%s/%s:%s" $clog_registry $clog_repository $clog_tag | quote }} + imagePullPolicy: {{ $clog_pullPolicy }} ports: - name: clog containerPort: 80 @@ -33,22 +45,7 @@ spec: resources: {{- toYaml .Values.resources.clog | nindent 12 }} env: - - name: SITE_NAME - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-clog-cm - key: SITE_NAME - - name: DEBUG - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-clog-cm - key: DEBUG - - name: NGROK - valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-clog-cm - key: NGROK - {{- if .Values.clog.cloudflared.enabled }} + {{- if $cloudflared }} - name: ALLOWED_HOSTS valueFrom: configMapKeyRef: @@ -57,13 +54,13 @@ spec: {{- end }} - name: POSTGRES_HOST valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-clog-postgres-cm + secretKeyRef: + name: {{ .Release.Name }}-clog-postgres-secret key: DB_HOST - name: POSTGRES_DB valueFrom: - configMapKeyRef: - name: {{ .Release.Name }}-clog-postgres-cm + secretKeyRef: + name: {{ .Release.Name }}-clog-postgres-secret key: DB_NAME - name: POSTGRES_USER valueFrom: @@ -75,16 +72,17 @@ spec: secretKeyRef: name: {{ .Release.Name }}-clog-postgres-secret key: DB_PASS - - name: SECRET_KEY - valueFrom: - secretKeyRef: - name: {{ .Release.Name }}-clog-secret - key: SECRET_KEY + envFrom: + - configMapRef: + name: {{ .Release.Name }}-clog-cm + - secretRef: + name: {{ .Release.Name }}-clog-secret volumeMounts: - name: {{ .Release.Name }}-clog-site-config mountPath: /etc/apache2/sites-available/000-default.conf subPath: site-config.conf readOnly: true + {{- if $persistence }} - name: {{ .Release.Name }}-clog-static mountPath: /static - name: {{ .Release.Name }}-clog-media @@ -95,10 +93,11 @@ spec: mountPath: /clog/core/migrations - name: {{ .Release.Name }}-clog-money-migrations mountPath: /clog/money/migrations - {{- if .Values.clog.ngrok.enabled }} + {{- end }} + {{- if $ngrok }} - name: ngrok - image: "{{ .Values.image.ngrok.registry }}/{{ .Values.image.ngrok.repository }}:{{ .Values.image.ngrok.tag | default .Chart.AppVersion }}" - imagePullPolicy: {{ .Values.image.ngrok.pullPolicy }} + image: {{ printf "%s/%s:%s" $ngrok_registry $ngrok_repository $ngrok_tag | quote }} + imagePullPolicy: {{ $ngrok_pullPolicy }} command: ["/bin/sh"] args: - -c @@ -123,6 +122,7 @@ spec: items: - key: site-config.conf path: site-config.conf + {{- if $persistence }} - name: {{ .Release.Name }}-clog-static persistentVolumeClaim: claimName: {{ .Release.Name }}-clog-static-pvc @@ -138,3 +138,4 @@ spec: - name: {{ .Release.Name }}-clog-money-migrations persistentVolumeClaim: claimName: {{ .Release.Name }}-clog-money-migrations-pvc + {{- end }} diff --git a/mika/clog/templates/pvc.yaml b/mika/clog/templates/pvc.yaml index 3643a8d8..e3044e1b 100644 --- a/mika/clog/templates/pvc.yaml +++ b/mika/clog/templates/pvc.yaml @@ -1,3 +1,10 @@ +{{- $static_storage := .Values.clog.persistence.static.storage | default "50Mi" | toString | quote }} +{{- $media_storage := .Values.clog.persistence.media.storage | default "100Mi" | toString | quote }} +{{- $logs_storage := .Values.clog.persistence.logs.storage | default "50Mi" | toString | quote }} +{{- $migrations_storage := .Values.clog.persistence.migrations.storage | default "20Mi" | toString | quote }} +{{- $storage_class_name := .Values.clog.persistence.storageClassName | default "longhorn" | toString | quote }} +{{- $persistence := .Values.clog.persistence.enabled }} +{{- if $persistence }} apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -9,8 +16,8 @@ spec: - ReadWriteMany resources: requests: - storage: {{ .Values.pvc.static.storage }} - storageClassName: {{ .Values.pvc.static.storageClassName }} + storage: {{ $static_storage }} + storageClassName: {{ $storage_class_name }} --- apiVersion: v1 kind: PersistentVolumeClaim @@ -23,8 +30,8 @@ spec: - ReadWriteMany resources: requests: - storage: {{ .Values.pvc.media.storage }} - storageClassName: {{ .Values.pvc.media.storageClassName }} + storage: {{ $media_storage }} + storageClassName: {{ $storage_class_name }} --- apiVersion: v1 kind: PersistentVolumeClaim @@ -37,8 +44,8 @@ spec: - ReadWriteMany resources: requests: - storage: {{ .Values.pvc.logs.storage }} - storageClassName: {{ .Values.pvc.logs.storageClassName }} + storage: {{ $logs_storage }} + storageClassName: {{ $storage_class_name }} --- apiVersion: v1 kind: PersistentVolumeClaim @@ -51,8 +58,8 @@ spec: - ReadWriteMany resources: requests: - storage: {{ .Values.pvc.migrations.core.storage }} - storageClassName: {{ .Values.pvc.migrations.core.storageClassName }} + storage: {{ $migrations_storage }} + storageClassName: {{ $storage_class_name }} --- apiVersion: v1 kind: PersistentVolumeClaim @@ -65,5 +72,6 @@ spec: - ReadWriteMany resources: requests: - storage: {{ .Values.pvc.migrations.money.storage }} - storageClassName: {{ .Values.pvc.migrations.money.storageClassName }} + storage: {{ $migrations_storage }} + storageClassName: {{ $storage_class_name }} +{{- end }} diff --git a/mika/clog/templates/secret.yaml b/mika/clog/templates/secret.yaml index 6d13addb..cd220b13 100644 --- a/mika/clog/templates/secret.yaml +++ b/mika/clog/templates/secret.yaml @@ -1,3 +1,12 @@ +{{- $secret := .Values.clog.secret | toString | b64enc }} +{{- $token := .Values.clog.ngrok.token | toString | b64enc }} +{{- $db_type := .Values.db.type | default "postgresql" | toString | b64enc }} +{{- $db_name := .Values.db.name | toString | b64enc }} +{{- $db_user := .Values.db.user | toString | b64enc }} +{{- $db_password := .Values.db.password | toString | b64enc }} +{{- $db_host := .Values.db.host | toString | b64enc }} +{{- $db_port := .Values.db.port | default "5432" | toString | b64enc }} +{{- $ngrok := .Values.clog.ngrok.enabled }} apiVersion: v1 kind: Secret metadata: @@ -6,9 +15,9 @@ metadata: {{- include "clog.labels" . | nindent 4 }} type: Opaque data: - SECRET_KEY: {{ .Values.clog.secret | toString | b64enc }} - {{- if .Values.clog.ngrok.enabled }} - NGROK_AUTH_TOKEN: {{ .Values.clog.ngrok.auth_token | toString | b64enc }} + SECRET_KEY: {{ $secret }} + {{- if $ngrok }} + NGROK_AUTH_TOKEN: {{ $token }} {{- end }} --- apiVersion: v1 @@ -19,5 +28,9 @@ metadata: {{- include "clog.labels" . | nindent 4 }} type: Opaque data: - DB_USER: {{ .Values.db.user | toString | b64enc }} - DB_PASS: {{ .Values.db.pass | toString | b64enc }} + DB_TYPE: {{ $db_type }} + DB_NAME: {{ $db_name }} + DB_USER: {{ $db_user }} + DB_PASS: {{ $db_password }} + DB_HOST: {{ $db_host }} + DB_PORT: {{ $db_port }} From 25bd3e1614de4d4d1b89ffdd98621cedd3da3893 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sun, 18 Jun 2023 17:29:02 +0800 Subject: [PATCH 097/117] Update chart values --- mika/clog/values.yaml | 201 ++++++++++++++++++++++++++++++++---------- 1 file changed, 153 insertions(+), 48 deletions(-) diff --git a/mika/clog/values.yaml b/mika/clog/values.yaml index 92c2a2d0..7984f522 100644 --- a/mika/clog/values.yaml +++ b/mika/clog/values.yaml @@ -2,67 +2,172 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -replicaCount: 1 +# The desired number of running replicas for Clog. +# Default: "1" +replicaCount: "" +# Container images used for Clog. image: + # Clog container image configurations. clog: - registry: ghcr.io - repository: irfanhakim-as/clog + # The registry where the Clog container image is hosted. + # Default: "ghcr.io" + registry: "" + # The name of the repository that contains the Clog container image used. + # Default: "irfanhakim-as/clog" + repository: "" + # The tag that specifies the version of the Clog container image used. + # Default: Chart appVersion tag: "" - pullPolicy: IfNotPresent - + # The policy that determines when Kubernetes should pull the Clog container image. + # Default: "IfNotPresent" + pullPolicy: "" + # Ngrok container image configurations. ngrok: - registry: docker.io - repository: wernight/ngrok - tag: "latest" - pullPolicy: IfNotPresent + # The registry where the Ngrok container image is hosted. + # Default: "docker.io" + registry: "" + # The name of the repository that contains the Ngrok container image used. + # Default: "wernight/ngrok" + repository: "" + # The tag that specifies the version of the Ngrok container image used. + # Default: "latest" + tag: "" + # The policy that determines when Kubernetes should pull the Ngrok container image. + # Default: "IfNotPresent" + pullPolicy: "" -imagePullSecrets: - - name: ghcr-token-secret # name of the secret containing the token to access the clog image +# Credentials used to securely authenticate and authorise the pulling of container images from private registries. +# Example: +# imagePullSecrets: +# - name: "ghcr-token-secret" +imagePullSecrets: [] clog: - site_name: "Clog" # name of the clog site - debug: false # django debug mode - secret: "" # django secret key - ngrok: - enabled: false # enable ngrok - auth_token: "" # ngrok auth token + # The name of the Clog service. + # Default: "Clog" + # Example: + # name: "Clog" + name: "" + # Specifies whether Clog should run in debug mode. + # Default: false + # Example: + # debug: true + debug: "" + # A 50-character secret key used for secure session management and cryptographic operations within the Clog service. + # Example: + # secret: "6&p4%t)-$8a14fmfh92py8j55+us51r6%e52dzy&=a3-6yd4#e" + secret: "" + # Clog storage persistence configurations. + persistence: + # Specifies whether Clog should persist its storage. + # Example: + # enabled: true + enabled: false + # The storage class name used for dynamically provisioning a persistent volume for the Clog storage. + # Default: "longhorn" + # Example: + # storageClassName: "longhorn" + storageClassName: "" + # Clog static files persistence configurations. + static: + # The amount of persistent storage allocated for Clog static files. + # Default: "50Mi" + # Example: + # storage: "1Gi" + storage: "" + # Clog media files persistence configurations. + media: + # The amount of persistent storage allocated for Clog media files. + # Default: "100Mi" + # Example: + # storage: "1Gi" + storage: "" + # Clog logs persistence configurations. + logs: + # The amount of persistent storage allocated for Clog logs. + # Default: "50Mi" + # Example: + # storage: "1Gi" + storage: "" + # Clog migration files persistence configurations. + migrations: + # The amount of persistent storage allocated for Clog migration files. + # Default: "20Mi" + # Example: + # storage: "1Gi" + storage: "" + # Clog Cloudflare configurations. cloudflared: - enabled: true # enable cloudflared - domain: "" # cloudflared domain + # Specifies whether Clog should run using a Cloudflare tunnel. + # Example: + # enabled: true + enabled: false + # Registered domain name on Cloudflare used for Clog. + # Example: + # domain: "clog.example.com" + domain: "" + # Clog Ngrok configurations. + ngrok: + # Specifies whether Clog should run using an Ngrok tunnel. + # Example: + # enabled: true + enabled: false + # Ngrok authentication token. + # Example: + # token: "s7Ed4IO23nw1HWRJwumSgcyB7BtcXr4ZYLtziJCDDLIVDv7uq" + token: "" +# Database configurations. db: - host: "postgres.default.svc.cluster.local" # remote postgres host - name: "" # remote postgres database name - user: "" # remote postgres database user - pass: "" # remote postgres database user password - -pvc: - static: - storage: "50Mi" # static files storage size - storageClassName: "longhorn" # static files storage class name - - media: - storage: "100Mi" # media files storage size - storageClassName: "longhorn" # media files storage class name - - logs: - storage: "50Mi" # logs files storage size - storageClassName: "longhorn" # logs files storage class name - - migrations: - core: - storage: "20Mi" # core migrations files storage size - storageClassName: "longhorn" # core migrations files storage class name - money: - storage: "20Mi" # money migrations files storage size - storageClassName: "longhorn" # money migrations files storage class name + # The type of the database used by Clog. + # Default: "postgresql" + # Example: + # type: "postgresql" + type: "" + # The name of the database used by Clog. + # Example: + # name: "clog" + name: "" + # The username or user account for accessing the Clog database. + # Example: + # user: "root" + user: "" + # The password associated with the Clog database's user. + # Example: + # password: "password" + password: "" + # The hostname or IP address of the Clog database server. + # Example: + # host: "clog.default.svc.cluster.local" + host: "" + # The port number on which the Clog database server is listening. + # Default: "5432" + # Example: + # port: "5432" + port: "" +# Resource requirements and limits for Clog containers. resources: + # Clog container resources. clog: + # The minimum amount of resources required by Clog to run. requests: - cpu: "10m" # clog cpu request - memory: "100Mi" # clog memory request + # The minimum amount of CPU resources required by Clog. + # Example: + # cpu: "20m" + cpu: "10m" + # The minimum amount of memory required by Clog. + # Example: + # memory: "250Mi" + memory: "100Mi" + # The maximum amount of resources allowed for Clog. limits: - cpu: "50m" # clog cpu limit - memory: "200Mi" # clog memory limit + # The maximum amount of CPU resources allowed for Clog. + # Example: + # cpu: "50m" + cpu: "50m" + # The maximum amount of memory allowed for Clog. + # Example: + # memory: "450Mi" + memory: "200Mi" From cb390d05100e801e1f69db97fb54c2e6c5bdf4ed Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sun, 18 Jun 2023 17:29:10 +0800 Subject: [PATCH 098/117] Update chart documentation --- mika/clog/README.md | 50 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/mika/clog/README.md b/mika/clog/README.md index 0c425ad9..5e36bcfb 100644 --- a/mika/clog/README.md +++ b/mika/clog/README.md @@ -49,7 +49,7 @@ Copy `values.yaml` from the chart you would like to install. cp mika/clog/values.yaml . ``` -Edit `values.yaml` with the appropriate values. +Edit `values.yaml` with the appropriate values. Refer to the [Configurations](#Configurations) section for the available options. ```sh nano values.yaml @@ -69,6 +69,14 @@ Verify that your chart has been installed. Replace `$namespace` and `$release_na helm ls --namespace $namespace | grep "$release_name" ``` +## How to upgrade + +After making any necessary changes to the `values.yaml` file, upgrade the desired chart. Replace `$release_name` and `$namespace` accordingly. + +```sh +helm upgrade $release_name mika/clog --namespace $namespace --values values.yaml --wait +``` + ## How to uninstall Uninstall the desired chart. Replace `$release_name` and `$namespace` accordingly. @@ -79,4 +87,42 @@ helm uninstall $release_name --namespace $namespace --wait ### Delete database -Install [`mika/postgres-dropdb`](../postgres-dropdb/). \ No newline at end of file +Install [`mika/postgres-dropdb`](../postgres-dropdb/). + +## Configurations + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| clog.cloudflared.domain | string | `""` | Registered domain name on Cloudflare used for Clog. | +| clog.cloudflared.enabled | bool | `false` | Specifies whether Clog should run using a Cloudflare tunnel. | +| clog.debug | string | `""` | Specifies whether Clog should run in debug mode. Default: `false`. | +| clog.name | string | `""` | The name of the Clog service. Default: `"Clog"`. | +| clog.ngrok.enabled | bool | `false` | Specifies whether Clog should run using an Ngrok tunnel. | +| clog.ngrok.token | string | `""` | Ngrok authentication token. | +| clog.persistence.enabled | bool | `false` | Specifies whether Clog should persist its storage. | +| clog.persistence.logs.storage | string | `""` | The amount of persistent storage allocated for Clog logs. Default: `"50Mi"`. | +| clog.persistence.media.storage | string | `""` | The amount of persistent storage allocated for Clog media files. Default: `"100Mi"`. | +| clog.persistence.migrations.storage | string | `""` | The amount of persistent storage allocated for Clog migration files. Default: `"20Mi"`. | +| clog.persistence.static.storage | string | `""` | The amount of persistent storage allocated for Clog static files. Default: `"50Mi"`. | +| clog.persistence.storageClassName | string | `""` | The storage class name used for dynamically provisioning a persistent volume for the Clog storage. Default: `"longhorn"`. | +| clog.secret | string | `""` | A 50-character secret key used for secure session management and cryptographic operations within the Clog service. | +| db.host | string | `""` | The hostname or IP address of the Clog database server. | +| db.name | string | `""` | The name of the database used by Clog. | +| db.password | string | `""` | The password associated with the Clog database's user. | +| db.port | string | `""` | The port number on which the Clog database server is listening. Default: `"5432"`. | +| db.type | string | `""` | The type of the database used by Clog. Default: `"postgresql"`. | +| db.user | string | `""` | The username or user account for accessing the Clog database. | +| image.clog.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the Clog container image. Default: `"IfNotPresent"`. | +| image.clog.registry | string | `""` | The registry where the Clog container image is hosted. Default: `"ghcr.io"`. | +| image.clog.repository | string | `""` | The name of the repository that contains the Clog container image used. Default: `"irfanhakim-as/clog"`. | +| image.clog.tag | string | `""` | The tag that specifies the version of the Clog container image used. Default: `"Chart appVersion"`. | +| image.ngrok.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the Ngrok container image. Default: `"IfNotPresent"`. | +| image.ngrok.registry | string | `""` | The registry where the Ngrok container image is hosted. Default: `"docker.io"`. | +| image.ngrok.repository | string | `""` | The name of the repository that contains the Ngrok container image used. Default: `"wernight/ngrok"`. | +| image.ngrok.tag | string | `""` | The tag that specifies the version of the Ngrok container image used. Default: `"latest"`. | +| imagePullSecrets | list | `[]` | Credentials used to securely authenticate and authorise the pulling of container images from private registries. | +| replicaCount | string | `""` | The desired number of running replicas for Clog. Default: `"1"`. | +| resources.clog.limits.cpu | string | `"50m"` | The maximum amount of CPU resources allowed for Clog. | +| resources.clog.limits.memory | string | `"200Mi"` | The maximum amount of memory allowed for Clog. | +| resources.clog.requests.cpu | string | `"10m"` | The minimum amount of CPU resources required by Clog. | +| resources.clog.requests.memory | string | `"100Mi"` | The minimum amount of memory required by Clog. | From ac309580b1ad8aa6f6511823844854552ed69dd7 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sun, 18 Jun 2023 17:35:14 +0800 Subject: [PATCH 099/117] Add step to upgrade a chart --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 148a54b2..2ef6b799 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,14 @@ Verify that your chart has been installed. Replace `$namespace` and `$release_na helm ls --namespace $namespace | grep "$release_name" ``` +## How to upgrade a chart + +After making any necessary changes to the `values.yaml` file, upgrade the desired chart. Replace `$release_name`, `$helm_chart` and `$namespace` accordingly. + +```sh +helm upgrade $release_name mika/$helm_chart --namespace $namespace --values values.yaml --wait +``` + ## How to uninstall a chart Uninstall the desired chart. Replace `$release_name` and `$namespace` accordingly. From 1455bcfa249b58116890217b808bef0da192f55b Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sun, 18 Jun 2023 20:55:28 +0800 Subject: [PATCH 100/117] Update step to deploy/delete database --- mika/clog/README.md | 4 ++-- mika/telego/README.md | 4 ++-- mika/vpbot/README.md | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mika/clog/README.md b/mika/clog/README.md index 5e36bcfb..a68cd822 100644 --- a/mika/clog/README.md +++ b/mika/clog/README.md @@ -39,7 +39,7 @@ helm repo update ### Create database -Install [`mika/postgres-createdb`](../postgres-createdb/). This step can be skipped if you have an existing PostgreSQL database. +Deploy [`mika/postgres-agent`](../postgres-agent/) with `postgres.mode.create` set to `true`. This step can be skipped if you have an existing PostgreSQL database. ### Prepare chart values @@ -87,7 +87,7 @@ helm uninstall $release_name --namespace $namespace --wait ### Delete database -Install [`mika/postgres-dropdb`](../postgres-dropdb/). +Deploy [`mika/postgres-agent`](../postgres-agent/) with `postgres.mode.drop` set to `true`. ## Configurations diff --git a/mika/telego/README.md b/mika/telego/README.md index 4c471578..f8a2af4c 100644 --- a/mika/telego/README.md +++ b/mika/telego/README.md @@ -39,7 +39,7 @@ helm repo update ### Create database -Install [`mika/postgres-createdb`](../postgres-createdb/). This step can be skipped if you have an existing PostgreSQL database. +Deploy [`mika/postgres-agent`](../postgres-agent/) with `postgres.mode.create` set to `true`. This step can be skipped if you have an existing PostgreSQL database. ### Prepare chart values @@ -181,7 +181,7 @@ helm uninstall $release_name --namespace $namespace --wait ### Delete database -Install [`mika/postgres-dropdb`](../postgres-dropdb/). +Deploy [`mika/postgres-agent`](../postgres-agent/) with `postgres.mode.drop` set to `true`. ## Configurations diff --git a/mika/vpbot/README.md b/mika/vpbot/README.md index df46c709..488b3c76 100644 --- a/mika/vpbot/README.md +++ b/mika/vpbot/README.md @@ -39,7 +39,7 @@ helm repo update ### Create database -Install [`mika/postgres-createdb`](../postgres-createdb/). This step can be skipped if you have an existing PostgreSQL database. +Deploy [`mika/postgres-agent`](../postgres-agent/) with `postgres.mode.create` set to `true`. This step can be skipped if you have an existing PostgreSQL database. ### Prepare chart values @@ -87,7 +87,7 @@ helm uninstall $release_name --namespace $namespace --wait ### Delete database -Install [`mika/postgres-dropdb`](../postgres-dropdb/). +Deploy [`mika/postgres-agent`](../postgres-agent/) with `postgres.mode.drop` set to `true`. ## Configurations From d985a630151edc2ae198237b6d7afd69c5a24151 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sun, 18 Jun 2023 21:16:54 +0800 Subject: [PATCH 101/117] Add info to refer to chart configurations table --- mika/clog/README.md | 2 +- mika/cloudflared/README.md | 2 +- mika/mango/README.md | 4 ++-- mika/postgres-agent/README.md | 2 +- mika/postgres/README.md | 2 +- mika/telego/README.md | 2 +- mika/vpbot/README.md | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mika/clog/README.md b/mika/clog/README.md index a68cd822..9c42cb69 100644 --- a/mika/clog/README.md +++ b/mika/clog/README.md @@ -49,7 +49,7 @@ Copy `values.yaml` from the chart you would like to install. cp mika/clog/values.yaml . ``` -Edit `values.yaml` with the appropriate values. Refer to the [Configurations](#Configurations) section for the available options. +Edit `values.yaml` with the appropriate values. Refer to the [Configurations](#Configurations) section for available options. ```sh nano values.yaml diff --git a/mika/cloudflared/README.md b/mika/cloudflared/README.md index 8cd79fc5..c7e75b72 100644 --- a/mika/cloudflared/README.md +++ b/mika/cloudflared/README.md @@ -53,7 +53,7 @@ Copy `values.yaml` from the chart you would like to install. cp mika/cloudflared/values.yaml . ``` -Edit `values.yaml` with the appropriate values. +Edit `values.yaml` with the appropriate values. Refer to the [Configurations](#Configurations) section for available options. ```sh nano values.yaml diff --git a/mika/mango/README.md b/mika/mango/README.md index 68fe7209..20cb3968 100644 --- a/mika/mango/README.md +++ b/mika/mango/README.md @@ -45,7 +45,7 @@ Copy `values.yaml` from the chart you would like to install. cp mika/mango/values.yaml . ``` -Edit `values.yaml` with the appropriate values. Refer to the [Configuration](#Configuration) section for available options. +Edit `values.yaml` with the appropriate values. Refer to the [Configurations](#Configurations) section for available options. ```sh nano values.yaml @@ -73,7 +73,7 @@ Uninstall the desired chart. Replace `$release_name` and `$namespace` accordingl helm uninstall $release_name --namespace $namespace --wait ``` -## Configuration +## Configurations | Key | Type | Default | Description | |-----|------|---------|-------------| diff --git a/mika/postgres-agent/README.md b/mika/postgres-agent/README.md index 1189d54e..519cbdcc 100644 --- a/mika/postgres-agent/README.md +++ b/mika/postgres-agent/README.md @@ -35,7 +35,7 @@ Copy `values.yaml` from the chart you would like to install. Refer to the [Confi cp mika/postgres-agent/values.yaml . ``` -Edit `values.yaml` with the appropriate values. +Edit `values.yaml` with the appropriate values. Refer to the [Configurations](#Configurations) section for available options. ```sh nano values.yaml diff --git a/mika/postgres/README.md b/mika/postgres/README.md index 2c7954af..cb7c9f9a 100644 --- a/mika/postgres/README.md +++ b/mika/postgres/README.md @@ -29,7 +29,7 @@ Copy `values.yaml` from the chart you would like to install. cp mika/postgres/values.yaml . ``` -Edit `values.yaml` with the appropriate values. Please refer to the [Configuration](#configuration) section below for more details. +Edit `values.yaml` with the appropriate values. Refer to the [Configurations](#Configurations) section for available options. ```sh nano values.yaml diff --git a/mika/telego/README.md b/mika/telego/README.md index f8a2af4c..a6386915 100644 --- a/mika/telego/README.md +++ b/mika/telego/README.md @@ -49,7 +49,7 @@ Copy `values.yaml` from the chart you would like to install. cp mika/telego/values.yaml . ``` -Edit `values.yaml` with the appropriate values. Refer to the [Configurations](#Configurations) section for the available options. +Edit `values.yaml` with the appropriate values. Refer to the [Configurations](#Configurations) section for available options. ```sh nano values.yaml diff --git a/mika/vpbot/README.md b/mika/vpbot/README.md index 488b3c76..f02d0063 100644 --- a/mika/vpbot/README.md +++ b/mika/vpbot/README.md @@ -49,7 +49,7 @@ Copy `values.yaml` from the chart you would like to install. cp mika/vpbot/values.yaml . ``` -Edit `values.yaml` with the appropriate values. Refer to the [Configurations](#Configurations) section for the available options. +Edit `values.yaml` with the appropriate values. Refer to the [Configurations](#Configurations) section for available options. ```sh nano values.yaml From e47e1b02ba09786545c584f6cdb16f3baee32ef2 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sun, 18 Jun 2023 21:59:04 +0800 Subject: [PATCH 102/117] Update chart version --- mika/clog/Chart.yaml | 2 +- mika/cloudflared/Chart.yaml | 2 +- mika/mango/Chart.yaml | 2 +- mika/postgres-agent/Chart.yaml | 2 +- mika/postgres/Chart.yaml | 2 +- mika/telego/Chart.yaml | 2 +- mika/vpbot/Chart.yaml | 2 +- mika/waktusolat/Chart.yaml | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mika/clog/Chart.yaml b/mika/clog/Chart.yaml index 3e062e62..51070d8a 100644 --- a/mika/clog/Chart.yaml +++ b/mika/clog/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: clog description: Creative blog, Career blog, Coin blog, you name it. type: application -version: 0.1.10 +version: 0.2.0 appVersion: "0.0.1-stable" keywords: - "clog" diff --git a/mika/cloudflared/Chart.yaml b/mika/cloudflared/Chart.yaml index 996ce495..945a2ce2 100644 --- a/mika/cloudflared/Chart.yaml +++ b/mika/cloudflared/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: cloudflared description: Cloudflare Tunnel is a tunneling software that lets you quickly secure and encrypt application traffic to any type of infrastructure. type: application -version: 0.1.0 +version: 0.2.0 appVersion: "2022.3.0" keywords: - "cloudflared" diff --git a/mika/mango/Chart.yaml b/mika/mango/Chart.yaml index 6d3f9806..b646332f 100644 --- a/mika/mango/Chart.yaml +++ b/mika/mango/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: mango description: Mango is an easy to use Mastodon bot framework built on top of Django. type: application -version: 0.1.1 +version: 0.2.0 appVersion: "0.0.1-stable" keywords: - mango diff --git a/mika/postgres-agent/Chart.yaml b/mika/postgres-agent/Chart.yaml index fec6238d..7f8bd6c8 100644 --- a/mika/postgres-agent/Chart.yaml +++ b/mika/postgres-agent/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: postgres-agent description: Easily deploy a database and create a user in a remote PostgreSQL instance or delete a database. type: application -version: 0.1.2 +version: 0.2.0 appVersion: "13.3" keywords: - "postgresql" diff --git a/mika/postgres/Chart.yaml b/mika/postgres/Chart.yaml index f414aa20..bfda1b72 100644 --- a/mika/postgres/Chart.yaml +++ b/mika/postgres/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: postgres description: Easy tool to deploy a PostgreSQL instance on Kubernetes. type: application -version: 0.1.5 +version: 0.2.0 appVersion: "13.3" keywords: - "PostgreSQL" diff --git a/mika/telego/Chart.yaml b/mika/telego/Chart.yaml index 16529238..d2a12f7d 100644 --- a/mika/telego/Chart.yaml +++ b/mika/telego/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: telego description: Telego is an easy to use Telegram bot framework built on top of Django. type: application -version: 0.1.9 +version: 0.2.0 appVersion: "0.0.3-stable" keywords: - "Telego" diff --git a/mika/vpbot/Chart.yaml b/mika/vpbot/Chart.yaml index 02ded2cb..5e2ab5fd 100644 --- a/mika/vpbot/Chart.yaml +++ b/mika/vpbot/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: vpbot description: Vpbot is a Telegram bot with support for a number of useful features such as prayer time notifications, COVID-19 statistics, and more. type: application -version: 0.2.1 +version: 0.3.0 appVersion: "1.5.6-stable" keywords: - "vpbot" diff --git a/mika/waktusolat/Chart.yaml b/mika/waktusolat/Chart.yaml index 2efe28d4..4e7c6400 100644 --- a/mika/waktusolat/Chart.yaml +++ b/mika/waktusolat/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: waktusolat description: Waktu Solat is a simple web application that posts local prayer times on Mastodon. type: application -version: 0.1.4 +version: 0.2.0 appVersion: "0.0.2-stable" keywords: - "waktu solat" From 99077b75779ecbef8c430462c89d39fba97acadb Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sun, 18 Jun 2023 23:40:51 +0800 Subject: [PATCH 103/117] Change app version --- mika/rizz/Chart.yaml | 2 +- mika/waktusolat/Chart.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mika/rizz/Chart.yaml b/mika/rizz/Chart.yaml index 37c56779..76d90132 100644 --- a/mika/rizz/Chart.yaml +++ b/mika/rizz/Chart.yaml @@ -3,7 +3,7 @@ name: rizz description: Rizz is a simple web application that tracks and posts content from RSS Feeds on Mastodon. type: application version: 0.0.1 -appVersion: "0.0.1-preview-r1" +appVersion: "0.0.1-stable-r1" keywords: - "rss" - "monitor" diff --git a/mika/waktusolat/Chart.yaml b/mika/waktusolat/Chart.yaml index 4e7c6400..bec1f72d 100644 --- a/mika/waktusolat/Chart.yaml +++ b/mika/waktusolat/Chart.yaml @@ -3,7 +3,7 @@ name: waktusolat description: Waktu Solat is a simple web application that posts local prayer times on Mastodon. type: application version: 0.2.0 -appVersion: "0.0.2-stable" +appVersion: "0.1.0-stable-r1" keywords: - "waktu solat" - "prayer time" From 5d6f96b9667300e2cf31fec3f4b3df8075fc776e Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Mon, 19 Jun 2023 14:25:10 +0800 Subject: [PATCH 104/117] Add value to set default post visibility --- mika/rizz/README.md | 1 + mika/rizz/templates/configmap.yaml | 2 ++ mika/rizz/values.yaml | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/mika/rizz/README.md b/mika/rizz/README.md index e2092112..c1986cdc 100644 --- a/mika/rizz/README.md +++ b/mika/rizz/README.md @@ -123,3 +123,4 @@ helm uninstall $release_name --namespace $namespace --wait | rizz.scheduler.schedule.update_data | string | `""` | The hours at which the task scheduler updates the database. Default: `"7-22/3"`. | | rizz.scheduler.timezone | string | `""` | The timezone for the task scheduler used by Rizz to schedule time-dependent operations. Default: `"Asia/Kuala_Lumpur"`. | | rizz.secret | string | `""` | A 50-character secret key used for secure session management and cryptographic operations within the Rizz service. | +| rizz.visibility | string | `""` | The default visibility of posts made by the Rizz service. Default: `"public"`. | diff --git a/mika/rizz/templates/configmap.yaml b/mika/rizz/templates/configmap.yaml index f5b66998..0a5e39fd 100644 --- a/mika/rizz/templates/configmap.yaml +++ b/mika/rizz/templates/configmap.yaml @@ -4,6 +4,7 @@ {{- $redis_service := printf "redis://%s-rizz-svc" .Release.Name | quote }} {{- $scheduler_timezone := .Values.rizz.scheduler.timezone | default "Asia/Kuala_Lumpur" | toString | quote }} {{- $domain := .Values.rizz.domain | default "localhost" | toString }} +{{- $visibility := .Values.rizz.visibility | default "public" | toString | quote }} {{- $feed := .Values.rizz.rss.feed | toString | quote }} {{- $post_limit := .Values.rizz.rss.post_limit | default "3" | toString | quote }} {{- $apscheduler := .Values.rizz.scheduler.apscheduler }} @@ -21,6 +22,7 @@ data: DEBUG: {{ $debug }} API_BASE_URL: {{ $api }} BOT_ID: {{ $bot }} + DEFAULT_VISIBILITY: {{ $visibility }} RSS_FEED_URL: {{ $feed }} RSS_POST_LIMIT: {{ $post_limit }} {{- if $celery }} diff --git a/mika/rizz/values.yaml b/mika/rizz/values.yaml index 0e054324..e0870216 100644 --- a/mika/rizz/values.yaml +++ b/mika/rizz/values.yaml @@ -59,6 +59,11 @@ rizz: # Example: # secret: "6&p4%t)-$8a14fmfh92py8j55+us51r6%e52dzy&=a3-6yd4#e" secret: "" + # The default visibility of posts made by the Rizz service. + # Default: "public" + # Example: + # visibility: "unlisted" + visibility: "" # Rizz Mastodon configurations. mastodon: # API endpoint or URL for the Mastodon instance of the Rizz bot. From 005fbe7c9cf2a4318da076a88d1f5f3442255a0b Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Mon, 19 Jun 2023 22:00:06 +0800 Subject: [PATCH 105/117] Add support for log persistence --- mika/rizz/README.md | 3 +++ mika/rizz/templates/deployment.yaml | 15 +++++++++++++++ mika/rizz/templates/pvc.yaml | 18 ++++++++++++++++++ mika/rizz/values.yaml | 18 ++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 mika/rizz/templates/pvc.yaml diff --git a/mika/rizz/README.md b/mika/rizz/README.md index c1986cdc..3e20563e 100644 --- a/mika/rizz/README.md +++ b/mika/rizz/README.md @@ -114,6 +114,9 @@ helm uninstall $release_name --namespace $namespace --wait | rizz.mastodon.api | string | `""` | API endpoint or URL for the Mastodon instance of the Rizz bot. | | rizz.mastodon.bot | string | `""` | The username or user account for the Mastodon instance of the Rizz bot. | | rizz.mastodon.token | string | `""` | A secure token required to authenticate the Rizz service with the Mastodon instance's API. | +| rizz.persistence.enabled | bool | `false` | Specifies whether Rizz should persist its storage. | +| rizz.persistence.logs.storage | string | `""` | The amount of persistent storage allocated for Rizz logs. Default: `"20Mi"`. | +| rizz.persistence.storageClassName | string | `""` | The storage class name used for dynamically provisioning a persistent volume for the Rizz storage. Default: `"longhorn"`. | | rizz.rss.feed | string | `""` | The URL of the RSS feed to be tracked by Rizz. | | rizz.rss.post_limit | string | `""` | The limit number of posts to be scheduled for posting by Rizz per run. Default: `"3"`. | | rizz.scheduler.apscheduler | bool | `true` | Specifies whether APScheduler should be used by Rizz as the task scheduler. | diff --git a/mika/rizz/templates/deployment.yaml b/mika/rizz/templates/deployment.yaml index 1da4325a..c06e76e8 100644 --- a/mika/rizz/templates/deployment.yaml +++ b/mika/rizz/templates/deployment.yaml @@ -9,6 +9,7 @@ {{- $redis_pullPolicy := .Values.image.redis.pullPolicy | default "IfNotPresent" | toString | quote }} {{- $apscheduler := .Values.rizz.scheduler.apscheduler }} {{- $celery := .Values.rizz.scheduler.celery }} +{{- $persistence := .Values.rizz.persistence.enabled }} apiVersion: apps/v1 kind: Deployment metadata: @@ -77,6 +78,10 @@ spec: mountPath: /base/base/mastodon.secret subPath: mastodon.secret readOnly: true + {{- if $persistence }} + - name: {{ .Release.Name }}-rizz-logs + mountPath: /var/log/apache2 + {{- end }} {{- if $apscheduler }} - name: apscheduler image: {{ printf "%s/%s:%s" $rizz_registry $rizz_repository $rizz_tag | quote }} @@ -106,6 +111,10 @@ spec: mountPath: /base/base/mastodon.secret subPath: mastodon.secret readOnly: true + {{- if $persistence }} + - name: {{ .Release.Name }}-rizz-logs + mountPath: /var/log/apache2 + {{- end }} {{- else if $celery }} - name: redis image: {{ printf "%s/%s:%s" $redis_registry $redis_repository $redis_tag | quote }} @@ -168,5 +177,11 @@ spec: - name: {{ .Release.Name }}-rizz-token-secret secret: secretName: {{ .Release.Name }}-rizz-token-secret + {{- if $persistence }} + - name: {{ .Release.Name }}-rizz-logs + persistentVolumeClaim: + claimName: {{ .Release.Name }}-rizz-logs-pvc + defaultMode: 0775 + {{- end }} securityContext: fsGroup: 33 diff --git a/mika/rizz/templates/pvc.yaml b/mika/rizz/templates/pvc.yaml new file mode 100644 index 00000000..e5b339a4 --- /dev/null +++ b/mika/rizz/templates/pvc.yaml @@ -0,0 +1,18 @@ +{{- $logs_storage := .Values.rizz.persistence.logs.storage | default "20Mi" | toString | quote }} +{{- $storage_class_name := .Values.rizz.persistence.storageClassName | default "longhorn" | toString | quote }} +{{- $persistence := .Values.rizz.persistence.enabled }} +{{- if $persistence }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-rizz-logs-pvc + labels: + {{- include "rizz.labels" . | nindent 4 }} +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: {{ $logs_storage }} + storageClassName: {{ $storage_class_name }} +{{- end }} diff --git a/mika/rizz/values.yaml b/mika/rizz/values.yaml index e0870216..79ac8ee0 100644 --- a/mika/rizz/values.yaml +++ b/mika/rizz/values.yaml @@ -78,6 +78,24 @@ rizz: # Example: # token: "6&p4%t)-$8a14fmfh92py8j55+us51r6%e52dzy&=a3-6yd4#e" token: "" + # Rizz storage persistence configurations. + persistence: + # Specifies whether Rizz should persist its storage. + # Example: + # enabled: true + enabled: false + # The storage class name used for dynamically provisioning a persistent volume for the Rizz storage. + # Default: "longhorn" + # Example: + # storageClassName: "longhorn" + storageClassName: "" + # Rizz logs persistence configurations. + logs: + # The amount of persistent storage allocated for Rizz logs. + # Default: "20Mi" + # Example: + # storage: "1Gi" + storage: "" # Rizz RSS configurations. rss: # The URL of the RSS feed to be tracked by Rizz. From 6ec0d19b6f5bc39406e437beabc1dc11f8da20c0 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Tue, 20 Jun 2023 10:38:33 +0800 Subject: [PATCH 106/117] Add support for log persistence --- mika/waktusolat/README.md | 3 +++ mika/waktusolat/templates/deployment.yaml | 15 +++++++++++++++ mika/waktusolat/templates/pvc.yaml | 18 ++++++++++++++++++ mika/waktusolat/values.yaml | 18 ++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 mika/waktusolat/templates/pvc.yaml diff --git a/mika/waktusolat/README.md b/mika/waktusolat/README.md index 9638db84..b8124642 100644 --- a/mika/waktusolat/README.md +++ b/mika/waktusolat/README.md @@ -115,6 +115,9 @@ helm uninstall $release_name --namespace $namespace --wait | waktusolat.mastodon.api | string | `""` | API endpoint or URL for the Mastodon instance of the WaktuSolat bot. | | waktusolat.mastodon.bot | string | `""` | The username or user account for the Mastodon instance of the WaktuSolat bot. | | waktusolat.mastodon.token | string | `""` | A secure token required to authenticate the WaktuSolat service with the Mastodon instance's API. | +| waktusolat.persistence.enabled | bool | `false` | Specifies whether WaktuSolat should persist its storage. | +| waktusolat.persistence.logs.storage | string | `""` | The amount of persistent storage allocated for WaktuSolat logs. Default: `"20Mi"`. | +| waktusolat.persistence.storageClassName | string | `""` | The storage class name used for dynamically provisioning a persistent volume for the WaktuSolat storage. Default: `"longhorn"`. | | waktusolat.scheduler.apscheduler | bool | `true` | Specifies whether APScheduler should be used by WaktuSolat as the task scheduler. | | waktusolat.scheduler.celery | bool | `false` | Specifies whether Celery should be used by WaktuSolat as the task scheduler. | | waktusolat.scheduler.timezone | string | `""` | The timezone for the task scheduler used by WaktuSolat to schedule time-dependent operations. Default: `"Asia/Kuala_Lumpur"`. | diff --git a/mika/waktusolat/templates/deployment.yaml b/mika/waktusolat/templates/deployment.yaml index c99dbed0..d6b05fa0 100644 --- a/mika/waktusolat/templates/deployment.yaml +++ b/mika/waktusolat/templates/deployment.yaml @@ -9,6 +9,7 @@ {{- $redis_pullPolicy := .Values.image.redis.pullPolicy | default "IfNotPresent" | toString | quote }} {{- $apscheduler := .Values.waktusolat.scheduler.apscheduler }} {{- $celery := .Values.waktusolat.scheduler.celery }} +{{- $persistence := .Values.waktusolat.persistence.enabled }} apiVersion: apps/v1 kind: Deployment metadata: @@ -77,6 +78,10 @@ spec: mountPath: /base/base/mastodon.secret subPath: mastodon.secret readOnly: true + {{- if $persistence }} + - name: {{ .Release.Name }}-waktusolat-logs + mountPath: /var/log/apache2 + {{- end }} {{- if $apscheduler }} - name: apscheduler image: {{ printf "%s/%s:%s" $waktusolat_registry $waktusolat_repository $waktusolat_tag | quote }} @@ -106,6 +111,10 @@ spec: mountPath: /base/base/mastodon.secret subPath: mastodon.secret readOnly: true + {{- if $persistence }} + - name: {{ .Release.Name }}-waktusolat-logs + mountPath: /var/log/apache2 + {{- end }} {{- else if $celery }} - name: redis image: {{ printf "%s/%s:%s" $redis_registry $redis_repository $redis_tag | quote }} @@ -168,5 +177,11 @@ spec: - name: {{ .Release.Name }}-waktusolat-token-secret secret: secretName: {{ .Release.Name }}-waktusolat-token-secret + {{- if $persistence }} + - name: {{ .Release.Name }}-waktusolat-logs + persistentVolumeClaim: + claimName: {{ .Release.Name }}-waktusolat-logs-pvc + defaultMode: 0775 + {{- end }} securityContext: fsGroup: 33 diff --git a/mika/waktusolat/templates/pvc.yaml b/mika/waktusolat/templates/pvc.yaml new file mode 100644 index 00000000..40ea8c1d --- /dev/null +++ b/mika/waktusolat/templates/pvc.yaml @@ -0,0 +1,18 @@ +{{- $logs_storage := .Values.waktusolat.persistence.logs.storage | default "20Mi" | toString | quote }} +{{- $storage_class_name := .Values.waktusolat.persistence.storageClassName | default "longhorn" | toString | quote }} +{{- $persistence := .Values.waktusolat.persistence.enabled }} +{{- if $persistence }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-waktusolat-logs-pvc + labels: + {{- include "waktusolat.labels" . | nindent 4 }} +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: {{ $logs_storage }} + storageClassName: {{ $storage_class_name }} +{{- end }} diff --git a/mika/waktusolat/values.yaml b/mika/waktusolat/values.yaml index 122c54b9..132859f8 100644 --- a/mika/waktusolat/values.yaml +++ b/mika/waktusolat/values.yaml @@ -78,6 +78,24 @@ waktusolat: # Example: # token: "6&p4%t)-$8a14fmfh92py8j55+us51r6%e52dzy&=a3-6yd4#e" token: "" + # WaktuSolat storage persistence configurations. + persistence: + # Specifies whether WaktuSolat should persist its storage. + # Example: + # enabled: true + enabled: false + # The storage class name used for dynamically provisioning a persistent volume for the WaktuSolat storage. + # Default: "longhorn" + # Example: + # storageClassName: "longhorn" + storageClassName: "" + # WaktuSolat logs persistence configurations. + logs: + # The amount of persistent storage allocated for WaktuSolat logs. + # Default: "20Mi" + # Example: + # storage: "1Gi" + storage: "" # WaktuSolat scheduler configurations. scheduler: # Specifies whether APScheduler should be used by WaktuSolat as the task scheduler. From bf10cd389e4f48aec92529253885b25f67e2e269 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Tue, 20 Jun 2023 11:59:05 +0800 Subject: [PATCH 107/117] Reorder same values --- mika/rizz/templates/configmap.yaml | 8 ++++---- mika/waktusolat/templates/configmap.yaml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mika/rizz/templates/configmap.yaml b/mika/rizz/templates/configmap.yaml index 0a5e39fd..633a0915 100644 --- a/mika/rizz/templates/configmap.yaml +++ b/mika/rizz/templates/configmap.yaml @@ -1,17 +1,17 @@ {{- $debug := .Values.rizz.debug | default "false" | toString | quote }} {{- $api := .Values.rizz.mastodon.api | toString | quote }} {{- $bot := .Values.rizz.mastodon.bot | toString | quote }} -{{- $redis_service := printf "redis://%s-rizz-svc" .Release.Name | quote }} {{- $scheduler_timezone := .Values.rizz.scheduler.timezone | default "Asia/Kuala_Lumpur" | toString | quote }} -{{- $domain := .Values.rizz.domain | default "localhost" | toString }} {{- $visibility := .Values.rizz.visibility | default "public" | toString | quote }} {{- $feed := .Values.rizz.rss.feed | toString | quote }} {{- $post_limit := .Values.rizz.rss.post_limit | default "3" | toString | quote }} -{{- $apscheduler := .Values.rizz.scheduler.apscheduler }} -{{- $celery := .Values.rizz.scheduler.celery }} {{- $clean_data := .Values.rizz.scheduler.schedule.clean_data | default "0" | toString | quote }} {{- $post_scheduler := .Values.rizz.scheduler.schedule.post_scheduler | default "8-23/3" | toString | quote }} {{- $update_data := .Values.rizz.scheduler.schedule.update_data | default "7-22/3" | toString | quote }} +{{- $redis_service := printf "redis://%s-rizz-svc" .Release.Name | quote }} +{{- $domain := .Values.rizz.domain | default "localhost" | toString }} +{{- $apscheduler := .Values.rizz.scheduler.apscheduler }} +{{- $celery := .Values.rizz.scheduler.celery }} apiVersion: v1 kind: ConfigMap metadata: diff --git a/mika/waktusolat/templates/configmap.yaml b/mika/waktusolat/templates/configmap.yaml index b18a89f2..f72bcdf1 100644 --- a/mika/waktusolat/templates/configmap.yaml +++ b/mika/waktusolat/templates/configmap.yaml @@ -2,8 +2,8 @@ {{- $location := .Values.waktusolat.location | default "wlp-0" | toString | quote }} {{- $api := .Values.waktusolat.mastodon.api | toString | quote }} {{- $bot := .Values.waktusolat.mastodon.bot | toString | quote }} -{{- $redis_service := printf "redis://%s-waktusolat-svc" .Release.Name | quote }} {{- $scheduler_timezone := .Values.waktusolat.scheduler.timezone | default "Asia/Kuala_Lumpur" | toString | quote }} +{{- $redis_service := printf "redis://%s-waktusolat-svc" .Release.Name | quote }} {{- $domain := .Values.waktusolat.domain | default "localhost" | toString }} {{- $apscheduler := .Values.waktusolat.scheduler.apscheduler }} {{- $celery := .Values.waktusolat.scheduler.celery }} From 0a78bd4b79768e33e45d24d2aadc8625aebb8156 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 22 Jun 2023 21:24:28 +0800 Subject: [PATCH 108/117] PVC does not support defaultMode --- mika/rizz/templates/deployment.yaml | 1 - mika/waktusolat/templates/deployment.yaml | 1 - 2 files changed, 2 deletions(-) diff --git a/mika/rizz/templates/deployment.yaml b/mika/rizz/templates/deployment.yaml index c06e76e8..71796f93 100644 --- a/mika/rizz/templates/deployment.yaml +++ b/mika/rizz/templates/deployment.yaml @@ -181,7 +181,6 @@ spec: - name: {{ .Release.Name }}-rizz-logs persistentVolumeClaim: claimName: {{ .Release.Name }}-rizz-logs-pvc - defaultMode: 0775 {{- end }} securityContext: fsGroup: 33 diff --git a/mika/waktusolat/templates/deployment.yaml b/mika/waktusolat/templates/deployment.yaml index d6b05fa0..e3749b07 100644 --- a/mika/waktusolat/templates/deployment.yaml +++ b/mika/waktusolat/templates/deployment.yaml @@ -181,7 +181,6 @@ spec: - name: {{ .Release.Name }}-waktusolat-logs persistentVolumeClaim: claimName: {{ .Release.Name }}-waktusolat-logs-pvc - defaultMode: 0775 {{- end }} securityContext: fsGroup: 33 From 74071f351fa4737051ae3db7efb5d617d3e74323 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Sun, 25 Jun 2023 23:47:26 +0800 Subject: [PATCH 109/117] Update postgres minimum memory --- mika/postgres/README.md | 2 +- mika/postgres/values.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mika/postgres/README.md b/mika/postgres/README.md index cb7c9f9a..75dbc857 100644 --- a/mika/postgres/README.md +++ b/mika/postgres/README.md @@ -82,4 +82,4 @@ helm uninstall $release_name --namespace $namespace --wait | resources.limits.cpu | string | `"250m"` | The maximum amount of CPU resources allowed for PostgreSQL. | | resources.limits.memory | string | `"250Mi"` | The maximum amount of memory allowed for PostgreSQL. | | resources.requests.cpu | string | `"10m"` | The minimum amount of CPU resources required by PostgreSQL. | -| resources.requests.memory | string | `"10Mi"` | The minimum amount of memory required by PostgreSQL. | +| resources.requests.memory | string | `"100Mi"` | The minimum amount of memory required by PostgreSQL. | diff --git a/mika/postgres/values.yaml b/mika/postgres/values.yaml index a93398e4..145d2e9f 100644 --- a/mika/postgres/values.yaml +++ b/mika/postgres/values.yaml @@ -61,7 +61,7 @@ resources: # The minimum amount of memory required by PostgreSQL. # Example: # memory: "10Mi" - memory: "10Mi" + memory: "100Mi" # The maximum amount of resources allowed for PostgreSQL. limits: # The maximum amount of CPU resources allowed for PostgreSQL. From 53f5d1d4f291f9efc29cb606ee2f37800af2c075 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Wed, 12 Jul 2023 19:43:17 +0800 Subject: [PATCH 110/117] Add new pubdate_format variable --- mika/rizz/README.md | 1 + mika/rizz/templates/configmap.yaml | 2 ++ mika/rizz/values.yaml | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/mika/rizz/README.md b/mika/rizz/README.md index 3e20563e..b97346ef 100644 --- a/mika/rizz/README.md +++ b/mika/rizz/README.md @@ -119,6 +119,7 @@ helm uninstall $release_name --namespace $namespace --wait | rizz.persistence.storageClassName | string | `""` | The storage class name used for dynamically provisioning a persistent volume for the Rizz storage. Default: `"longhorn"`. | | rizz.rss.feed | string | `""` | The URL of the RSS feed to be tracked by Rizz. | | rizz.rss.post_limit | string | `""` | The limit number of posts to be scheduled for posting by Rizz per run. Default: `"3"`. | +| rizz.rss.pubdate_format | string | `""` | The publishing date format of the RSS feed entry. Default: `"%a, %d %b %Y %H:%M:%S %z"`. | | rizz.scheduler.apscheduler | bool | `true` | Specifies whether APScheduler should be used by Rizz as the task scheduler. | | rizz.scheduler.celery | bool | `false` | Specifies whether Celery should be used by Rizz as the task scheduler. | | rizz.scheduler.schedule.clean_data | string | `""` | The hours at which the task scheduler cleans up the database. Default: `"0"`. | diff --git a/mika/rizz/templates/configmap.yaml b/mika/rizz/templates/configmap.yaml index 633a0915..85a45fa1 100644 --- a/mika/rizz/templates/configmap.yaml +++ b/mika/rizz/templates/configmap.yaml @@ -5,6 +5,7 @@ {{- $visibility := .Values.rizz.visibility | default "public" | toString | quote }} {{- $feed := .Values.rizz.rss.feed | toString | quote }} {{- $post_limit := .Values.rizz.rss.post_limit | default "3" | toString | quote }} +{{- $pubdate_format := .Values.rizz.rss.pubdate_format | default "%a, %d %b %Y %H:%M:%S %z" | toString | quote }} {{- $clean_data := .Values.rizz.scheduler.schedule.clean_data | default "0" | toString | quote }} {{- $post_scheduler := .Values.rizz.scheduler.schedule.post_scheduler | default "8-23/3" | toString | quote }} {{- $update_data := .Values.rizz.scheduler.schedule.update_data | default "7-22/3" | toString | quote }} @@ -25,6 +26,7 @@ data: DEFAULT_VISIBILITY: {{ $visibility }} RSS_FEED_URL: {{ $feed }} RSS_POST_LIMIT: {{ $post_limit }} + RSS_PUBDATE_FORMAT: {{ $pubdate_format }} {{- if $celery }} CELERY_BROKER: {{ $redis_service }} CELERY_BACKEND: {{ $redis_service }} diff --git a/mika/rizz/values.yaml b/mika/rizz/values.yaml index 79ac8ee0..a2a6f74e 100644 --- a/mika/rizz/values.yaml +++ b/mika/rizz/values.yaml @@ -107,6 +107,11 @@ rizz: # Example: # post_limit: "5" post_limit: "" + # The publishing date format of the RSS feed entry. + # Default: "%a, %d %b %Y %H:%M:%S %z" + # Example: + # pubdate_format: "%a, %d %b %Y %H:%M:%S %Z" + pubdate_format: "" # Rizz scheduler configurations. scheduler: # Specifies whether APScheduler should be used by Rizz as the task scheduler. From 574743a81eb3a8b16068b00c523c50eb46da526d Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 20 Jul 2023 15:48:14 +0800 Subject: [PATCH 111/117] Add new chart grocy --- mika/grocy/.helmignore | 23 +++++ mika/grocy/Chart.yaml | 17 ++++ mika/grocy/README.md | 98 ++++++++++++++++++ mika/grocy/templates/NOTES.txt | 5 + mika/grocy/templates/_helpers.tpl | 88 +++++++++++++++++ mika/grocy/templates/configmap.yaml | 36 +++++++ mika/grocy/templates/deployment.yaml | 88 +++++++++++++++++ mika/grocy/templates/pvc.yaml | 15 +++ mika/grocy/templates/service.yaml | 19 ++++ mika/grocy/values.yaml | 142 +++++++++++++++++++++++++++ 10 files changed, 531 insertions(+) create mode 100644 mika/grocy/.helmignore create mode 100644 mika/grocy/Chart.yaml create mode 100644 mika/grocy/README.md create mode 100644 mika/grocy/templates/NOTES.txt create mode 100644 mika/grocy/templates/_helpers.tpl create mode 100644 mika/grocy/templates/configmap.yaml create mode 100644 mika/grocy/templates/deployment.yaml create mode 100644 mika/grocy/templates/pvc.yaml create mode 100644 mika/grocy/templates/service.yaml create mode 100644 mika/grocy/values.yaml diff --git a/mika/grocy/.helmignore b/mika/grocy/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/mika/grocy/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/mika/grocy/Chart.yaml b/mika/grocy/Chart.yaml new file mode 100644 index 00000000..b3814bfc --- /dev/null +++ b/mika/grocy/Chart.yaml @@ -0,0 +1,17 @@ +apiVersion: v2 +name: grocy +description: Grocy is a web-based self-hosted groceries & household management solution for your home. +type: application +version: 0.0.1 +appVersion: "v3.3.2" +keywords: + - "grocy" +home: "https://github.com/grocy/grocy" +icon: "https://raw.githubusercontent.com/grocy/grocy/master/public/img/logo.svg" +sources: + - "https://github.com/grocy/grocy" + - "https://github.com/irfanhakim-as/charts" +maintainers: + - name: "Irfan Hakim" + email: "irfanhakim.as@yahoo.com" + url: "https://github.com/irfanhakim-as" diff --git a/mika/grocy/README.md b/mika/grocy/README.md new file mode 100644 index 00000000..b9e33faf --- /dev/null +++ b/mika/grocy/README.md @@ -0,0 +1,98 @@ +# `grocy` + +## Prerequisites + +- Kubernetes 1.19+ +- Helm 3.2.0+ + +## How to add repo + +Add the repo to your local helm client. + +```sh +helm repo add mika https://irfanhakim-as.github.io/charts +``` + +Update the repo to retrieve the latest versions of the packages. + +```sh +helm repo update +``` + +## How to install + +### Prepare chart values + +Copy `values.yaml` from the chart you would like to install. + +```sh +cp mika/grocy/values.yaml . +``` + +Edit `values.yaml` with the appropriate values. Please refer to the [Configurations](#configurations) section below, or the `values.yaml` file itself for details and sample values. + +```sh +nano values.yaml +``` + +### Perform installation + +Install the desired chart. Replace `$release_name` and `$namespace` accordingly. + +```sh +helm install $release_name mika/grocy --namespace $namespace --create-namespace --values values.yaml --wait +``` + +Verify that your chart has been installed. Replace `$namespace` and `$release_name` accordingly. + +```sh +helm ls --namespace $namespace | grep "$release_name" +``` + +## How to upgrade + +After making any necessary changes to the `values.yaml` file, upgrade the desired chart. Replace `$release_name` and `$namespace` accordingly. + +```sh +helm upgrade $release_name mika/grocy --namespace $namespace --values values.yaml --wait +``` + +## How to uninstall + +Uninstall the desired chart. Replace `$release_name` and `$namespace` accordingly. + +```sh +helm uninstall $release_name --namespace $namespace --wait +``` + +## Configurations + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| grocy.culture | string | `""` | The localisation of the Grocy application. Default: `"en_GB"`. | +| grocy.currency | string | `""` | The currency used to format all monetary values in Grocy. Default: `"MYR"`. | +| grocy.data.storage | string | `""` | The amount of persistent storage allocated for the Grocy instance. Default: `"500Mi"`. | +| grocy.data.storageClassName | string | `""` | The storage class name used for dynamically provisioning a persistent volume for the Grocy storage. Default: `"longhorn"`. | +| grocy.energy | string | `""` | The preferred unit for displaying energy values in Grocy. Default: `"kcal"`. | +| grocy.mode | string | `""` | The mode to deploy grocy in which determines whether to enable user authentication. Default: `"production"`. | +| grocy.php.file_limit | string | `""` | Sets the maximum number of files that can be uploaded simultaneously through PHP. Default: `"200"`. | +| grocy.php.memory_limit | string | `""` | Determines the maximum amount of memory that PHP can allocate for executing scripts. Default: `"512M"`. | +| grocy.php.post_limit | string | `""` | Defines the maximum size of the entire HTTP POST request that PHP can handle. Default: `"100M"`. | +| grocy.php.upload_limit | string | `""` | Specifies the maximum size of an individual file that can be uploaded through PHP. Default: `"50M"`. | +| image.backend.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the backend container image. Default: `"IfNotPresent"`. | +| image.backend.registry | string | `""` | The registry where the backend container image is hosted. Default: `"docker.io"`. | +| image.backend.repository | string | `""` | The name of the repository that contains the backend container image used. Default: `"grocy/backend"`. | +| image.backend.tag | string | `""` | The tag that specifies the version of the backend container image used. Default: `Chart appVersion`. | +| image.frontend.pullPolicy | string | `""` | The policy that determines when Kubernetes should pull the frontend container image. Default: `"IfNotPresent"`. | +| image.frontend.registry | string | `""` | The registry where the frontend container image is hosted. Default: `"docker.io"`. | +| image.frontend.repository | string | `""` | The name of the repository that contains the frontend container image used. Default: `"grocy/frontend"`. | +| image.frontend.tag | string | `""` | The tag that specifies the version of the frontend container image used. Default: `Chart appVersion`. | +| replicaCount | string | `""` | The desired number of running replicas for Grocy. | +| resources.backend.limits.cpu | string | `"100m"` | The maximum amount of CPU resources allowed for the backend. | +| resources.backend.limits.memory | string | `"100Mi"` | The maximum amount of memory allowed for the backend. | +| resources.backend.requests.cpu | string | `"50m"` | The minimum amount of CPU resources required by the backend. | +| resources.backend.requests.memory | string | `"50Mi"` | The minimum amount of memory required by the backend. | +| resources.frontend.limits.cpu | string | `"100m"` | The maximum amount of CPU resources allowed for the frontend. | +| resources.frontend.limits.memory | string | `"50Mi"` | The maximum amount of memory allowed for the frontend. | +| resources.frontend.requests.cpu | string | `"10m"` | The minimum amount of CPU resources required by the frontend. | +| resources.frontend.requests.memory | string | `"10Mi"` | The minimum amount of memory required by the frontend. | diff --git a/mika/grocy/templates/NOTES.txt b/mika/grocy/templates/NOTES.txt new file mode 100644 index 00000000..15b08f79 --- /dev/null +++ b/mika/grocy/templates/NOTES.txt @@ -0,0 +1,5 @@ +Grocy is now installed and configured for {{ .Release.Name | toString }}. + +See the values.yaml file of this chart for more configuration options. + +Please refer to the official documentation for more information on how to use Grocy. diff --git a/mika/grocy/templates/_helpers.tpl b/mika/grocy/templates/_helpers.tpl new file mode 100644 index 00000000..421135fb --- /dev/null +++ b/mika/grocy/templates/_helpers.tpl @@ -0,0 +1,88 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "grocy.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "grocy.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "grocy.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "grocy.labels" -}} +helm.sh/chart: {{ include "grocy.chart" . }} +{{ include "grocy.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "grocy.selectorLabels" -}} +app.kubernetes.io/name: {{ include "grocy.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "grocy.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "grocy.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{/* +Nginx common.conf template +*/}} +{{- define "grocy.common-conf" -}} +charset utf-8; + +location / { + try_files $uri /index.php$is_args$query_string; +} + +location ~* .(jpg|jpeg|png|gif|ico|css|js)$ { + expires 365d; +} + +location ~ \.php$ { + fastcgi_pass {{ .Release.Name }}-grocy-svc:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; +} + +location ~ /\.ht { + deny all; +} +{{- end }} diff --git a/mika/grocy/templates/configmap.yaml b/mika/grocy/templates/configmap.yaml new file mode 100644 index 00000000..ddd8c6bc --- /dev/null +++ b/mika/grocy/templates/configmap.yaml @@ -0,0 +1,36 @@ +{{- $frontend_tag := .Values.image.frontend.tag | default .Chart.AppVersion | toString }} +{{- $mode := .Values.grocy.mode | default "production" | toString | quote }} +{{- $culture := .Values.grocy.culture | default "en_GB" | toString | quote }} +{{- $currency := .Values.grocy.currency | default "MYR" | toString | quote }} +{{- $energy := .Values.grocy.energy | default "kcal" | toString | quote }} +{{- $upload_limit := .Values.grocy.php.upload_limit | default "50M" | toString | quote }} +{{- $file_limit := .Values.grocy.php.file_limit | default "200" | toString | quote }} +{{- $post_limit := .Values.grocy.php.post_limit | default "100M" | toString | quote }} +{{- $memory_limit := .Values.grocy.php.memory_limit | default "512M" | toString | quote }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-grocy-cm + labels: + {{- include "grocy.labels" . | nindent 4 }} +data: + GROCY_VERSION: {{ $frontend_tag }} + PLATFORM: "linux/amd64" + GROCY_MODE: {{ $mode }} + GROCY_CULTURE: {{ $culture }} + GROCY_CURRENCY: {{ $currency }} + GROCY_ENERGY_UNIT: {{ $energy }} + MAX_UPLOAD: {{ $upload_limit }} + PHP_MAX_FILE_UPLOAD: {{ $file_limit }} + PHP_MAX_POST: {{ $post_limit }} + PHP_MEMORY_LIMIT: {{ $memory_limit }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-grocy-nginx-config + labels: + {{- include "grocy.labels" . | nindent 4 }} +data: + common.conf: | + {{- include "grocy.common-conf" . | nindent 4 }} diff --git a/mika/grocy/templates/deployment.yaml b/mika/grocy/templates/deployment.yaml new file mode 100644 index 00000000..d67bf2b3 --- /dev/null +++ b/mika/grocy/templates/deployment.yaml @@ -0,0 +1,88 @@ +{{- $backend_registry := .Values.image.backend.registry | default "docker.io" | toString }} +{{- $backend_repository := .Values.image.backend.repository | default "grocy/backend" | toString }} +{{- $backend_tag := .Values.image.backend.tag | default .Chart.AppVersion | toString }} +{{- $backend_pullPolicy := .Values.image.backend.pullPolicy | default "IfNotPresent" | toString | quote }} +{{- $frontend_registry := .Values.image.frontend.registry | default "docker.io" | toString }} +{{- $frontend_repository := .Values.image.frontend.repository | default "grocy/frontend" | toString }} +{{- $frontend_tag := .Values.image.frontend.tag | default .Chart.AppVersion | toString }} +{{- $frontend_pullPolicy := .Values.image.frontend.pullPolicy | default "IfNotPresent" | toString | quote }} +{{- $replica_count := .Values.replicaCount | default "1" | toString }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-grocy + labels: + {{- include "grocy.labels" . | nindent 4 }} +spec: + replicas: {{ int $replica_count }} + selector: + matchLabels: + {{- include "grocy.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "grocy.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + initContainers: + - name: copy-data + image: {{ printf "%s/%s:%s" $backend_registry $backend_repository $backend_tag | quote }} + imagePullPolicy: {{ $backend_pullPolicy }} + command: ["sh", "-c", "cp -rf /var/www/data/. /scratch/data"] + volumeMounts: + - name: {{ .Release.Name }}-grocy-data + mountPath: /scratch/data + containers: + - name: backend + image: {{ printf "%s/%s:%s" $backend_registry $backend_repository $backend_tag | quote }} + imagePullPolicy: {{ $backend_pullPolicy }} + ports: + - name: backend + containerPort: 9000 + protocol: TCP + resources: + {{- toYaml .Values.resources.backend | nindent 12 }} + envFrom: + - configMapRef: + name: {{ .Release.Name }}-grocy-cm + volumeMounts: + - name: {{ .Release.Name }}-tmp-volume + mountPath: /tmp + - name: {{ .Release.Name }}-grocy-data + mountPath: /var/www/data + - name: frontend + image: {{ printf "%s/%s:%s" $frontend_registry $frontend_repository $frontend_tag | quote }} + imagePullPolicy: {{ $frontend_pullPolicy }} + ports: + - name: frontend + containerPort: 8080 + protocol: TCP + resources: + {{- toYaml .Values.resources.frontend | nindent 12 }} + envFrom: + - configMapRef: + name: {{ .Release.Name }}-grocy-cm + volumeMounts: + - name: {{ .Release.Name }}-tmp-volume + mountPath: /tmp + - name: {{ .Release.Name }}-grocy-nginx-config + mountPath: /etc/nginx/common.conf + subPath: common.conf + volumes: + - name: {{ .Release.Name }}-tmp-volume + emptyDir: {} + - name: {{ .Release.Name }}-grocy-nginx-config + configMap: + name: {{ .Release.Name }}-grocy-nginx-config + - name: {{ .Release.Name }}-grocy-data + persistentVolumeClaim: + claimName: {{ .Release.Name }}-grocy-data-pvc + securityContext: + fsGroup: 82 diff --git a/mika/grocy/templates/pvc.yaml b/mika/grocy/templates/pvc.yaml new file mode 100644 index 00000000..7d5c58bd --- /dev/null +++ b/mika/grocy/templates/pvc.yaml @@ -0,0 +1,15 @@ +{{- $storage := .Values.grocy.data.storage | default "500Mi" | toString | quote }} +{{- $storage_class_name := .Values.grocy.data.storageClassName | default "longhorn" | toString | quote }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Release.Name }}-grocy-data-pvc + labels: + {{- include "grocy.labels" . | nindent 4 }} +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: {{ $storage }} + storageClassName: {{ $storage_class_name }} diff --git a/mika/grocy/templates/service.yaml b/mika/grocy/templates/service.yaml new file mode 100644 index 00000000..9b7bf687 --- /dev/null +++ b/mika/grocy/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Release.Name }}-grocy-svc + labels: + {{- include "grocy.labels" . | nindent 4 }} +spec: + type: ClusterIP + ports: + - port: 9000 + targetPort: backend + protocol: TCP + name: {{ .Release.Name }}-grocy-backend + - port: 8080 + targetPort: frontend + protocol: TCP + name: {{ .Release.Name }}-grocy-frontend + selector: + {{- include "grocy.selectorLabels" . | nindent 4 }} diff --git a/mika/grocy/values.yaml b/mika/grocy/values.yaml new file mode 100644 index 00000000..4d98546b --- /dev/null +++ b/mika/grocy/values.yaml @@ -0,0 +1,142 @@ +# Default values for grocy. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# The desired number of running replicas for Grocy. +# Default: "1" +replicaCount: "" + +# Container images used for Grocy. +image: + # Backend container image configurations. + backend: + # The registry where the backend container image is hosted. + # Default: "docker.io" + registry: "" + # The name of the repository that contains the backend container image used. + # Default: "grocy/backend" + repository: "" + # The tag that specifies the version of the backend container image used. + # Default: Chart appVersion + tag: "" + # The policy that determines when Kubernetes should pull the backend container image. + # Default: "IfNotPresent" + pullPolicy: "" + # Frontend container image configurations. + frontend: + # The registry where the frontend container image is hosted. + # Default: "docker.io" + registry: "" + # The name of the repository that contains the frontend container image used. + # Default: "grocy/frontend" + repository: "" + # The tag that specifies the version of the frontend container image used. + # Default: Chart appVersion + tag: "" + # The policy that determines when Kubernetes should pull the frontend container image. + # Default: "IfNotPresent" + pullPolicy: "" + +# Grocy configurations. +grocy: + # The mode to deploy grocy in which determines whether to enable user authentication. + # Default: "production" + # Example: + # mode: "demo" + mode: "" + # The localisation of the Grocy application. + # Default: "en_GB" + # Example: + # culture: "en" + culture: "" + # The currency used to format all monetary values in Grocy. + # Default: "MYR" + # Example: + # currency: "USD" + currency: "" + # The preferred unit for displaying energy values in Grocy. + # Default: "kcal" + # Example: + # energy: "kJ" + energy: "" + # Grocy PHP configurations. + php: + # Specifies the maximum size of an individual file that can be uploaded through PHP. + # Default: "50M" + # Example: + # upload_limit: "100M" + upload_limit: "" + # Sets the maximum number of files that can be uploaded simultaneously through PHP. + # Default: "200" + # Example: + # file_limit: "100" + file_limit: "" + # Defines the maximum size of the entire HTTP POST request that PHP can handle. + # Default: "100M" + # Example: + # post_limit: "200M" + post_limit: "" + # Determines the maximum amount of memory that PHP can allocate for executing scripts. + # Default: "512M" + # Example: + # memory_limit: "256M" + memory_limit: "" + # Grocy data configurations. + data: + # The amount of persistent storage allocated for the Grocy instance. + # Default: "500Mi" + # Example: + # storage: "1Gi" + storage: "" + # The storage class name used for dynamically provisioning a persistent volume for the Grocy storage. + # Default: "longhorn" + # Example: + # storageClassName: "longhorn" + storageClassName: "" + +# Resource requirements and limits for Grocy containers. +resources: + # Backend container resources. + backend: + # The minimum amount of resources required by the backend to run. + requests: + # The minimum amount of CPU resources required by the backend. + # Example: + # cpu: "10m" + cpu: "50m" + # The minimum amount of memory required by the backend. + # Example: + # memory: "10Mi" + memory: "50Mi" + # The maximum amount of resources allowed for the backend. + limits: + # The maximum amount of CPU resources allowed for the backend. + # Example: + # cpu: "250m" + cpu: "100m" + # The maximum amount of memory allowed for the backend. + # Example: + # memory: "250Mi" + memory: "100Mi" + # Frontend container resources. + frontend: + # The minimum amount of resources required by the frontend to run. + requests: + # The minimum amount of CPU resources required by the frontend. + # Example: + # cpu: "10m" + cpu: "10m" + # The minimum amount of memory required by the frontend. + # Example: + # memory: "10Mi" + memory: "10Mi" + # The maximum amount of resources allowed for the frontend. + limits: + # The maximum amount of CPU resources allowed for the frontend. + # Example: + # cpu: "250m" + cpu: "100m" + # The maximum amount of memory allowed for the frontend. + # Example: + # memory: "250Mi" + memory: "50Mi" From fe1d58bd7ebb65b84888fd5e6980d0b5001c6efa Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 20 Jul 2023 16:15:29 +0800 Subject: [PATCH 112/117] Update rizz appVersion --- mika/rizz/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mika/rizz/Chart.yaml b/mika/rizz/Chart.yaml index 76d90132..b98fdcf4 100644 --- a/mika/rizz/Chart.yaml +++ b/mika/rizz/Chart.yaml @@ -3,7 +3,7 @@ name: rizz description: Rizz is a simple web application that tracks and posts content from RSS Feeds on Mastodon. type: application version: 0.0.1 -appVersion: "0.0.1-stable-r1" +appVersion: "0.0.1-beta-r2" keywords: - "rss" - "monitor" From 02d4eb02c2019b8c50fa5da49a6e0890590eeb58 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 20 Jul 2023 16:31:08 +0800 Subject: [PATCH 113/117] Add lock emoji to charts requiring a private image --- mika/clog/README.md | 2 +- mika/mango/README.md | 2 +- mika/rizz/README.md | 2 +- mika/telego/README.md | 2 +- mika/vpbot/README.md | 2 +- mika/waktusolat/README.md | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mika/clog/README.md b/mika/clog/README.md index 9c42cb69..1552b68d 100644 --- a/mika/clog/README.md +++ b/mika/clog/README.md @@ -1,4 +1,4 @@ -# `clog` +# `clog` 🔒 ## Prerequisites diff --git a/mika/mango/README.md b/mika/mango/README.md index 20cb3968..0bead05a 100644 --- a/mika/mango/README.md +++ b/mika/mango/README.md @@ -1,4 +1,4 @@ -# `mango` +# `mango` 🔒 ## Prerequisites diff --git a/mika/rizz/README.md b/mika/rizz/README.md index b97346ef..496ea22a 100644 --- a/mika/rizz/README.md +++ b/mika/rizz/README.md @@ -1,4 +1,4 @@ -# `rizz` +# `rizz` 🔒 ## Prerequisites diff --git a/mika/telego/README.md b/mika/telego/README.md index a6386915..eef7a9b8 100644 --- a/mika/telego/README.md +++ b/mika/telego/README.md @@ -1,4 +1,4 @@ -# [`telego`](https://github.com/irfanhakim-as/telego) +# [`telego`](https://github.com/irfanhakim-as/telego) 🔒 ## Prerequisites diff --git a/mika/vpbot/README.md b/mika/vpbot/README.md index f02d0063..4264dd1d 100644 --- a/mika/vpbot/README.md +++ b/mika/vpbot/README.md @@ -1,4 +1,4 @@ -# [`vpbot`](https://github.com/irfanhakim-as/quarantine-bot) +# [`vpbot`](https://github.com/irfanhakim-as/quarantine-bot) 🔒 ## Prerequisites diff --git a/mika/waktusolat/README.md b/mika/waktusolat/README.md index b8124642..b3befa10 100644 --- a/mika/waktusolat/README.md +++ b/mika/waktusolat/README.md @@ -1,4 +1,4 @@ -# `waktusolat` +# `waktusolat` 🔒 ## Prerequisites From b01d637f6368883582d34b2d32c20678806f357a Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 20 Jul 2023 16:35:39 +0800 Subject: [PATCH 114/117] Add app links --- mika/clog/README.md | 2 +- mika/cloudflared/README.md | 2 +- mika/grocy/README.md | 2 +- mika/mango/README.md | 2 +- mika/postgres-agent/README.md | 2 +- mika/postgres/README.md | 2 +- mika/rizz/README.md | 2 +- mika/waktusolat/README.md | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mika/clog/README.md b/mika/clog/README.md index 1552b68d..f94e7967 100644 --- a/mika/clog/README.md +++ b/mika/clog/README.md @@ -1,4 +1,4 @@ -# `clog` 🔒 +# [`clog`](https://github.com/irfanhakim-as/clog) 🔒 ## Prerequisites diff --git a/mika/cloudflared/README.md b/mika/cloudflared/README.md index c7e75b72..049dec3e 100644 --- a/mika/cloudflared/README.md +++ b/mika/cloudflared/README.md @@ -1,4 +1,4 @@ -# `cloudflared` +# [`cloudflared`](https://github.com/cloudflare/cloudflared) ## Prerequisites diff --git a/mika/grocy/README.md b/mika/grocy/README.md index b9e33faf..bcbaad98 100644 --- a/mika/grocy/README.md +++ b/mika/grocy/README.md @@ -1,4 +1,4 @@ -# `grocy` +# [`grocy`](https://github.com/grocy/grocy) ## Prerequisites diff --git a/mika/mango/README.md b/mika/mango/README.md index 0bead05a..633672d2 100644 --- a/mika/mango/README.md +++ b/mika/mango/README.md @@ -1,4 +1,4 @@ -# `mango` 🔒 +# [`mango`](https://github.com/irfanhakim-as/mango) 🔒 ## Prerequisites diff --git a/mika/postgres-agent/README.md b/mika/postgres-agent/README.md index 519cbdcc..7531e8b1 100644 --- a/mika/postgres-agent/README.md +++ b/mika/postgres-agent/README.md @@ -1,4 +1,4 @@ -# `postgres-agent` +# [`postgres-agent`](https://github.com/postgres/postgres) ## Prerequisites diff --git a/mika/postgres/README.md b/mika/postgres/README.md index 75dbc857..d70404a4 100644 --- a/mika/postgres/README.md +++ b/mika/postgres/README.md @@ -1,4 +1,4 @@ -# `postgres` +# [`postgres`](https://github.com/postgres/postgres) ## Prerequisites diff --git a/mika/rizz/README.md b/mika/rizz/README.md index 496ea22a..6bc5da07 100644 --- a/mika/rizz/README.md +++ b/mika/rizz/README.md @@ -1,4 +1,4 @@ -# `rizz` 🔒 +# [`rizz`](https://github.com/irfanhakim-as/rizz) 🔒 ## Prerequisites diff --git a/mika/waktusolat/README.md b/mika/waktusolat/README.md index b3befa10..7eb79da5 100644 --- a/mika/waktusolat/README.md +++ b/mika/waktusolat/README.md @@ -1,4 +1,4 @@ -# `waktusolat` 🔒 +# [`waktusolat`](https://github.com/irfanhakim-as/waktusolat) 🔒 ## Prerequisites From 620fecce54254493f8b54cdb5c82b127785806fc Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 20 Jul 2023 16:53:05 +0800 Subject: [PATCH 115/117] Updated description --- mika/rizz/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mika/rizz/Chart.yaml b/mika/rizz/Chart.yaml index b98fdcf4..4b4d7dbf 100644 --- a/mika/rizz/Chart.yaml +++ b/mika/rizz/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: rizz -description: Rizz is a simple web application that tracks and posts content from RSS Feeds on Mastodon. +description: Rizz is a simple web application that tracks and posts content from RSS Feeds to Mastodon. type: application version: 0.0.1 appVersion: "0.0.1-beta-r2" From 1d8754a31f534853ae61afc7923afddc01585982 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 20 Jul 2023 17:00:02 +0800 Subject: [PATCH 116/117] Update chart description --- mika/postgres-agent/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mika/postgres-agent/Chart.yaml b/mika/postgres-agent/Chart.yaml index 7f8bd6c8..02b50fff 100644 --- a/mika/postgres-agent/Chart.yaml +++ b/mika/postgres-agent/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: postgres-agent -description: Easily deploy a database and create a user in a remote PostgreSQL instance or delete a database. +description: Easily deploy a database and create a user, or delete a database in a remote PostgreSQL instance. type: application version: 0.2.0 appVersion: "13.3" From 5a8fb01f8e62c2f761a212e01185f564bdf280a0 Mon Sep 17 00:00:00 2001 From: irfanhakim-as Date: Thu, 20 Jul 2023 17:00:20 +0800 Subject: [PATCH 117/117] Add chart directory --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 2ef6b799..a994a796 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,23 @@ Applications, developed or curated by [mika](https://github.com/irfanhakim-as), - Kubernetes 1.19+ - Helm 3.2.0+ +## Chart Directory + +| Chart Name | Description | Support | Access | +| ---------- | ----------- | ------- | ------ | +| [clog](https://github.com/irfanhakim-as/charts/tree/master/mika/clog) | Creative blog, Career blog, Coin blog, you name it. | ✅ | 🔒 | +| [cloudflared](https://github.com/irfanhakim-as/charts/tree/master/mika/cloudflared) | Cloudflare Tunnel is a tunneling software that lets you quickly secure and encrypt application traffic to any type of infrastructure. | ✅ | ✅ | +| [grocy](https://github.com/irfanhakim-as/charts/tree/master/mika/grocy) | Grocy is a web-based self-hosted groceries & household management solution for your home. | ✅ | ✅ | +| [mango](https://github.com/irfanhakim-as/charts/tree/master/mika/mango) | Mango is an easy to use Mastodon bot framework built on top of Django. | ✅ | 🔒 | +| [postgres](https://github.com/irfanhakim-as/charts/tree/master/mika/postgres) | Easy tool to deploy a PostgreSQL instance on Kubernetes. | ✅ | ✅ | +| [postgres-agent](https://github.com/irfanhakim-as/charts/tree/master/mika/postgres-agent) | Easily deploy a database and create a user, or delete a database in a remote PostgreSQL instance. | ✅ | ✅ | +| [postgres-createdb](https://github.com/irfanhakim-as/charts/tree/master/mika/postgres-createdb) | Easily deploy a database and create a user in a remote PostgreSQL instance. | ❌ | ✅ | +| [postgres-dropdb](https://github.com/irfanhakim-as/charts/tree/master/mika/postgres-dropdb) | Delete a database easily in a remote PostgreSQL instance. | ❌ | ✅ | +| [rizz](https://github.com/irfanhakim-as/charts/tree/master/mika/rizz) | Rizz is a simple web application that tracks and posts content from RSS Feeds to Mastodon. | ✅ | 🔒 | +| [telego](https://github.com/irfanhakim-as/charts/tree/master/mika/telego) | Telego is an easy to use Telegram bot framework built on top of Django. | ✅ | 🔒 | +| [vpbot](https://github.com/irfanhakim-as/charts/tree/master/mika/vpbot) | Vpbot is a Telegram bot with support for a number of useful features such as prayer time notifications, COVID-19 statistics, and more. | ✅ | 🔒 | +| [waktusolat](https://github.com/irfanhakim-as/charts/tree/master/mika/waktusolat) | Waktu Solat is a simple web application that posts local prayer times on Mastodon. | ✅ | 🔒 | + ## How to add repo Add the repo to your local helm client.