commit bc314a3014f1456ae5362ae6265fa2ca3f4f0537 Author: Kofo Okesola Date: Thu Aug 14 02:47:39 2025 +0100 initial commit diff --git a/servflow/.helmignore b/servflow/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/servflow/.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/servflow/Chart.lock b/servflow/Chart.lock new file mode 100644 index 0000000..ce99511 --- /dev/null +++ b/servflow/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: ingress-nginx + repository: https://kubernetes.github.io/ingress-nginx + version: 4.11.2 +digest: sha256:ab93695e04dab546906b6bad42e147fa538237f6a52a5b3cceff14fc287d4268 +generated: "2024-10-02T06:05:05.964658+01:00" diff --git a/servflow/Chart.yaml b/servflow/Chart.yaml new file mode 100644 index 0000000..24162dd --- /dev/null +++ b/servflow/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: servflow +description: Helm chart for the helm deployment + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 1.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.2.1" diff --git a/servflow/templates/NOTES.txt b/servflow/templates/NOTES.txt new file mode 100644 index 0000000..abf4646 --- /dev/null +++ b/servflow/templates/NOTES.txt @@ -0,0 +1 @@ +HAVE FUN! diff --git a/servflow/templates/_helpers.tpl b/servflow/templates/_helpers.tpl new file mode 100644 index 0000000..d54f91a --- /dev/null +++ b/servflow/templates/_helpers.tpl @@ -0,0 +1,54 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "servflow.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 "servflow.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 "servflow.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "servflow.labels" -}} +helm.sh/chart: {{ include "servflow.chart" . }} +{{ include "helm.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "servflow.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "servflow.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/servflow/templates/deployment.yaml b/servflow/templates/deployment.yaml new file mode 100644 index 0000000..cf36ca2 --- /dev/null +++ b/servflow/templates/deployment.yaml @@ -0,0 +1,97 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: servflow-engine + labels: + app: servflow-engine +spec: + selector: + matchLabels: + app: servflow-engine + template: + metadata: + labels: + app: servflow-engine + spec: + {{ if .Values.persistence.enabled }} + volumes: + - name: data-volume + persistentVolumeClaim: + claimName: servflow-engine-pvc + {{ end }} + imagePullSecrets: + - name: regcred + containers: + - name: servflow + resources: + limits: + memory: 50Mi + image: "servflow/servflow:v1.2.1" + {{ if .Values.persistence.enabled }} + volumeMounts: + - name: data-volume + mountPath: {{ .Values.persistence.storage.mountPath }} + {{ end }} + ports: + - name: http + containerPort: 80 + protocol: TCP + env: + - name: SERVFLOW_PORT + value: "80" + - name: SERVFLOW_APPSERVERURL + value: "{{ .Values.engine.environment }}-grpc-server-service.default.svc.cluster.local:50051" + - name: SERVFLOW_LOGLEVEL + value: {{ .Values.engine.environment }} + - name: SERVFLOW_APIKEY + value: {{ .Values.general.apikey }} + - name: SERVFLOW_REDIS_CONNECTIONSTRING + valueFrom: + secretKeyRef: + key: redis-url + name: redis-secret + - name: KEDA_REDIS_ADDRESS + valueFrom: + secretKeyRef: + name: redis-secret + key: redis-address + - name: SERVFLOW_OTEL_ENABLED + value: "true" + - name: SERVFLOW_OTEL_ADDRESS + value: jaeger-service.default.svc.cluster.local:4317 + {{ if .Values.persistence.enabled }} + - name: SERVFLOW_STORAGE_PATH + value: {{ .Values.persistence.storage.mountPath }} + {{ end}} + - name: scalersignal-consumer + resources: + limits: + memory: 10Mi + image: servflow/scalersignal-consumer:v0.1.3 + env: + - name: REDIS_ADDR + valueFrom: + secretKeyRef: + key: redis-url + name: redis-secret + - name: SUBDOMAIN + value: {{ .Values.general.subdomain }} + +--- +{{ if .Values.persistence.enabled }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: servflow-engine-pvc +spec: + accessModes: + {{ range .Values.persistence.storage.accessModes }} + - {{ . }} + {{ end }} + resources: + requests: + storage: {{ .Values.persistence.storage.size }} + {{ if .Values.persistence.storage.storageClassName }} + storageClassName: {{ .Values.persistence.storage.storageClassName }} + {{ end }} +{{ end }} \ No newline at end of file diff --git a/servflow/templates/ingress.yaml b/servflow/templates/ingress.yaml new file mode 100644 index 0000000..8fb33ef --- /dev/null +++ b/servflow/templates/ingress.yaml @@ -0,0 +1,16 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: servflow-engine +spec: + rules: + - host: {{ .Values.general.domain }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: servflow-engine-service + port: + number: 80 diff --git a/servflow/templates/scaler.yaml b/servflow/templates/scaler.yaml new file mode 100644 index 0000000..b098c3e --- /dev/null +++ b/servflow/templates/scaler.yaml @@ -0,0 +1,32 @@ +apiVersion: keda.sh/v1alpha1 +kind: TriggerAuthentication +metadata: + name: keda-redis-stream-triggerauth +spec: + secretTargetRef: + - parameter: username + name: redis-secret + key: redis-username + - parameter: password + name: redis-secret + key: redis-password +--- +apiVersion: keda.sh/v1alpha1 +kind: ScaledObject +metadata: + name: redis-streams-scaledobject +spec: + scaleTargetRef: + name: servflow-engine + pollingInterval: 5 + cooldownPeriod: 300 + maxReplicaCount: 1 + minReplicaCount: 0 + triggers: + - type: redis-streams + metadata: + addressFromEnv: KEDA_REDIS_ADDRESS + stream: "proxy_requests:{{ .Values.general.subdomain }}" + streamLength: "1" + authenticationRef: + name: keda-redis-stream-triggerauth # name of the TriggerAuthentication resource \ No newline at end of file diff --git a/servflow/templates/service.yaml b/servflow/templates/service.yaml new file mode 100644 index 0000000..4e73bae --- /dev/null +++ b/servflow/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: servflow-engine-service + labels: + app: servflow-engine +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: http + protocol: TCP + name: http + selector: + app: servflow-engine diff --git a/servflow/values.yaml b/servflow/values.yaml new file mode 100644 index 0000000..dc88465 --- /dev/null +++ b/servflow/values.yaml @@ -0,0 +1,24 @@ +# Default values for helm. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +# This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ +replicaCount: 1 + +general: + apikey: "" + domain: "" + subdomain: "" + +engine: + environment: "staging" + redisURL: "" + +persistence: + enabled: true + storage: + size: 10Mi + mountPath: "/data/servflow" + accessModes: + - ReadWriteOnce + storageClassName: "do-block-storage"