From 574ea7c9ac10f791ebbc1c37481588a3801b0307 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Wed, 27 Aug 2025 00:19:04 +0400 Subject: [PATCH 01/22] feat: add chart --- .../kubernetes/sms-gateway-server/.helmignore | 23 +++ .../kubernetes/sms-gateway-server/Chart.yaml | 9 ++ .../sms-gateway-server/examples/values.yaml | 25 ++++ .../sms-gateway-server/templates/NOTES.txt | 22 +++ .../sms-gateway-server/templates/_helpers.tpl | 62 ++++++++ .../sms-gateway-server/templates/config.yaml | 9 ++ .../templates/deployment.yaml | 96 +++++++++++++ .../sms-gateway-server/templates/ingress.yaml | 43 ++++++ .../sms-gateway-server/templates/service.yaml | 15 ++ .../kubernetes/sms-gateway-server/values.yaml | 133 ++++++++++++++++++ 10 files changed, 437 insertions(+) create mode 100644 deployments/kubernetes/sms-gateway-server/.helmignore create mode 100644 deployments/kubernetes/sms-gateway-server/Chart.yaml create mode 100644 deployments/kubernetes/sms-gateway-server/examples/values.yaml create mode 100644 deployments/kubernetes/sms-gateway-server/templates/NOTES.txt create mode 100644 deployments/kubernetes/sms-gateway-server/templates/_helpers.tpl create mode 100644 deployments/kubernetes/sms-gateway-server/templates/config.yaml create mode 100644 deployments/kubernetes/sms-gateway-server/templates/deployment.yaml create mode 100644 deployments/kubernetes/sms-gateway-server/templates/ingress.yaml create mode 100644 deployments/kubernetes/sms-gateway-server/templates/service.yaml create mode 100644 deployments/kubernetes/sms-gateway-server/values.yaml diff --git a/deployments/kubernetes/sms-gateway-server/.helmignore b/deployments/kubernetes/sms-gateway-server/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/deployments/kubernetes/sms-gateway-server/.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/deployments/kubernetes/sms-gateway-server/Chart.yaml b/deployments/kubernetes/sms-gateway-server/Chart.yaml new file mode 100644 index 00000000..f6485819 --- /dev/null +++ b/deployments/kubernetes/sms-gateway-server/Chart.yaml @@ -0,0 +1,9 @@ +apiVersion: v2 +name: sms-gateway-server +description: A Helm chart for Kubernetes to deploy sms-gateway-server. + +type: application + +version: 0.1.0 + +appVersion: "1.28.1" diff --git a/deployments/kubernetes/sms-gateway-server/examples/values.yaml b/deployments/kubernetes/sms-gateway-server/examples/values.yaml new file mode 100644 index 00000000..3e22a9d5 --- /dev/null +++ b/deployments/kubernetes/sms-gateway-server/examples/values.yaml @@ -0,0 +1,25 @@ +replicaCount: 2 + +image: + repository: capcom6/sms-gateway + pullPolicy: Always + +resources: + limits: + cpu: 500m + memory: 256Mi + requests: + cpu: 250m + memory: 128Mi + +service: + type: ClusterIP + port: 8080 + +config: + debug: false + secret: + enabled: true + secretName: "sms-gateway-config" + unsecure: + enabled: false diff --git a/deployments/kubernetes/sms-gateway-server/templates/NOTES.txt b/deployments/kubernetes/sms-gateway-server/templates/NOTES.txt new file mode 100644 index 00000000..d1818693 --- /dev/null +++ b/deployments/kubernetes/sms-gateway-server/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "sms-gateway-server.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "sms-gateway-server.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "sms-gateway-server.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "sms-gateway-server.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/deployments/kubernetes/sms-gateway-server/templates/_helpers.tpl b/deployments/kubernetes/sms-gateway-server/templates/_helpers.tpl new file mode 100644 index 00000000..a74d061b --- /dev/null +++ b/deployments/kubernetes/sms-gateway-server/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "sms-gateway-server.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 "sms-gateway-server.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 "sms-gateway-server.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "sms-gateway-server.labels" -}} +helm.sh/chart: {{ include "sms-gateway-server.chart" . }} +{{ include "sms-gateway-server.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "sms-gateway-server.selectorLabels" -}} +app.kubernetes.io/name: {{ include "sms-gateway-server.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "sms-gateway-server.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "sms-gateway-server.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deployments/kubernetes/sms-gateway-server/templates/config.yaml b/deployments/kubernetes/sms-gateway-server/templates/config.yaml new file mode 100644 index 00000000..ebda085d --- /dev/null +++ b/deployments/kubernetes/sms-gateway-server/templates/config.yaml @@ -0,0 +1,9 @@ +{{- if .Values.config.unsecure.enabled}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "sms-gateway-server.fullname" . }}-config +data: + config.yml: | + {{ .Values.config.unsecure.configYml | nindent 4 }} +{{- end }} \ No newline at end of file diff --git a/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml b/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml new file mode 100644 index 00000000..fa689961 --- /dev/null +++ b/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml @@ -0,0 +1,96 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "sms-gateway-server.fullname" . }} + labels: + {{- include "sms-gateway-server.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "sms-gateway-server.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "sms-gateway-server.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + {{- with .Values.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + environment: + - name: CONFIG_PATH + value: /app/config.yml + {{- if .Values.config.debug }} + - name: DEBUG + value: "1" + {{- end }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + {{- with .Values.livenessProbe }} + livenessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.readinessProbe }} + readinessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + + volumeMounts: + - name: config-volume + mountPath: /app/config.yml + subPath: config.yml + {{- with .Values.volumeMounts }} + {{- toYaml . | nindent 12 }} + {{- end }} + volumes: + {{- if .Values.config.secret.enabled }} + - name: config-volume + secret: + secretName: {{ .Values.config.secret.secretName }} + {{- end }} + {{- if .Values.config.unsecure.enabled }} + - name: config-volume + configMap: + name: {{ include "sms-gateway-server.fullname" $ }}-config + {{- end }} + {{- with .Values.volumes }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/deployments/kubernetes/sms-gateway-server/templates/ingress.yaml b/deployments/kubernetes/sms-gateway-server/templates/ingress.yaml new file mode 100644 index 00000000..2c504884 --- /dev/null +++ b/deployments/kubernetes/sms-gateway-server/templates/ingress.yaml @@ -0,0 +1,43 @@ +{{- if .Values.ingress.enabled -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "sms-gateway-server.fullname" . }} + labels: + {{- include "sms-gateway-server.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- with .Values.ingress.className }} + ingressClassName: {{ . }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- with .pathType }} + pathType: {{ . }} + {{- end }} + backend: + service: + name: {{ include "sms-gateway-server.fullname" $ }} + port: + number: {{ $.Values.service.port }} + {{- end }} + {{- end }} +{{- end }} diff --git a/deployments/kubernetes/sms-gateway-server/templates/service.yaml b/deployments/kubernetes/sms-gateway-server/templates/service.yaml new file mode 100644 index 00000000..bd4d894f --- /dev/null +++ b/deployments/kubernetes/sms-gateway-server/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "sms-gateway-server.fullname" . }} + labels: + {{- include "sms-gateway-server.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "sms-gateway-server.selectorLabels" . | nindent 4 }} diff --git a/deployments/kubernetes/sms-gateway-server/values.yaml b/deployments/kubernetes/sms-gateway-server/values.yaml new file mode 100644 index 00000000..e74addc7 --- /dev/null +++ b/deployments/kubernetes/sms-gateway-server/values.yaml @@ -0,0 +1,133 @@ + +replicaCount: 1 + +# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ +image: + repository: capcom6/sms-gateway + # This sets the pull policy for images. + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +# This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ +imagePullSecrets: [] +# This is to override the chart name. +nameOverride: "" +fullnameOverride: "" + +# This is for setting Kubernetes Annotations to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +podAnnotations: {} +# This is for setting Kubernetes Labels to a Pod. +# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +# This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ +service: + # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types + type: ClusterIP + # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports + port: 80 + +# This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/ +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +# This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ +livenessProbe: + httpGet: + path: / + port: http +readinessProbe: + httpGet: + path: / + port: http + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +config: + debug: false + secret: + enabled: false + secretName: "sms-gateway-server-config" + unsecure: + enabled: false + configYml: >- + gateway: # gateway config + mode: private # gateway mode (public - allow anonymous device registration, private - protected registration) [GATEWAY__MODE] + private_token: 123456789 # access token for device registration in private mode [GATEWAY__PRIVATE_TOKEN] + http: # http server config + listen: 127.0.0.1:3000 # listen address [HTTP__LISTEN] + proxies: + - "127.0.0.1" # proxy address [HTTP__PROXIES] + database: # database + dialect: mysql # database dialect (only mysql supported at the moment) [DATABASE__DIALECT] + host: localhost # database host [DATABASE__HOST] + port: 3306 # database port [DATABASE__PORT] + user: root # database user [DATABASE__USER] + password: root # database password [DATABASE__PASSWORD] + database: sms # database name [DATABASE__DATABASE] + timezone: UTC # database timezone (important for message TTL calculation) [DATABASE__TIMEZONE] + max_open_conns: 4 # database max open connections (default: 4 * CPU) [DATABASE__MAX_OPEN_CONNS] + max_idle_conns: 2 # database max idle connections (default: 2 * CPU) [DATABASE__MAX_IDLE_CONNS] + fcm: # firebase cloud messaging config + credentials_json: "{}" # firebase credentials json (for public mode only) [FCM__CREDENTIALS_JSON] + timeout_seconds: 1 # push notification send timeout [FCM__DEBOUNCE_SECONDS] + debounce_seconds: 5 # push notification debounce (>= 5s) [FCM__TIMEOUT_SECONDS] + tasks: # tasks config + hashing: # hashing task (hashes processed messages for privacy purposes) + interval_seconds: 15 # hashing interval in seconds [TASKS__HASHING__INTERVAL_SECONDS] + From 419bd6485eb8760e96c3893cee52e5613c07077d Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Wed, 27 Aug 2025 00:25:17 +0400 Subject: [PATCH 02/22] ci: add chart releaser --- .github/workflows/build-chart.yaml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/build-chart.yaml diff --git a/.github/workflows/build-chart.yaml b/.github/workflows/build-chart.yaml new file mode 100644 index 00000000..6832e91d --- /dev/null +++ b/.github/workflows/build-chart.yaml @@ -0,0 +1,28 @@ +name: Release Charts + +on: + push: + +permissions: write-all + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Run chart-releaser + id: cr + uses: helm/chart-releaser-action@v1.5.0 + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + with: + charts_dir: ./deployments/kubernetes \ No newline at end of file From ae7356f23f3a73a14df71b2760aa416588ac03c3 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Wed, 27 Aug 2025 10:49:11 +0400 Subject: [PATCH 03/22] feat: update chart --- .../kubernetes/sms-gateway-server/Chart.yaml | 2 +- .../sms-gateway-server/examples/values.yaml | 6 ++++ .../templates/deployment.yaml | 4 ++- .../sms-gateway-server/templates/hpa.yaml | 32 +++++++++++++++++++ .../kubernetes/sms-gateway-server/values.yaml | 13 ++++++-- 5 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 deployments/kubernetes/sms-gateway-server/templates/hpa.yaml diff --git a/deployments/kubernetes/sms-gateway-server/Chart.yaml b/deployments/kubernetes/sms-gateway-server/Chart.yaml index f6485819..e4ec19ba 100644 --- a/deployments/kubernetes/sms-gateway-server/Chart.yaml +++ b/deployments/kubernetes/sms-gateway-server/Chart.yaml @@ -4,6 +4,6 @@ description: A Helm chart for Kubernetes to deploy sms-gateway-server. type: application -version: 0.1.0 +version: 0.2.0 appVersion: "1.28.1" diff --git a/deployments/kubernetes/sms-gateway-server/examples/values.yaml b/deployments/kubernetes/sms-gateway-server/examples/values.yaml index 3e22a9d5..d903b8c9 100644 --- a/deployments/kubernetes/sms-gateway-server/examples/values.yaml +++ b/deployments/kubernetes/sms-gateway-server/examples/values.yaml @@ -23,3 +23,9 @@ config: secretName: "sms-gateway-config" unsecure: enabled: false + +autoscaling: + enabled: true + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 \ No newline at end of file diff --git a/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml b/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml index fa689961..36ebc865 100644 --- a/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml +++ b/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml @@ -5,7 +5,9 @@ metadata: labels: {{- include "sms-gateway-server.labels" . | nindent 4 }} spec: + {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount }} + {{- end}} selector: matchLabels: {{- include "sms-gateway-server.selectorLabels" . | nindent 6 }} @@ -37,7 +39,7 @@ spec: {{- end }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} - environment: + env: - name: CONFIG_PATH value: /app/config.yml {{- if .Values.config.debug }} diff --git a/deployments/kubernetes/sms-gateway-server/templates/hpa.yaml b/deployments/kubernetes/sms-gateway-server/templates/hpa.yaml new file mode 100644 index 00000000..1c031280 --- /dev/null +++ b/deployments/kubernetes/sms-gateway-server/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "sms-gateway-server.fullname" . }} + labels: + {{- include "sms-gateway-server.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "sms-gateway-server.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/deployments/kubernetes/sms-gateway-server/values.yaml b/deployments/kubernetes/sms-gateway-server/values.yaml index e74addc7..815c856e 100644 --- a/deployments/kubernetes/sms-gateway-server/values.yaml +++ b/deployments/kubernetes/sms-gateway-server/values.yaml @@ -72,13 +72,22 @@ resources: {} # This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ livenessProbe: httpGet: - path: / + path: /health port: http readinessProbe: httpGet: - path: / + path: /health port: http +# This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/ +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + + # Additional volumes on the output Deployment definition. volumes: [] # - name: foo From 43881e8e5e0231bf100e21f283ad40a69d1f4841 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Wed, 27 Aug 2025 11:22:22 +0400 Subject: [PATCH 04/22] fix: update config ports Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- deployments/kubernetes/sms-gateway-server/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/kubernetes/sms-gateway-server/values.yaml b/deployments/kubernetes/sms-gateway-server/values.yaml index 815c856e..d39f7572 100644 --- a/deployments/kubernetes/sms-gateway-server/values.yaml +++ b/deployments/kubernetes/sms-gateway-server/values.yaml @@ -119,7 +119,7 @@ config: mode: private # gateway mode (public - allow anonymous device registration, private - protected registration) [GATEWAY__MODE] private_token: 123456789 # access token for device registration in private mode [GATEWAY__PRIVATE_TOKEN] http: # http server config - listen: 127.0.0.1:3000 # listen address [HTTP__LISTEN] + listen: 0.0.0.0:8080 # listen address [HTTP__LISTEN] proxies: - "127.0.0.1" # proxy address [HTTP__PROXIES] database: # database From 542423ac105aeb8dac024d3eb3f775a06796eaec Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Wed, 27 Aug 2025 11:23:07 +0400 Subject: [PATCH 05/22] Update deployments/kubernetes/sms-gateway-server/values.yaml Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- deployments/kubernetes/sms-gateway-server/values.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/deployments/kubernetes/sms-gateway-server/values.yaml b/deployments/kubernetes/sms-gateway-server/values.yaml index d39f7572..a0b57e88 100644 --- a/deployments/kubernetes/sms-gateway-server/values.yaml +++ b/deployments/kubernetes/sms-gateway-server/values.yaml @@ -38,8 +38,7 @@ service: # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types type: ClusterIP # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports - port: 80 - + port: 8080 # This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/ ingress: enabled: false From 7b0707b958f276bff95ebd98a2346c7ad007aae3 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Wed, 27 Aug 2025 11:24:02 +0400 Subject: [PATCH 06/22] fix: update autoscaling values Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../kubernetes/sms-gateway-server/templates/hpa.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/deployments/kubernetes/sms-gateway-server/templates/hpa.yaml b/deployments/kubernetes/sms-gateway-server/templates/hpa.yaml index 1c031280..7ed1856c 100644 --- a/deployments/kubernetes/sms-gateway-server/templates/hpa.yaml +++ b/deployments/kubernetes/sms-gateway-server/templates/hpa.yaml @@ -12,6 +12,7 @@ spec: name: {{ include "sms-gateway-server.fullname" . }} minReplicas: {{ .Values.autoscaling.minReplicas }} maxReplicas: {{ .Values.autoscaling.maxReplicas }} + {{- if or .Values.autoscaling.targetCPUUtilizationPercentage .Values.autoscaling.targetMemoryUtilizationPercentage }} metrics: {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} - type: Resource @@ -29,4 +30,13 @@ spec: type: Utilization averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} {{- end }} + {{- else }} + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 80 + {{- end }} {{- end }} From 02ba8ad546c22a9ddf9e541de912c9453ecd00e6 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Wed, 27 Aug 2025 11:24:17 +0400 Subject: [PATCH 07/22] fix: upgrade ci Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .github/workflows/build-chart.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-chart.yaml b/.github/workflows/build-chart.yaml index 6832e91d..0ec0d1a1 100644 --- a/.github/workflows/build-chart.yaml +++ b/.github/workflows/build-chart.yaml @@ -10,7 +10,8 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v4 with: fetch-depth: 0 From 800c58d0ea5bb53651fde29aa625f1dde8a0dd16 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Wed, 27 Aug 2025 11:24:44 +0400 Subject: [PATCH 08/22] fix: fix config for deployment Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../sms-gateway-server/templates/deployment.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml b/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml index 36ebc865..5949fa32 100644 --- a/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml +++ b/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml @@ -71,12 +71,14 @@ spec: {{- toYaml . | nindent 12 }} {{- end }} volumes: + {{- if and .Values.config.secret.enabled .Values.config.unsecure.enabled }} + {{- fail "Only one of config.secret.enabled or config.unsecure.enabled may be true" }} + {{- end }} {{- if .Values.config.secret.enabled }} - name: config-volume secret: - secretName: {{ .Values.config.secret.secretName }} - {{- end }} - {{- if .Values.config.unsecure.enabled }} + secretName: {{ required "Values.config.secret.secretName is required when config.secret.enabled is true" .Values.config.secret.secretName }} + {{- else if .Values.config.unsecure.enabled }} - name: config-volume configMap: name: {{ include "sms-gateway-server.fullname" $ }}-config From 2593e33ddc23fc38427a38142ebda63e067a601f Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Wed, 27 Aug 2025 11:25:32 +0400 Subject: [PATCH 09/22] fix: update template Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- .../kubernetes/sms-gateway-server/templates/ingress.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/deployments/kubernetes/sms-gateway-server/templates/ingress.yaml b/deployments/kubernetes/sms-gateway-server/templates/ingress.yaml index 2c504884..bb8a5083 100644 --- a/deployments/kubernetes/sms-gateway-server/templates/ingress.yaml +++ b/deployments/kubernetes/sms-gateway-server/templates/ingress.yaml @@ -30,9 +30,7 @@ spec: paths: {{- range .paths }} - path: {{ .path }} - {{- with .pathType }} - pathType: {{ . }} - {{- end }} + pathType: {{ .pathType | default "ImplementationSpecific" }} backend: service: name: {{ include "sms-gateway-server.fullname" $ }} From a4114e62451220efd1fcac32eb11b74b45264fbe Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Wed, 27 Aug 2025 11:28:39 +0400 Subject: [PATCH 10/22] chore: bump version --- deployments/kubernetes/sms-gateway-server/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/kubernetes/sms-gateway-server/Chart.yaml b/deployments/kubernetes/sms-gateway-server/Chart.yaml index e4ec19ba..eebaf7b5 100644 --- a/deployments/kubernetes/sms-gateway-server/Chart.yaml +++ b/deployments/kubernetes/sms-gateway-server/Chart.yaml @@ -4,6 +4,6 @@ description: A Helm chart for Kubernetes to deploy sms-gateway-server. type: application -version: 0.2.0 +version: 0.2.6 appVersion: "1.28.1" From 2ef390f6cfcd61fdc079ccbef0f4a78a1c4da566 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Thu, 4 Sep 2025 20:04:31 +0400 Subject: [PATCH 11/22] feat: improve helm --- deployments/kubernetes/sms-gateway-server/Chart.yaml | 11 +++++++++-- .../sms-gateway-server/examples/values.yaml | 2 +- .../sms-gateway-server/templates/config.yaml | 2 ++ .../sms-gateway-server/templates/deployment.yaml | 5 +++++ deployments/kubernetes/sms-gateway-server/values.yaml | 6 ++++-- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/deployments/kubernetes/sms-gateway-server/Chart.yaml b/deployments/kubernetes/sms-gateway-server/Chart.yaml index eebaf7b5..646aed1a 100644 --- a/deployments/kubernetes/sms-gateway-server/Chart.yaml +++ b/deployments/kubernetes/sms-gateway-server/Chart.yaml @@ -4,6 +4,13 @@ description: A Helm chart for Kubernetes to deploy sms-gateway-server. type: application -version: 0.2.6 +version: 0.2.7 -appVersion: "1.28.1" +appVersion: "1.29.0" + +home: https://github.com/android-sms-gateway/server +sources: + - https://github.com/android-sms-gateway/server +maintainers: + - name: SMSGate Team + email: support@sms-gate.app \ No newline at end of file diff --git a/deployments/kubernetes/sms-gateway-server/examples/values.yaml b/deployments/kubernetes/sms-gateway-server/examples/values.yaml index d903b8c9..2b4322a0 100644 --- a/deployments/kubernetes/sms-gateway-server/examples/values.yaml +++ b/deployments/kubernetes/sms-gateway-server/examples/values.yaml @@ -1,4 +1,4 @@ -replicaCount: 2 +replicaCount: 1 image: repository: capcom6/sms-gateway diff --git a/deployments/kubernetes/sms-gateway-server/templates/config.yaml b/deployments/kubernetes/sms-gateway-server/templates/config.yaml index ebda085d..2da58cd4 100644 --- a/deployments/kubernetes/sms-gateway-server/templates/config.yaml +++ b/deployments/kubernetes/sms-gateway-server/templates/config.yaml @@ -3,6 +3,8 @@ apiVersion: v1 kind: ConfigMap metadata: name: {{ include "sms-gateway-server.fullname" . }}-config + labels: + # ... data: config.yml: | {{ .Values.config.unsecure.configYml | nindent 4 }} diff --git a/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml b/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml index 5949fa32..cf571162 100644 --- a/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml +++ b/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml @@ -46,6 +46,9 @@ spec: - name: DEBUG value: "1" {{- end }} + {{- with.Values.extraEnv }} + {{- toYaml . | nindent 12 }} + {{- end }} ports: - name: http containerPort: {{ .Values.service.port }} @@ -63,10 +66,12 @@ spec: {{- toYaml . | nindent 12 }} {{- end }} + {{- if or .Values.config.secret.enabled .Values.config.unsecure.enabled }} volumeMounts: - name: config-volume mountPath: /app/config.yml subPath: config.yml + {{- end }} {{- with .Values.volumeMounts }} {{- toYaml . | nindent 12 }} {{- end }} diff --git a/deployments/kubernetes/sms-gateway-server/values.yaml b/deployments/kubernetes/sms-gateway-server/values.yaml index a0b57e88..4779deda 100644 --- a/deployments/kubernetes/sms-gateway-server/values.yaml +++ b/deployments/kubernetes/sms-gateway-server/values.yaml @@ -106,6 +106,8 @@ tolerations: [] affinity: {} +extraEnv: {} + config: debug: false secret: @@ -133,8 +135,8 @@ config: max_idle_conns: 2 # database max idle connections (default: 2 * CPU) [DATABASE__MAX_IDLE_CONNS] fcm: # firebase cloud messaging config credentials_json: "{}" # firebase credentials json (for public mode only) [FCM__CREDENTIALS_JSON] - timeout_seconds: 1 # push notification send timeout [FCM__DEBOUNCE_SECONDS] - debounce_seconds: 5 # push notification debounce (>= 5s) [FCM__TIMEOUT_SECONDS] + timeout_seconds: 1 # push notification send timeout [FCM__TIMEOUT_SECONDS] + debounce_seconds: 5 # push notification debounce (>= 5s) [FCM__DEBOUNCE_SECONDS] tasks: # tasks config hashing: # hashing task (hashes processed messages for privacy purposes) interval_seconds: 15 # hashing interval in seconds [TASKS__HASHING__INTERVAL_SECONDS] From acc8f6d4208385b0f94ec067fb11423a01112597 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Thu, 4 Sep 2025 20:06:22 +0400 Subject: [PATCH 12/22] ci: upgrade ci --- .github/workflows/build-chart.yaml | 9 +++- .github/workflows/bump-chart-app-version.yaml | 45 +++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/bump-chart-app-version.yaml diff --git a/.github/workflows/build-chart.yaml b/.github/workflows/build-chart.yaml index 0ec0d1a1..294b2da0 100644 --- a/.github/workflows/build-chart.yaml +++ b/.github/workflows/build-chart.yaml @@ -2,14 +2,19 @@ name: Release Charts on: push: + branches: + - master + paths: + - 'deployments/kubernetes/**' -permissions: write-all + +permissions: + contents: write jobs: release: runs-on: ubuntu-latest steps: - - name: Checkout - name: Checkout uses: actions/checkout@v4 with: diff --git a/.github/workflows/bump-chart-app-version.yaml b/.github/workflows/bump-chart-app-version.yaml new file mode 100644 index 00000000..90d8d6ae --- /dev/null +++ b/.github/workflows/bump-chart-app-version.yaml @@ -0,0 +1,45 @@ +name: Release Charts + +on: + push: + tags: + - 'v*.*.*' + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Bump Chart.yaml + run: | + TAG_VERSION=${GITHUB_REF#refs/tags/} + CHART_FILE=deployments/kubernetes/Chart.yaml + + # Extract current version + CURRENT_VERSION=$(awk '/^version:/ {print $2}' $CHART_FILE) + IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION" + + # Increment patch + PATCH=$((PATCH + 1)) + NEW_VERSION="$MAJOR.$MINOR.$PATCH" + + # Update Chart.yaml + sed -i "s/^version:.*/version: $NEW_VERSION/" $CHART_FILE + sed -i "s/^appVersion:.*/appVersion: $TAG_VERSION/" $CHART_FILE + + # Commit and push changes + git add $CHART_FILE + git commit -m "[infra] bump Chart version to $NEW_VERSION and appVersion to $TAG_VERSION" + git push origin HEAD:master From 26bd4aea589b98b3a15af9ae934580673cd62749 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Thu, 4 Sep 2025 20:08:13 +0400 Subject: [PATCH 13/22] chore: bump version --- deployments/kubernetes/sms-gateway-server/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/kubernetes/sms-gateway-server/Chart.yaml b/deployments/kubernetes/sms-gateway-server/Chart.yaml index 646aed1a..b94a7bbb 100644 --- a/deployments/kubernetes/sms-gateway-server/Chart.yaml +++ b/deployments/kubernetes/sms-gateway-server/Chart.yaml @@ -4,7 +4,7 @@ description: A Helm chart for Kubernetes to deploy sms-gateway-server. type: application -version: 0.2.7 +version: 0.2.8 appVersion: "1.29.0" From 34ec506071df172e80017bb19fb96b37014c016a Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Thu, 4 Sep 2025 21:08:44 +0400 Subject: [PATCH 14/22] fix: fix yaml --- .github/workflows/bump-chart-app-version.yaml | 5 +++-- deployments/kubernetes/sms-gateway-server/Chart.yaml | 2 +- .../sms-gateway-server/templates/_validation.tpl | 3 +++ .../kubernetes/sms-gateway-server/templates/config.yaml | 2 +- .../sms-gateway-server/templates/deployment.yaml | 8 +++++--- 5 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 deployments/kubernetes/sms-gateway-server/templates/_validation.tpl diff --git a/.github/workflows/bump-chart-app-version.yaml b/.github/workflows/bump-chart-app-version.yaml index 90d8d6ae..12424cc7 100644 --- a/.github/workflows/bump-chart-app-version.yaml +++ b/.github/workflows/bump-chart-app-version.yaml @@ -25,7 +25,8 @@ jobs: - name: Bump Chart.yaml run: | TAG_VERSION=${GITHUB_REF#refs/tags/} - CHART_FILE=deployments/kubernetes/Chart.yaml + TAG_VERSION=${TAG_VERSION#v} + CHART_FILE=deployments/kubernetes/sms-gateway-server/Chart.yaml # Extract current version CURRENT_VERSION=$(awk '/^version:/ {print $2}' $CHART_FILE) @@ -37,7 +38,7 @@ jobs: # Update Chart.yaml sed -i "s/^version:.*/version: $NEW_VERSION/" $CHART_FILE - sed -i "s/^appVersion:.*/appVersion: $TAG_VERSION/" $CHART_FILE + sed -i "s/^appVersion:.*/appVersion: \"$TAG_VERSION\"/" $CHART_FILE # Commit and push changes git add $CHART_FILE diff --git a/deployments/kubernetes/sms-gateway-server/Chart.yaml b/deployments/kubernetes/sms-gateway-server/Chart.yaml index b94a7bbb..0243841b 100644 --- a/deployments/kubernetes/sms-gateway-server/Chart.yaml +++ b/deployments/kubernetes/sms-gateway-server/Chart.yaml @@ -4,7 +4,7 @@ description: A Helm chart for Kubernetes to deploy sms-gateway-server. type: application -version: 0.2.8 +version: 0.2.9 appVersion: "1.29.0" diff --git a/deployments/kubernetes/sms-gateway-server/templates/_validation.tpl b/deployments/kubernetes/sms-gateway-server/templates/_validation.tpl new file mode 100644 index 00000000..b2b2a467 --- /dev/null +++ b/deployments/kubernetes/sms-gateway-server/templates/_validation.tpl @@ -0,0 +1,3 @@ +{{- if and .Values.config.secret.enabled .Values.config.unsecure.enabled -}} +{{- fail "Only one of config.secret.enabled or config.unsecure.enabled may be true." -}} +{{- end -}} \ No newline at end of file diff --git a/deployments/kubernetes/sms-gateway-server/templates/config.yaml b/deployments/kubernetes/sms-gateway-server/templates/config.yaml index 2da58cd4..3f351a4a 100644 --- a/deployments/kubernetes/sms-gateway-server/templates/config.yaml +++ b/deployments/kubernetes/sms-gateway-server/templates/config.yaml @@ -4,7 +4,7 @@ kind: ConfigMap metadata: name: {{ include "sms-gateway-server.fullname" . }}-config labels: - # ... + {{- include "sms-gateway-server.labels" . | nindent 4 }} data: config.yml: | {{ .Values.config.unsecure.configYml | nindent 4 }} diff --git a/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml b/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml index cf571162..54ab78eb 100644 --- a/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml +++ b/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml @@ -46,7 +46,7 @@ spec: - name: DEBUG value: "1" {{- end }} - {{- with.Values.extraEnv }} + {{- with .Values.extraEnv }} {{- toYaml . | nindent 12 }} {{- end }} ports: @@ -65,16 +65,18 @@ spec: resources: {{- toYaml . | nindent 12 }} {{- end }} - - {{- if or .Values.config.secret.enabled .Values.config.unsecure.enabled }} + {{- if or (or .Values.config.secret.enabled .Values.config.unsecure.enabled) .Values.volumeMounts }} volumeMounts: + {{- if or .Values.config.secret.enabled .Values.config.unsecure.enabled }} - name: config-volume mountPath: /app/config.yml subPath: config.yml + readOnly: true {{- end }} {{- with .Values.volumeMounts }} {{- toYaml . | nindent 12 }} {{- end }} + {{- end }} volumes: {{- if and .Values.config.secret.enabled .Values.config.unsecure.enabled }} {{- fail "Only one of config.secret.enabled or config.unsecure.enabled may be true" }} From 4c66ebcb88de8cab0c1ef906525a967f85867630 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Thu, 4 Sep 2025 22:23:55 +0400 Subject: [PATCH 15/22] docs: add docs and components to yaml --- .../kubernetes/sms-gateway-server/Chart.yaml | 2 +- .../kubernetes/sms-gateway-server/README.md | 348 ++++++++++++++++++ .../sms-gateway-server/examples/values.yaml | 44 ++- .../sms-gateway-server/templates/config.yaml | 1 + .../templates/deployment.yaml | 1 + .../sms-gateway-server/templates/hpa.yaml | 1 + .../sms-gateway-server/templates/ingress.yaml | 1 + .../sms-gateway-server/templates/service.yaml | 1 + .../kubernetes/sms-gateway-server/values.yaml | 7 +- 9 files changed, 403 insertions(+), 3 deletions(-) create mode 100644 deployments/kubernetes/sms-gateway-server/README.md diff --git a/deployments/kubernetes/sms-gateway-server/Chart.yaml b/deployments/kubernetes/sms-gateway-server/Chart.yaml index 0243841b..8758695b 100644 --- a/deployments/kubernetes/sms-gateway-server/Chart.yaml +++ b/deployments/kubernetes/sms-gateway-server/Chart.yaml @@ -4,7 +4,7 @@ description: A Helm chart for Kubernetes to deploy sms-gateway-server. type: application -version: 0.2.9 +version: 0.2.10 appVersion: "1.29.0" diff --git a/deployments/kubernetes/sms-gateway-server/README.md b/deployments/kubernetes/sms-gateway-server/README.md new file mode 100644 index 00000000..13f265f7 --- /dev/null +++ b/deployments/kubernetes/sms-gateway-server/README.md @@ -0,0 +1,348 @@ +# SMS Gateway Server Helm Chart + +A Helm chart for deploying the SMS Gateway Server on Kubernetes. + +## Installation + +```bash +helm repo add sms-gateway-server https://android-sms-gateway.github.io/server + +helm upgrade --install sms-gateway-server \ + --namespace sms-gateway-system \ + --create-namespace \ + -f your-values.yaml \ + android-sms-gateway/sms-gateway-server +``` + +## Configuration + +This chart supports three configuration methods: + +1. **External Secret** (Recommended for production) +2. **Unsecure ConfigMap** (Development/testing) +3. **Environment Variables** (Override specific values) + +### Basic Configuration + +| Parameter | Description | Default | +|-----------|-------------|---------| +| `replicaCount` | Number of replicas | `1` | +| `image.repository` | Container image repository | `capcom6/sms-gateway` | +| `image.tag` | Container image tag | `""` (uses Chart.AppVersion) | +| `image.pullPolicy` | Image pull policy | `IfNotPresent` | +| `service.type` | Kubernetes service type | `ClusterIP` | +| `service.port` | Service port | `8080` | + +### Security Configuration + +| Parameter | Description | Default | +|-----------|-------------|---------| +| `podSecurityContext` | Pod security context | `{}` | +| `securityContext` | Container security context | `{}` | +| `imagePullSecrets` | Image pull secrets | `[]` | + +### Autoscaling Configuration + +| Parameter | Description | Default | +|-----------|-------------|---------| +| `autoscaling.enabled` | Enable horizontal pod autoscaler | `false` | +| `autoscaling.minReplicas` | Minimum number of replicas | `1` | +| `autoscaling.maxReplicas` | Maximum number of replicas | `100` | +| `autoscaling.targetCPUUtilizationPercentage` | Target CPU utilization | `80` | +| `autoscaling.targetMemoryUtilizationPercentage` | Target memory utilization | `null` | + +### Ingress Configuration + +| Parameter | Description | Default | +|-----------|-------------|---------| +| `ingress.enabled` | Enable ingress | `false` | +| `ingress.className` | Ingress class name | `""` | +| `ingress.annotations` | Ingress annotations | `{}` | +| `ingress.hosts[0].host` | Hostname | `chart-example.local` | +| `ingress.hosts[0].paths[0].path` | Path | `/` | +| `ingress.hosts[0].paths[0].pathType` | Path type | `ImplementationSpecific` | +| `ingress.tls` | TLS configuration | `[]` | + +### Resource Configuration + +| Parameter | Description | Default | +|-----------|-------------|---------| +| `resources.limits.cpu` | CPU limit | `null` | +| `resources.limits.memory` | Memory limit | `null` | +| `resources.requests.cpu` | CPU request | `null` | +| `resources.requests.memory` | Memory request | `null` | + +### Node Selection + +| Parameter | Description | Default | +|-----------|-------------|---------| +| `nodeSelector` | Node selector | `{}` | +| `tolerations` | Tolerations | `[]` | +| `affinity` | Affinity rules | `{}` | + +## Application Configuration + +The SMS Gateway Server can be configured using three methods: + +### Method 1: External Secret (Recommended) + +Create an external secret containing your configuration: + +```yaml +config: + secret: + enabled: true + secretName: "my-sms-gateway-config" +``` + +Your secret should contain a `config.yml` key with the full configuration. + +### Method 2: Unsecure ConfigMap + +For development or non-sensitive environments: + +```yaml +config: + unsecure: + enabled: true + configYml: | + gateway: + mode: private + private_token: "your-secret-token" + http: + listen: 0.0.0.0:8080 + proxies: + - "127.0.0.1" + database: + dialect: mysql + host: mysql-service + port: 3306 + user: sms_user + password: sms_password + database: sms + timezone: UTC + max_open_conns: 4 + max_idle_conns: 2 + fcm: + credentials_json: "{}" + timeout_seconds: 1 + debounce_seconds: 5 + tasks: + hashing: + interval_seconds: 15 +``` + +### Method 3: Environment Variables + +Override specific configuration values using environment variables: + +```yaml +extraEnv: + - name: GATEWAY__MODE + value: "public" + - name: DATABASE__HOST + value: "mysql.example.com" + - name: DATABASE__PASSWORD + valueFrom: + secretKeyRef: + name: mysql-secret + key: password +``` + +## Configuration Reference + +Based on the example configuration file, here are all available configuration options: + +### Gateway Configuration + +| Parameter | Environment Variable | Description | Default | +|-----------|---------------------|-------------|---------| +| `config.unsecure.configYml` (gateway.mode) | `GATEWAY__MODE` | Gateway mode: `public` (anonymous registration) or `private` (protected) | `private` | +| `config.unsecure.configYml` (gateway.private_token) | `GATEWAY__PRIVATE_TOKEN` | Access token for device registration in private mode | `123456789` | + +### HTTP Server Configuration + +| Parameter | Environment Variable | Description | Default | +|-----------|---------------------|-------------|---------| +| `config.unsecure.configYml` (http.listen) | `HTTP__LISTEN` | HTTP server listen address | `0.0.0.0:8080` | +| `config.unsecure.configYml` (http.proxies) | `HTTP__PROXIES` | Trusted proxy addresses | `["127.0.0.1"]` | + +### Database Configuration + +| Parameter | Environment Variable | Description | Default | +|-----------|---------------------|-------------|---------| +| `config.unsecure.configYml` (database.dialect) | `DATABASE__DIALECT` | Database dialect (only mysql supported) | `mysql` | +| `config.unsecure.configYml` (database.host) | `DATABASE__HOST` | Database host | `localhost` | +| `config.unsecure.configYml` (database.port) | `DATABASE__PORT` | Database port | `3306` | +| `config.unsecure.configYml` (database.user) | `DATABASE__USER` | Database user | `root` | +| `config.unsecure.configYml` (database.password) | `DATABASE__PASSWORD` | Database password | `root` | +| `config.unsecure.configYml` (database.database) | `DATABASE__DATABASE` | Database name | `sms` | +| `config.unsecure.configYml` (database.timezone) | `DATABASE__TIMEZONE` | Database timezone (important for message TTL) | `UTC` | +| `config.unsecure.configYml` (database.max_open_conns) | `DATABASE__MAX_OPEN_CONNS` | Maximum open database connections | `4` | +| `config.unsecure.configYml` (database.max_idle_conns) | `DATABASE__MAX_IDLE_CONNS` | Maximum idle database connections | `2` | + +### Firebase Cloud Messaging (FCM) Configuration + +| Parameter | Environment Variable | Description | Default | +|-----------|---------------------|-------------|---------| +| `config.unsecure.configYml` (fcm.credentials_json) | `FCM__CREDENTIALS_JSON` | Firebase credentials JSON (for public mode only) | `"{}"` | +| `config.unsecure.configYml` (fcm.timeout_seconds) | `FCM__TIMEOUT_SECONDS` | Push notification send timeout | `1` | +| `config.unsecure.configYml` (fcm.debounce_seconds) | `FCM__DEBOUNCE_SECONDS` | Push notification debounce (>= 5s) | `5` | + +### Tasks Configuration + +| Parameter | Environment Variable | Description | Default | +|-----------|---------------------|-------------|---------| +| `config.unsecure.configYml` (tasks.hashing.interval_seconds) | `TASKS__HASHING__INTERVAL_SECONDS` | Hashing interval for privacy purposes | `15` | + +### HTTP API Configuration + +| Parameter | Environment Variable | Description | Default | +|-----------|---------------------|-------------|---------| +| N/A | `HTTP__API__HOST` | External API host URL for the gateway | N/A | +| N/A | `HTTP__OPENAPI__ENABLED` | Enable OpenAPI documentation endpoint | `false` | +| N/A | `HTTP__API__PATH` | API base path prefix | `/` | + +### Additional Configuration + +| Parameter | Description | Default | +|-----------|-------------|---------| +| `config.debug` | Enable debug mode | `false` | +| `extraEnv` | Additional environment variables | `{}` | + +## Health Checks + +The chart includes health checks that can be customized: + +```yaml +livenessProbe: + httpGet: + path: /health + port: http + initialDelaySeconds: 30 + periodSeconds: 10 + +readinessProbe: + httpGet: + path: /health + port: http + initialDelaySeconds: 5 + periodSeconds: 5 +``` + +## Volume Configuration + +Add additional volumes and volume mounts: + +```yaml +volumes: + - name: custom-volume + configMap: + name: my-configmap + +volumeMounts: + - name: custom-volume + mountPath: /custom/path + readOnly: true +``` + +## Examples + +### Basic Deployment with External Database + +```yaml +# values.yaml +config: + unsecure: + enabled: true + configYml: | + gateway: + mode: private + private_token: "my-secure-token" + database: + host: mysql.default.svc.cluster.local + user: sms_user + password: sms_password + database: sms_gateway +``` + +### Production Deployment with External Secret + +```yaml +# values.yaml +config: + secret: + enabled: true + secretName: "sms-gateway-config" + +resources: + limits: + cpu: 500m + memory: 512Mi + requests: + cpu: 250m + memory: 256Mi + +autoscaling: + enabled: true + minReplicas: 2 + maxReplicas: 10 + targetCPUUtilizationPercentage: 70 +``` + +### Environment Variable Override + +```yaml +# values.yaml +config: + unsecure: + enabled: true + configYml: | + # Basic config here + +# Override specific values with env vars +extraEnv: + - name: DATABASE__HOST + value: "production-mysql.example.com" + - name: DATABASE__PASSWORD + valueFrom: + secretKeyRef: + name: mysql-credentials + key: password + - name: FCM__CREDENTIALS_JSON + valueFrom: + secretKeyRef: + name: fcm-credentials + key: credentials.json +``` + +## Security Considerations + +**Always use external secrets in production** for sensitive configuration values + +## Troubleshooting + +### Common Issues + +1. **Pod fails to start**: Check configuration format and required fields +2. **Database connection errors**: Verify database connectivity and credentials +3. **Health check failures**: Ensure the `/health` endpoint is accessible on port 8080 + +### Debug Mode + +Enable debug logging: + +```yaml +config: + debug: true +``` + +## Additional Resources + +### Example Configuration Files + +For complete examples, see: + +- **[examples/values.yaml](examples/values.yaml)** - Example Helm values configuration with external secret setup + +- **[configs/config.example.yml](../../configs/config.example.yml)** - Complete application configuration reference diff --git a/deployments/kubernetes/sms-gateway-server/examples/values.yaml b/deployments/kubernetes/sms-gateway-server/examples/values.yaml index 2b4322a0..1ba316c7 100644 --- a/deployments/kubernetes/sms-gateway-server/examples/values.yaml +++ b/deployments/kubernetes/sms-gateway-server/examples/values.yaml @@ -1,7 +1,11 @@ +##################### +# Example values.yaml +##################### + replicaCount: 1 image: - repository: capcom6/sms-gateway + repository: ghcr.io/android-sms-gateway/server pullPolicy: Always resources: @@ -20,9 +24,47 @@ config: debug: false secret: enabled: true + # Define your secret and deploy it with any name below but it should be in the same namespace or use "sms-gateway-server-config" + # see configs/config.example.yml secretName: "sms-gateway-config" + # If you do not care, just enable unsecure, it will create + # a config for you and it will apply what you configured. + # configs/config.example.yml, DO NOT USE the default config below unsecure: enabled: false + # configYml: >- + # gateway: # gateway config + # mode: private # gateway mode (public - allow anonymous device registration, private - protected registration) [GATEWAY__MODE] + # private_token: 123456789 # access token for device registration in private mode [GATEWAY__PRIVATE_TOKEN] + # http: # http server config + # listen: 0.0.0.0:8080 # listen address [HTTP__LISTEN] + # proxies: + # - "127.0.0.1" # proxy address [HTTP__PROXIES] + # database: # database + # dialect: mysql # database dialect (only mysql supported at the moment) [DATABASE__DIALECT] + # host: localhost # database host [DATABASE__HOST] + # port: 3306 # database port [DATABASE__PORT] + # user: root # database user [DATABASE__USER] + # password: root # database password [DATABASE__PASSWORD] + # database: sms # database name [DATABASE__DATABASE] + # timezone: UTC # database timezone (important for message TTL calculation) [DATABASE__TIMEZONE] + # max_open_conns: 4 # database max open connections (default: 4 * CPU) [DATABASE__MAX_OPEN_CONNS] + # max_idle_conns: 2 # database max idle connections (default: 2 * CPU) [DATABASE__MAX_IDLE_CONNS] + # fcm: # firebase cloud messaging config + # credentials_json: "{}" # firebase credentials json (for public mode only) [FCM__CREDENTIALS_JSON] + # timeout_seconds: 1 # push notification send timeout [FCM__TIMEOUT_SECONDS] + # debounce_seconds: 5 # push notification debounce (>= 5s) [FCM__DEBOUNCE_SECONDS] + # tasks: # tasks config + # hashing: # hashing task (hashes processed messages for privacy purposes) + # interval_seconds: 15 # hashing interval in seconds [TASKS__HASHING__INTERVAL_SECONDS] + +extraEnv: + - name: HTTP__API__HOST + value: https://sms-gateway.parksmart.mu + - name: HTTP__OPENAPI__ENABLED + value: "true" + - name: HTTP__API__PATH + value: /api autoscaling: enabled: true diff --git a/deployments/kubernetes/sms-gateway-server/templates/config.yaml b/deployments/kubernetes/sms-gateway-server/templates/config.yaml index 3f351a4a..20a2e22b 100644 --- a/deployments/kubernetes/sms-gateway-server/templates/config.yaml +++ b/deployments/kubernetes/sms-gateway-server/templates/config.yaml @@ -5,6 +5,7 @@ metadata: name: {{ include "sms-gateway-server.fullname" . }}-config labels: {{- include "sms-gateway-server.labels" . | nindent 4 }} + app.kubernetes.io/component: configmap data: config.yml: | {{ .Values.config.unsecure.configYml | nindent 4 }} diff --git a/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml b/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml index 54ab78eb..2abec0bc 100644 --- a/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml +++ b/deployments/kubernetes/sms-gateway-server/templates/deployment.yaml @@ -4,6 +4,7 @@ metadata: name: {{ include "sms-gateway-server.fullname" . }} labels: {{- include "sms-gateway-server.labels" . | nindent 4 }} + app.kubernetes.io/component: server spec: {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount }} diff --git a/deployments/kubernetes/sms-gateway-server/templates/hpa.yaml b/deployments/kubernetes/sms-gateway-server/templates/hpa.yaml index 7ed1856c..c3fc36a4 100644 --- a/deployments/kubernetes/sms-gateway-server/templates/hpa.yaml +++ b/deployments/kubernetes/sms-gateway-server/templates/hpa.yaml @@ -5,6 +5,7 @@ metadata: name: {{ include "sms-gateway-server.fullname" . }} labels: {{- include "sms-gateway-server.labels" . | nindent 4 }} + app.kubernetes.io/component: autoscaler spec: scaleTargetRef: apiVersion: apps/v1 diff --git a/deployments/kubernetes/sms-gateway-server/templates/ingress.yaml b/deployments/kubernetes/sms-gateway-server/templates/ingress.yaml index bb8a5083..3a310466 100644 --- a/deployments/kubernetes/sms-gateway-server/templates/ingress.yaml +++ b/deployments/kubernetes/sms-gateway-server/templates/ingress.yaml @@ -5,6 +5,7 @@ metadata: name: {{ include "sms-gateway-server.fullname" . }} labels: {{- include "sms-gateway-server.labels" . | nindent 4 }} + app.kubernetes.io/component: ingress {{- with .Values.ingress.annotations }} annotations: {{- toYaml . | nindent 4 }} diff --git a/deployments/kubernetes/sms-gateway-server/templates/service.yaml b/deployments/kubernetes/sms-gateway-server/templates/service.yaml index bd4d894f..f7f59e07 100644 --- a/deployments/kubernetes/sms-gateway-server/templates/service.yaml +++ b/deployments/kubernetes/sms-gateway-server/templates/service.yaml @@ -4,6 +4,7 @@ metadata: name: {{ include "sms-gateway-server.fullname" . }} labels: {{- include "sms-gateway-server.labels" . | nindent 4 }} + app.kubernetes.io/component: service spec: type: {{ .Values.service.type }} ports: diff --git a/deployments/kubernetes/sms-gateway-server/values.yaml b/deployments/kubernetes/sms-gateway-server/values.yaml index 4779deda..3cf64688 100644 --- a/deployments/kubernetes/sms-gateway-server/values.yaml +++ b/deployments/kubernetes/sms-gateway-server/values.yaml @@ -3,7 +3,7 @@ replicaCount: 1 # This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ image: - repository: capcom6/sms-gateway + repository: ghcr.io/android-sms-gateway/server # This sets the pull policy for images. pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. @@ -112,9 +112,14 @@ config: debug: false secret: enabled: false + # Define your secret and deploy it with any name below but it should be in the same namespace + # see configs/config.example.yml secretName: "sms-gateway-server-config" unsecure: enabled: false + # If you do not care, just enable unsecure, it will create + # a config for you and it will apply what you configured. + # configs/config.example.yml, DO NOT USE the default config below configYml: >- gateway: # gateway config mode: private # gateway mode (public - allow anonymous device registration, private - protected registration) [GATEWAY__MODE] From cb9d7e725d6e7c3e518655cc644c61af27406ed5 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Thu, 4 Sep 2025 22:43:59 +0400 Subject: [PATCH 16/22] docs: update docs --- deployments/kubernetes/sms-gateway-server/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deployments/kubernetes/sms-gateway-server/README.md b/deployments/kubernetes/sms-gateway-server/README.md index 13f265f7..8d41dac1 100644 --- a/deployments/kubernetes/sms-gateway-server/README.md +++ b/deployments/kubernetes/sms-gateway-server/README.md @@ -5,7 +5,7 @@ A Helm chart for deploying the SMS Gateway Server on Kubernetes. ## Installation ```bash -helm repo add sms-gateway-server https://android-sms-gateway.github.io/server +helm repo add android-sms-gateway https://android-sms-gateway.github.io/server helm upgrade --install sms-gateway-server \ --namespace sms-gateway-system \ @@ -27,8 +27,8 @@ This chart supports three configuration methods: | Parameter | Description | Default | |-----------|-------------|---------| | `replicaCount` | Number of replicas | `1` | -| `image.repository` | Container image repository | `capcom6/sms-gateway` | -| `image.tag` | Container image tag | `""` (uses Chart.AppVersion) | +| `image.repository` | Container image repository | `ghcr.io/android-sms-gateway/server` | +| `image.tag` | Container image tag | `""` (uses Chart.AppVersion) | | `image.pullPolicy` | Image pull policy | `IfNotPresent` | | `service.type` | Kubernetes service type | `ClusterIP` | | `service.port` | Service port | `8080` | From 20196bab2ca2dc08fa07594d446ab70d2a71cf65 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Thu, 4 Sep 2025 22:55:07 +0400 Subject: [PATCH 17/22] docs: update docs --- deployments/kubernetes/sms-gateway-server/README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/deployments/kubernetes/sms-gateway-server/README.md b/deployments/kubernetes/sms-gateway-server/README.md index 8d41dac1..7e23e94a 100644 --- a/deployments/kubernetes/sms-gateway-server/README.md +++ b/deployments/kubernetes/sms-gateway-server/README.md @@ -6,11 +6,14 @@ A Helm chart for deploying the SMS Gateway Server on Kubernetes. ```bash helm repo add android-sms-gateway https://android-sms-gateway.github.io/server +helm repo update helm upgrade --install sms-gateway-server \ --namespace sms-gateway-system \ --create-namespace \ -f your-values.yaml \ + # optionally pin a chart version for reproducible installs: + # --version X.Y.Z \ android-sms-gateway/sms-gateway-server ``` @@ -266,6 +269,10 @@ config: database: sms_gateway ``` +> For production: run your database as a managed/external service with backups +> and durable storage. Avoid in-cluster ephemeral databases unless explicitly +> configured with PersistentVolumeClaims and a proper HA/backup strategy. + ### Production Deployment with External Secret ```yaml @@ -318,7 +325,7 @@ extraEnv: ## Security Considerations -**Always use external secrets in production** for sensitive configuration values +**Always use external secrets in production** for sensitive configuration values. ## Troubleshooting From 0382d7083ab5fc9f1cd8226e9552b04655b47b9b Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Thu, 4 Sep 2025 22:56:06 +0400 Subject: [PATCH 18/22] docs: update docs --- deployments/kubernetes/sms-gateway-server/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/kubernetes/sms-gateway-server/README.md b/deployments/kubernetes/sms-gateway-server/README.md index 7e23e94a..e0010d7c 100644 --- a/deployments/kubernetes/sms-gateway-server/README.md +++ b/deployments/kubernetes/sms-gateway-server/README.md @@ -352,4 +352,4 @@ For complete examples, see: - **[examples/values.yaml](examples/values.yaml)** - Example Helm values configuration with external secret setup -- **[configs/config.example.yml](../../configs/config.example.yml)** - Complete application configuration reference +- **[configs/config.example.yml](../../../configs/config.example.yml)** - Complete application configuration reference From 33a4c212d39126631c722dd5b29d571aa17e6b49 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Fri, 5 Sep 2025 11:54:12 +0400 Subject: [PATCH 19/22] docs: make example easy --- deployments/kubernetes/sms-gateway-server/examples/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/kubernetes/sms-gateway-server/examples/values.yaml b/deployments/kubernetes/sms-gateway-server/examples/values.yaml index 1ba316c7..27c3f8ea 100644 --- a/deployments/kubernetes/sms-gateway-server/examples/values.yaml +++ b/deployments/kubernetes/sms-gateway-server/examples/values.yaml @@ -60,7 +60,7 @@ config: extraEnv: - name: HTTP__API__HOST - value: https://sms-gateway.parksmart.mu + value: https://sms.example.com - name: HTTP__OPENAPI__ENABLED value: "true" - name: HTTP__API__PATH From 60147a5d67895003d20c4eaf5ef43c4214ebf96e Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Fri, 5 Sep 2025 12:16:50 +0400 Subject: [PATCH 20/22] fix: update release --- deployments/kubernetes/sms-gateway-server/Chart.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deployments/kubernetes/sms-gateway-server/Chart.yaml b/deployments/kubernetes/sms-gateway-server/Chart.yaml index 8758695b..1b811098 100644 --- a/deployments/kubernetes/sms-gateway-server/Chart.yaml +++ b/deployments/kubernetes/sms-gateway-server/Chart.yaml @@ -6,7 +6,8 @@ type: application version: 0.2.10 -appVersion: "1.29.0" +# appVersion is always updated in CI +appVersion: "latest" home: https://github.com/android-sms-gateway/server sources: From 0ca4786fefa673c86b1440666fef3e9a6cc1fb85 Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Fri, 5 Sep 2025 12:40:59 +0400 Subject: [PATCH 21/22] ci: bump version --- .github/workflows/build-chart.yaml | 23 +++++++++- .github/workflows/bump-chart-app-version.yaml | 46 ------------------- .../kubernetes/sms-gateway-server/Chart.yaml | 2 +- 3 files changed, 23 insertions(+), 48 deletions(-) delete mode 100644 .github/workflows/bump-chart-app-version.yaml diff --git a/.github/workflows/build-chart.yaml b/.github/workflows/build-chart.yaml index 294b2da0..fd9aad52 100644 --- a/.github/workflows/build-chart.yaml +++ b/.github/workflows/build-chart.yaml @@ -7,7 +7,6 @@ on: paths: - 'deployments/kubernetes/**' - permissions: contents: write @@ -25,6 +24,28 @@ jobs: git config user.name "$GITHUB_ACTOR" git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + - name: Install yq + run: sudo apt-get install -y yq + + - name: Get last Git tag + id: get_tag + # Forks will not have tags, so it won't change the version + run: | + TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + echo "tag=$TAG" >> $GITHUB_OUTPUT + + - name: Update appVersion in Chart.yaml for release + if: steps.get_tag.outputs.tag != '' + run: | + FILE="deployments/kubernetes/sms-gateway-server/Chart.yaml" + TAG="${{ steps.get_tag.outputs.tag }}" + + # Strip leading 'v' if present + APPVERSION="${TAG#v}" + + echo "Temporarily updating appVersion in $FILE to $APPVERSION for release" + yq -i ".appVersion = \"$APPVERSION\"" "$FILE" + - name: Run chart-releaser id: cr uses: helm/chart-releaser-action@v1.5.0 diff --git a/.github/workflows/bump-chart-app-version.yaml b/.github/workflows/bump-chart-app-version.yaml deleted file mode 100644 index 12424cc7..00000000 --- a/.github/workflows/bump-chart-app-version.yaml +++ /dev/null @@ -1,46 +0,0 @@ -name: Release Charts - -on: - push: - tags: - - 'v*.*.*' - -permissions: - contents: write - -jobs: - release: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Configure Git - run: | - git config user.name "$GITHUB_ACTOR" - git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - - - name: Bump Chart.yaml - run: | - TAG_VERSION=${GITHUB_REF#refs/tags/} - TAG_VERSION=${TAG_VERSION#v} - CHART_FILE=deployments/kubernetes/sms-gateway-server/Chart.yaml - - # Extract current version - CURRENT_VERSION=$(awk '/^version:/ {print $2}' $CHART_FILE) - IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION" - - # Increment patch - PATCH=$((PATCH + 1)) - NEW_VERSION="$MAJOR.$MINOR.$PATCH" - - # Update Chart.yaml - sed -i "s/^version:.*/version: $NEW_VERSION/" $CHART_FILE - sed -i "s/^appVersion:.*/appVersion: \"$TAG_VERSION\"/" $CHART_FILE - - # Commit and push changes - git add $CHART_FILE - git commit -m "[infra] bump Chart version to $NEW_VERSION and appVersion to $TAG_VERSION" - git push origin HEAD:master diff --git a/deployments/kubernetes/sms-gateway-server/Chart.yaml b/deployments/kubernetes/sms-gateway-server/Chart.yaml index 1b811098..2bbc377b 100644 --- a/deployments/kubernetes/sms-gateway-server/Chart.yaml +++ b/deployments/kubernetes/sms-gateway-server/Chart.yaml @@ -4,7 +4,7 @@ description: A Helm chart for Kubernetes to deploy sms-gateway-server. type: application -version: 0.2.10 +version: 0.2.11 # appVersion is always updated in CI appVersion: "latest" From 39782670db7c7d37c1e9e141d3eda249b1cd27bb Mon Sep 17 00:00:00 2001 From: Bruno Bernard Date: Fri, 5 Sep 2025 15:03:42 +0400 Subject: [PATCH 22/22] ci: update yaml --- .github/workflows/build-chart.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-chart.yaml b/.github/workflows/build-chart.yaml index fd9aad52..96e50d88 100644 --- a/.github/workflows/build-chart.yaml +++ b/.github/workflows/build-chart.yaml @@ -18,6 +18,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + fetch-tags: true - name: Configure Git run: | @@ -25,7 +26,7 @@ jobs: git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - name: Install yq - run: sudo apt-get install -y yq + uses: mikefarah/yq@v4 - name: Get last Git tag id: get_tag @@ -52,4 +53,4 @@ jobs: env: CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" with: - charts_dir: ./deployments/kubernetes \ No newline at end of file + charts_dir: ./deployments/kubernetes