From ef0f1b40ea664002339e54cdf6f25b76c099ab44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Casta=C3=B1o=20Arteaga?= Date: Fri, 31 Oct 2025 12:23:30 +0100 Subject: [PATCH] Add Helm chart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Sergio CastaƱo Arteaga --- charts/dco2/Chart.yaml | 15 ++++ charts/dco2/templates/_helpers.tpl | 74 +++++++++++++++++ charts/dco2/templates/server_deployment.yaml | 62 +++++++++++++++ charts/dco2/templates/server_ingress.yaml | 30 +++++++ charts/dco2/templates/server_secret.yaml | 17 ++++ charts/dco2/templates/server_service.yaml | 19 +++++ charts/dco2/values.yaml | 83 ++++++++++++++++++++ 7 files changed, 300 insertions(+) create mode 100644 charts/dco2/Chart.yaml create mode 100644 charts/dco2/templates/_helpers.tpl create mode 100644 charts/dco2/templates/server_deployment.yaml create mode 100644 charts/dco2/templates/server_ingress.yaml create mode 100644 charts/dco2/templates/server_secret.yaml create mode 100644 charts/dco2/templates/server_service.yaml create mode 100644 charts/dco2/values.yaml diff --git a/charts/dco2/Chart.yaml b/charts/dco2/Chart.yaml new file mode 100644 index 0000000..d7abee4 --- /dev/null +++ b/charts/dco2/Chart.yaml @@ -0,0 +1,15 @@ +apiVersion: v2 +name: dco2 +description: DCO2 GitHub App server +type: application +version: 0.1.0 +appVersion: 0.1.0 +kubeVersion: ">= 1.25.0-0" +keywords: + - dco + - dco2 +maintainers: + - name: Sergio + email: tegioz@icloud.com + - name: Cintia + email: cynthiasg@icloud.com diff --git a/charts/dco2/templates/_helpers.tpl b/charts/dco2/templates/_helpers.tpl new file mode 100644 index 0000000..235e13e --- /dev/null +++ b/charts/dco2/templates/_helpers.tpl @@ -0,0 +1,74 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "dco2.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a fully qualified app name. +*/}} +{{- define "dco2.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := include "dco2.name" . -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Kubernetes resource name prefix +Using the prefix allows deploying multiple instances of the chart in a single namespace. +If the dynamic prefix is disabled, the helper returns an empty string. +Resource names are capped at 63 characters. +We truncate the prefix to leave space for the longest suffix ("server-config" = 12 chars). +*/}} +{{- define "dco2.resourceNamePrefix" -}} +{{- if .Values.dynamicResourceNamePrefixEnabled -}} +{{- include "dco2.fullname" . | trunc 43 | trimSuffix "-" | printf "%s-" -}} +{{- else -}} +{{- "" -}} +{{- end -}} +{{- end -}} + +{{/* +Compose a resource name using the optional prefix. +*/}} +{{- define "dco2.resourceName" -}} +{{- $root := index . 0 -}} +{{- $name := index . 1 -}} +{{- printf "%s%s" (include "dco2.resourceNamePrefix" $root) $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create chart name and version. +*/}} +{{- define "dco2.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels. +*/}} +{{- define "dco2.labels" -}} +helm.sh/chart: {{ include "dco2.chart" . }} +{{ include "dco2.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels. +*/}} +{{- define "dco2.selectorLabels" -}} +app.kubernetes.io/name: {{ include "dco2.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} diff --git a/charts/dco2/templates/server_deployment.yaml b/charts/dco2/templates/server_deployment.yaml new file mode 100644 index 0000000..af1f9e6 --- /dev/null +++ b/charts/dco2/templates/server_deployment.yaml @@ -0,0 +1,62 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app.kubernetes.io/component: server + {{- include "dco2.labels" . | nindent 4 }} + name: {{ include "dco2.resourceName" (list . "server") }} +spec: + replicas: {{ .Values.server.deploy.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/component: server + {{- include "dco2.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + app.kubernetes.io/component: server + {{- include "dco2.selectorLabels" . | nindent 8 }} + {{- with .Values.server.deploy.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.server.deploy.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - command: + - dco2-server + args: + - --config-file + - {{ printf "%s/%s" .Values.configDir .Values.configFileName | quote }} + image: {{ printf "%s:%s" .Values.server.deploy.image.repository (default "latest" .Values.imageTag) }} + imagePullPolicy: {{ .Values.pullPolicy }} + name: server + {{- with .Values.server.deploy.containerSecurityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + ports: + - containerPort: 9000 + name: http + protocol: TCP + {{- with .Values.server.deploy.readinessProbe }} + readinessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + resources: + {{- toYaml .Values.server.deploy.resources | nindent 12 }} + volumeMounts: + - mountPath: {{ .Values.configDir | quote }} + name: server-config + readOnly: true + volumes: + - name: server-config + secret: + secretName: {{ include "dco2.resourceName" (list . "server-config") }} diff --git a/charts/dco2/templates/server_ingress.yaml b/charts/dco2/templates/server_ingress.yaml new file mode 100644 index 0000000..0ba0fb4 --- /dev/null +++ b/charts/dco2/templates/server_ingress.yaml @@ -0,0 +1,30 @@ +{{- if .Values.server.ingress.enabled -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + labels: + app.kubernetes.io/component: server + {{- include "dco2.labels" . | nindent 4 }} + name: {{ include "dco2.resourceName" (list . "server") }} + {{- with .Values.server.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.server.ingress.className }} + ingressClassName: {{ .Values.server.ingress.className }} + {{- end }} + defaultBackend: + service: + name: {{ include "dco2.resourceName" (list . "server") }} + port: + number: {{ .Values.server.ingress.backendServicePort }} + {{- with .Values.server.ingress.hosts }} + rules: + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.server.ingress.tls }} + tls: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/dco2/templates/server_secret.yaml b/charts/dco2/templates/server_secret.yaml new file mode 100644 index 0000000..4885b18 --- /dev/null +++ b/charts/dco2/templates/server_secret.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "dco2.resourceName" (list . "server-config") }} +type: Opaque +stringData: + {{ .Values.configFileName }}: |- + github_app: + {{- if .Values.server.config.githubApp.apiHost }} + api_host: {{ .Values.server.config.githubApp.apiHost }} + {{- end }} + app_id: {{ .Values.server.config.githubApp.appId }} + private_key: |- +{{ .Values.server.config.githubApp.privateKey | default "" | nindent 8 }} + webhook_secret: {{ .Values.server.config.githubApp.webhookSecret | quote }} + log_format: {{ .Values.server.config.logFormat }} + server_addr: {{ .Values.server.config.addr }} diff --git a/charts/dco2/templates/server_service.yaml b/charts/dco2/templates/server_service.yaml new file mode 100644 index 0000000..b22fd9b --- /dev/null +++ b/charts/dco2/templates/server_service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/component: server + {{- include "dco2.labels" . | nindent 4 }} + name: {{ include "dco2.resourceName" (list . "server") }} + {{- with .Values.server.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + allocateLoadBalancerNodePorts: {{ .Values.server.service.allocateLoadBalancerNodePorts }} + ports: + {{- toYaml .Values.server.service.ports | nindent 4 }} + selector: + app.kubernetes.io/component: server + {{- include "dco2.selectorLabels" . | nindent 4 }} + type: {{ default "ClusterIP" .Values.server.service.type }} diff --git a/charts/dco2/values.yaml b/charts/dco2/values.yaml new file mode 100644 index 0000000..b4af861 --- /dev/null +++ b/charts/dco2/values.yaml @@ -0,0 +1,83 @@ +# DCO2 chart default configuration values + +# Image pull secrets (if needed) +imagePullSecrets: [] + +# Image tag to deploy. Defaults to "latest" when empty. +imageTag: "" + +# Name overrides +nameOverride: "" + +# Image pull policy +pullPolicy: IfNotPresent + +# Overwrite the installation's fullname generation (used for resource naming) +fullnameOverride: "" + +# Enable dynamic resource name prefix +# +# When enabled, resources include the Helm installation name as a prefix so multiple +# installations can share a namespace. Override the prefix with `fullnameOverride`. +dynamicResourceNamePrefixEnabled: false + +# Directory path where the configuration files should be mounted +configDir: "/home/dco2/.config/dco2" + +# Configuration file name mounted for the dco2-server binary +configFileName: "dco2-server.yml" + +# DCO2 server configuration +server: + # Configuration passed to the application via a secret + config: + # Address to listen on + addr: "0.0.0.0:9000" + + # GitHub application configuration + githubApp: + # Optional GitHub API host override + apiHost: "" + # GitHub application identifier + appId: 0 + # GitHub application private key + privateKey: "" + # GitHub webhook secret + webhookSecret: "" + + # Log output format [json|pretty] + logFormat: json + + # Deployment configuration + deploy: + containerSecurityContext: {} + image: + repository: ghcr.io/cncf/dco2/server + podAnnotations: {} + podSecurityContext: {} + readinessProbe: + httpGet: + path: /health-check + port: 9000 + replicaCount: 1 + resources: {} + + # Ingress configuration + ingress: + annotations: {} + backendServicePort: 80 + className: "" + enabled: false + hosts: [] + tls: [] + + # Service configuration + service: + allocateLoadBalancerNodePorts: true + annotations: {} + ports: + - name: http + port: 80 + protocol: TCP + targetPort: 9000 + type: ClusterIP