Add Helm chart tooling, CI, and release packaging

This commit is contained in:
Pulse Automation Bot 2025-10-18 11:50:57 +00:00
parent d79b8e8883
commit d15ad1d0b4
25 changed files with 1299 additions and 5 deletions

View file

@ -0,0 +1,4 @@
1. Pulse hub URL: http://{{ include "pulse.fullname" . }}:{{ .Values.service.port }}
(Adjust if using ingress or LoadBalancer.)
2. Create an API token from the Pulse UI under Settings → Security for the Docker agent.
3. Deploy the optional agent by enabling `agent.enabled` and providing your server URL and token.

View file

@ -0,0 +1,97 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "pulse.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
*/}}
{{- define "pulse.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 label.
*/}}
{{- define "pulse.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Common labels.
*/}}
{{- define "pulse.labels" -}}
helm.sh/chart: {{ include "pulse.chart" . }}
{{ include "pulse.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
{{/*
Selector labels.
*/}}
{{- define "pulse.selectorLabels" -}}
app.kubernetes.io/name: {{ include "pulse.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}
{{/*
Return the name of the service account to use.
*/}}
{{- define "pulse.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{- default (printf "%s-sa" (include "pulse.fullname" .)) .Values.serviceAccount.name -}}
{{- else -}}
{{- default "default" .Values.serviceAccount.name -}}
{{- end -}}
{{- end -}}
{{/*
Return the server secret name (Pulse hub env vars).
*/}}
{{- define "pulse.serverSecretName" -}}
{{- $secret := .Values.server.secretEnv -}}
{{- if $secret.name -}}
{{- $secret.name -}}
{{- else -}}
{{- printf "%s-server-env" (include "pulse.fullname" .) -}}
{{- end -}}
{{- end -}}
{{/*
Return the agent secret name.
*/}}
{{- define "pulse.agentSecretName" -}}
{{- $secret := .Values.agent.secretEnv -}}
{{- if $secret.name -}}
{{- $secret.name -}}
{{- else -}}
{{- printf "%s-agent-env" (include "pulse.fullname" .) -}}
{{- end -}}
{{- end -}}
{{/*
Return the agent service account name.
*/}}
{{- define "pulse.agentServiceAccountName" -}}
{{- if .Values.agent.serviceAccount.create -}}
{{- default (printf "%s-agent" (include "pulse.fullname" .)) .Values.agent.serviceAccount.name -}}
{{- else if .Values.agent.serviceAccount.name -}}
{{- .Values.agent.serviceAccount.name -}}
{{- else -}}
{{- include "pulse.serviceAccountName" . -}}
{{- end -}}
{{- end -}}

View file

@ -0,0 +1,14 @@
{{- $secret := .Values.agent.secretEnv }}
{{- if and .Values.agent.enabled $secret.create (gt (len $secret.data) 0) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "pulse.agentSecretName" . }}
labels:
{{- include "pulse.labels" . | nindent 4 }}
type: Opaque
data:
{{- range $key, $value := $secret.data }}
{{ $key }}: {{ $value | toString | b64enc }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,12 @@
{{- if and .Values.agent.enabled .Values.agent.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ default (printf "%s-agent" (include "pulse.fullname" .)) .Values.agent.serviceAccount.name }}
labels:
{{- include "pulse.labels" . | nindent 4 }}
{{- with .Values.agent.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,125 @@
{{- if .Values.agent.enabled }}
{{- $kind := default "DaemonSet" .Values.agent.kind | lower }}
{{- $isDaemon := eq $kind "daemonset" }}
{{- $workloadName := printf "%s-agent" (include "pulse.fullname" .) }}
apiVersion: apps/v1
kind: {{ if $isDaemon }}DaemonSet{{ else }}Deployment{{ end }}
metadata:
name: {{ $workloadName }}
labels:
{{- include "pulse.labels" . | nindent 4 }}
app.kubernetes.io/component: agent
spec:
{{- if not $isDaemon }}
replicas: {{ .Values.agent.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "pulse.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: agent
{{- if $isDaemon }}
updateStrategy:
type: RollingUpdate
{{- end }}
template:
metadata:
labels:
{{- include "pulse.selectorLabels" . | nindent 8 }}
app.kubernetes.io/component: agent
{{- with .Values.agent.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.agent.podAnnotations }}
annotations:
{{- toYaml .Values.agent.podAnnotations | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "pulse.agentServiceAccountName" . }}
{{- $podSecurityContext := .Values.agent.podSecurityContext }}
{{- if $podSecurityContext }}
securityContext:
{{- toYaml $podSecurityContext | nindent 8 }}
{{- end }}
containers:
- name: pulse-docker-agent
image: "{{ .Values.agent.image.repository }}:{{ default .Chart.AppVersion .Values.agent.image.tag }}"
imagePullPolicy: {{ .Values.agent.image.pullPolicy }}
{{- if .Values.agent.args }}
args:
{{- toYaml .Values.agent.args | nindent 12 }}
{{- end }}
{{- $csec := .Values.agent.securityContext }}
{{- if $csec }}
securityContext:
{{- toYaml $csec | nindent 12 }}
{{- end }}
{{- $envList := list }}
{{- range .Values.agent.env }}
{{- $envList = append $envList . }}
{{- end }}
{{- range .Values.agent.extraEnv }}
{{- $envList = append $envList . }}
{{- end }}
{{- $secret := .Values.agent.secretEnv }}
{{- $secretKeys := list }}
{{- if $secret.keys }}
{{- $secretKeys = $secret.keys }}
{{- else if $secret.data }}
{{- $secretKeys = keys $secret.data }}
{{- end }}
{{- $root := . }}
{{- range $key := $secretKeys }}
{{- $envList = append $envList (dict "name" $key "valueFrom" (dict "secretKeyRef" (dict "name" (include "pulse.agentSecretName" $root) "key" $key))) }}
{{- end }}
{{- if $envList }}
env:
{{- toYaml $envList | nindent 12 }}
{{- end }}
{{- $envFrom := concat .Values.agent.envFrom .Values.agent.extraEnvFrom }}
{{- if $envFrom }}
envFrom:
{{- range $envFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- if or .Values.agent.dockerSocket.enabled .Values.agent.extraVolumeMounts }}
volumeMounts:
{{- if .Values.agent.dockerSocket.enabled }}
- name: docker-socket
mountPath: {{ .Values.agent.dockerSocket.path }}
{{- end }}
{{- with .Values.agent.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- with .Values.agent.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- if or .Values.agent.dockerSocket.enabled .Values.agent.extraVolumes }}
volumes:
{{- if .Values.agent.dockerSocket.enabled }}
- name: docker-socket
hostPath:
path: {{ .Values.agent.dockerSocket.path }}
{{- with .Values.agent.dockerSocket.hostPathType }}
type: {{ . }}
{{- end }}
{{- end }}
{{- with .Values.agent.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- with .Values.agent.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.agent.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.agent.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,135 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "pulse.fullname" . }}
labels:
{{- include "pulse.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "pulse.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "pulse.selectorLabels" . | nindent 8 }}
{{- with .Values.server.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- $podAnnotations := merge (dict) .Values.podAnnotations .Values.server.podAnnotations }}
{{- if $podAnnotations }}
annotations:
{{- toYaml $podAnnotations | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ include "pulse.serviceAccountName" . }}
{{- $podSecurityContext := merge (dict) .Values.podSecurityContext .Values.server.podSecurityContext }}
{{- if $podSecurityContext }}
securityContext:
{{- toYaml $podSecurityContext | nindent 8 }}
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: pulse
image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 7655
{{- $containerSecurityContext := merge (dict) .Values.securityContext .Values.server.securityContext }}
{{- if $containerSecurityContext }}
securityContext:
{{- toYaml $containerSecurityContext | nindent 12 }}
{{- end }}
{{- $envList := list }}
{{- range .Values.server.env }}
{{- $envList = append $envList . }}
{{- end }}
{{- range .Values.server.extraEnv }}
{{- $envList = append $envList . }}
{{- end }}
{{- $secret := .Values.server.secretEnv }}
{{- $secretKeys := list }}
{{- if $secret.keys }}
{{- $secretKeys = $secret.keys }}
{{- else if $secret.data }}
{{- $secretKeys = keys $secret.data }}
{{- end }}
{{- $root := . }}
{{- range $key := $secretKeys }}
{{- $envList = append $envList (dict "name" $key "valueFrom" (dict "secretKeyRef" (dict "name" (include "pulse.serverSecretName" $root) "key" $key))) }}
{{- end }}
{{- if $envList }}
env:
{{- toYaml $envList | nindent 12 }}
{{- end }}
{{- $envFrom := concat .Values.server.envFrom .Values.server.extraEnvFrom }}
{{- if $envFrom }}
envFrom:
{{- range $envFrom }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
volumeMounts:
- name: data
mountPath: /data
{{- with .Values.server.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.server.livenessProbe }}
{{- if .enabled }}
livenessProbe:
httpGet:
path: {{ .path }}
port: http
initialDelaySeconds: {{ .initialDelaySeconds }}
periodSeconds: {{ .periodSeconds }}
timeoutSeconds: {{ .timeoutSeconds }}
failureThreshold: {{ .failureThreshold }}
{{- end }}
{{- end }}
{{- with .Values.server.readinessProbe }}
{{- if .enabled }}
readinessProbe:
httpGet:
path: {{ .path }}
port: http
initialDelaySeconds: {{ .initialDelaySeconds }}
periodSeconds: {{ .periodSeconds }}
timeoutSeconds: {{ .timeoutSeconds }}
failureThreshold: {{ .failureThreshold }}
{{- end }}
{{- end }}
{{- with .Values.server.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: data
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
persistentVolumeClaim:
claimName: {{ include "pulse.fullname" . }}
{{- else if and .Values.persistence.enabled .Values.persistence.existingClaim }}
persistentVolumeClaim:
claimName: {{ .Values.persistence.existingClaim }}
{{- else }}
emptyDir: {}
{{- end }}
{{- with .Values.server.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.server.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.server.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.server.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View file

@ -0,0 +1,35 @@
{{- if .Values.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "pulse.fullname" . }}
labels:
{{- include "pulse.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.className }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: {{ .pathType }}
backend:
service:
name: {{ include "pulse.fullname" $ }}
port:
number: {{ $.Values.service.port }}
{{- end }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- toYaml .Values.ingress.tls | nindent 4 }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,21 @@
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "pulse.fullname" . }}
labels:
{{- include "pulse.labels" . | nindent 4 }}
{{- with .Values.persistence.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
accessModes:
{{- toYaml .Values.persistence.accessModes | nindent 4 }}
resources:
requests:
storage: {{ .Values.persistence.size }}
{{- with .Values.persistence.storageClass }}
storageClassName: {{ . }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,14 @@
{{- $secret := .Values.server.secretEnv }}
{{- if and $secret.create (gt (len $secret.data) 0) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "pulse.serverSecretName" . }}
labels:
{{- include "pulse.labels" . | nindent 4 }}
type: Opaque
data:
{{- range $key, $value := $secret.data }}
{{ $key }}: {{ $value | toString | b64enc }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,30 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "pulse.fullname" . }}
labels:
{{- include "pulse.labels" . | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- if and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if and (eq .Values.service.type "LoadBalancer") (ne .Values.service.externalTrafficPolicy "") }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }}
{{- end }}
selector:
{{- include "pulse.selectorLabels" . | nindent 4 }}
ports:
- name: http
port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
{{- if eq .Values.service.type "NodePort" }}
{{- with .Values.service.nodePort }}
nodePort: {{ . }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "pulse.serviceAccountName" . }}
labels:
{{- include "pulse.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}