mirror of
https://gitea.com/gitea/helm-actions.git
synced 2026-12-01 08:57:48 +00:00
feat: support native Kubernetes runner jobs (#194)
### Description of the change Make DinD optional and add opt-in ServiceAccount/RBAC creation for native Kubernetes jobs. Preserve Docker defaults and compatibility with reused Helm values. ### Benefits Deploy Kubernetes jobs through the existing chart, with support for mixed backend labels. ### Possible drawbacks Requires matching runner configuration. Docker container actions remain unsupported by the upstream Kubernetes backend. ### Additional information Validated with 61 Helm tests, lint, packaging, and kind: six concurrent jobs, checkout/services, artifacts/cache, cleanup, restarts and backend upgrades. Manual validation completed. ### Checklist - [x] Parameters documented in values.yaml and generated README.md - [x] Helm templating unit tests added - [x] New resources render metadata.namespace Reviewed-on: https://gitea.com/gitea/helm-actions/pulls/194 Reviewed-by: DaanSelen <[email protected]> Reviewed-by: Lunny Xiao <[email protected]> Co-authored-by: James Tatum <[email protected]>
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
{{- if or (empty .Values.existingSecret) (empty .Values.existingSecretKey) -}}
|
||||
{{- fail "existingSecret and existingSecretKey are required when provisioning is disabled" -}}
|
||||
{{- end -}}
|
||||
{{- if and (.Values.rbac | default dict).create (not (.Values.serviceAccount | default dict).create) (empty .Values.statefulset.serviceAccountName) -}}
|
||||
{{- fail "rbac.create requires serviceAccount.create or statefulset.serviceAccountName" -}}
|
||||
{{- end -}}
|
||||
{{- if not .Values.giteaRootURL -}}
|
||||
{{- fail "giteaRootURL is required" -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -143,3 +143,11 @@ Create image for Init
|
||||
{{- define "gitea.actions.init.image" -}}
|
||||
{{ include "gitea.actions.common.image" (dict "root" . "image" .Values.init.image) }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "gitea.actions.serviceAccountName" -}}
|
||||
{{- if (.Values.serviceAccount | default dict).create -}}
|
||||
{{- default (printf "%s-runner" (include "gitea.actions.fullname" .) | trunc 63 | trimSuffix "-") .Values.statefulset.serviceAccountName -}}
|
||||
{{- else -}}
|
||||
{{- .Values.statefulset.serviceAccountName -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
{{- if and .Values.enabled (.Values.rbac | default dict).create }}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: Role
|
||||
metadata:
|
||||
name: {{ include "gitea.actions.fullname" . }}-runner
|
||||
namespace: {{ .Values.namespace | default .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "gitea.actions.labels.runner" . | nindent 4 }}
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["pods"]
|
||||
verbs: ["create", "get", "list", "delete"]
|
||||
- apiGroups: [""]
|
||||
resources: ["pods/exec"]
|
||||
verbs: ["create", "get"]
|
||||
- apiGroups: [""]
|
||||
resources: ["pods/log"]
|
||||
verbs: ["get"]
|
||||
- apiGroups: [""]
|
||||
resources: ["secrets"]
|
||||
verbs: ["create", "delete"]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: {{ include "gitea.actions.fullname" . }}-runner
|
||||
namespace: {{ .Values.namespace | default .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "gitea.actions.labels.runner" . | nindent 4 }}
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: Role
|
||||
name: {{ include "gitea.actions.fullname" . }}-runner
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ include "gitea.actions.serviceAccountName" . | quote }}
|
||||
namespace: {{ .Values.namespace | default .Release.Namespace }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,9 @@
|
||||
{{- if and .Values.enabled (.Values.serviceAccount | default dict).create }}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "gitea.actions.serviceAccountName" . | quote }}
|
||||
namespace: {{ .Values.namespace | default .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "gitea.actions.labels.runner" . | nindent 4 }}
|
||||
{{- end }}
|
||||
@@ -31,8 +31,8 @@ spec:
|
||||
{{- end }}
|
||||
spec:
|
||||
restartPolicy: Always
|
||||
{{- if .Values.statefulset.serviceAccountName }}
|
||||
serviceAccountName: {{ .Values.statefulset.serviceAccountName | quote }}
|
||||
{{- if or (.Values.serviceAccount | default dict).create .Values.statefulset.serviceAccountName }}
|
||||
serviceAccountName: {{ include "gitea.actions.serviceAccountName" . | quote }}
|
||||
{{- end }}
|
||||
{{- if .Values.statefulset.securityContext }}
|
||||
securityContext:
|
||||
@@ -85,6 +85,7 @@ spec:
|
||||
echo "Trying again in 3 seconds..."
|
||||
done
|
||||
echo "Gitea has been reached!"
|
||||
{{- if ne .Values.statefulset.dind.enabled false }}
|
||||
- name: dind
|
||||
image: "{{ include "gitea.actions.dind.image" . }}"
|
||||
restartPolicy: Always
|
||||
@@ -131,6 +132,7 @@ spec:
|
||||
{{- with .Values.statefulset.dind.extraVolumeMounts }}
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.postExtraInitContainers }}
|
||||
{{- toYaml .Values.postExtraInitContainers | nindent 8 }}
|
||||
{{- end }}
|
||||
@@ -160,9 +162,11 @@ spec:
|
||||
- mountPath: /runner/config.yaml
|
||||
name: runner-config
|
||||
subPath: config.yaml
|
||||
{{- if ne .Values.statefulset.dind.enabled false }}
|
||||
- mountPath: /var/run/docker.sock
|
||||
name: docker-socket
|
||||
subPath: docker.sock
|
||||
{{- end }}
|
||||
- mountPath: /data
|
||||
name: data-runner
|
||||
{{- with .Values.statefulset.runner.extraVolumeMounts }}
|
||||
@@ -190,8 +194,10 @@ spec:
|
||||
- name: runner-config
|
||||
configMap:
|
||||
name: {{ include "gitea.actions.fullname" . }}-runner-configmap
|
||||
{{- if ne .Values.statefulset.dind.enabled false }}
|
||||
- name: docker-socket
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
{{- with .Values.statefulset.extraVolumes }}
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
|
||||
Reference in New Issue
Block a user