From f5f2f3b452ddbb26fbfda8987bcff4d4323ced93 Mon Sep 17 00:00:00 2001 From: heidmann Date: Mon, 27 Mar 2023 08:08:39 +0200 Subject: [PATCH] add Helmchart for git-sync-mirror --- charts/Chart.yaml | 6 ++ charts/templates/_helpers.tpl | 62 ++++++++++++++++++ charts/templates/deployment.yaml | 97 ++++++++++++++++++++++++++++ charts/templates/secret.yaml | 11 ++++ charts/templates/serviceaccount.yaml | 12 ++++ charts/values.yaml | 72 +++++++++++++++++++++ 6 files changed, 260 insertions(+) create mode 100644 charts/Chart.yaml create mode 100644 charts/templates/_helpers.tpl create mode 100644 charts/templates/deployment.yaml create mode 100644 charts/templates/secret.yaml create mode 100644 charts/templates/serviceaccount.yaml create mode 100644 charts/values.yaml diff --git a/charts/Chart.yaml b/charts/Chart.yaml new file mode 100644 index 0000000..915debc --- /dev/null +++ b/charts/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +appVersion: 1.1.0 +description: A Helm chart for git-sync-mirror +name: git-sync-mirror +type: application +version: 1.0.1 \ No newline at end of file diff --git a/charts/templates/_helpers.tpl b/charts/templates/_helpers.tpl new file mode 100644 index 0000000..b46896e --- /dev/null +++ b/charts/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "git-mirroring.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 "git-mirroring.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 "git-mirroring.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "git-mirroring.labels" -}} +helm.sh/chart: {{ include "git-mirroring.chart" . }} +{{ include "git-mirroring.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "git-mirroring.selectorLabels" -}} +app.kubernetes.io/name: {{ include "git-mirroring.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "git-mirroring.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "git-mirroring.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/templates/deployment.yaml b/charts/templates/deployment.yaml new file mode 100644 index 0000000..4b471cd --- /dev/null +++ b/charts/templates/deployment.yaml @@ -0,0 +1,97 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "git-mirroring.fullname" . }} + labels: + {{- include "git-mirroring.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "git-mirroring.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "git-mirroring.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "git-mirroring.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default (printf "v%s" .Chart.AppVersion) }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + env: + - name: "SRC_REPO" + value: {{ required "URL of the source repository must be configured." .Values.repositories.sourceRepository.gitHttpsUrl | quote }} + - name: "SRC_REPO_TOKEN" + valueFrom: + secretKeyRef: + name: {{ include "git-mirroring.fullname" . }} + key: SRC_REPO_TOKEN + - name: "SRC_REPO_TOKEN_USER" + valueFrom: + secretKeyRef: + name: {{ include "git-mirroring.fullname" . }} + key: SRC_REPO_TOKEN_USER + {{- if .Values.repositories.sourceRepository.httpProxy }} + - name: HTTP_SRC_PROXY + value: {{ .Values.repositories.sourceRepository.httpProxy | quote }} + {{- end }} + - name: "DST_REPO" + value: {{ required "URL of the destination repository must be configured." .Values.repositories.destinationRepository.gitHttpsUrl | quote }} + - name: "DST_REPO_TOKEN" + valueFrom: + secretKeyRef: + name: {{ include "git-mirroring.fullname" . }} + key: DST_REPO_TOKEN + - name: "DST_REPO_TOKEN_USER" + valueFrom: + secretKeyRef: + name: {{ include "git-mirroring.fullname" . }} + key: DST_REPO_TOKEN_USER + {{- if .Values.repositories.destinationRepository.httpProxy }} + - name: "HTTP_SRC_PROXY" + value: {{ .Values.repositories.destinationRepository.httpProxy | quote }} + {{- end }} + - name: "DEBUG" + value: {{ .Values.synchronization.debug | quote }} + - name: "TWO_WAY" + value: {{ .Values.synchronization.twoWay | quote }} + - name: "GIT_FORCE_PUSH" + value: {{ .Values.synchronization.gitForcePush | quote }} + - name: "HTTP_TLS_VERIFY" + value: {{ .Values.synchronization.httpTlsVerify | quote }} + - name: "HTTP_ALLOW_TOKENS_INSECURE" + value: {{ .Values.synchronization.httpAllowTokensInsecure | quote }} + - name: "ONCE" + value: {{ .Values.synchronization.once | quote }} + - name: "SLEEP_TIME" + value: {{ .Values.synchronization.sleepTime | quote }} + - name: "IGNORE_REFS_PATTERN" + value: {{ .Values.synchronization.ignoreRefsPattern | quote }} + - name: "TLS_TOFU" + value: {{ .Values.synchronization.tlsTofu | quote }} + {{- 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/charts/templates/secret.yaml b/charts/templates/secret.yaml new file mode 100644 index 0000000..a147039 --- /dev/null +++ b/charts/templates/secret.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "git-mirroring.fullname" . }} + labels: + {{- include "git-mirroring.labels" . | nindent 4 }} +data: + SRC_REPO_TOKEN: {{ required "Access token for the source repository must be configured." .Values.repositories.sourceRepository.accessToken | b64enc | quote }} + SRC_REPO_TOKEN_USER: {{ required "User name for the source repository must be configured." .Values.repositories.sourceRepository.accessTokenUser | b64enc | quote }} + DST_REPO_TOKEN: {{ required "Access token for the destination repository must be configured." .Values.repositories.destinationRepository.accessToken | b64enc | quote }} + DST_REPO_TOKEN_USER: {{ required "User name for the destination repository must be configured." .Values.repositories.destinationRepository.accessTokenUser | b64enc | quote }} \ No newline at end of file diff --git a/charts/templates/serviceaccount.yaml b/charts/templates/serviceaccount.yaml new file mode 100644 index 0000000..5bf8b96 --- /dev/null +++ b/charts/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "git-mirroring.serviceAccountName" . }} + labels: + {{- include "git-mirroring.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/values.yaml b/charts/values.yaml new file mode 100644 index 0000000..7fda4d4 --- /dev/null +++ b/charts/values.yaml @@ -0,0 +1,72 @@ +image: + repository: enteee/git-sync-mirror + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +repositories: + sourceRepository: + gitHttpsUrl: + accessToken: + accessTokenUser: + httpProxy: + destinationRepository: + gitHttpsUrl: + accessToken: + accessTokenUser: + httpProxy: +synchronization: + debug: "false" + prune: "false" + twoWay: "false" + gitForcePush: "false" + httpTlsVerify: "true" + httpAllowTokensInsecure: "false" + once: "false" + sleepTime: "60s" + ignoreRefsPattern: "refs/pull" + tlsTofu: "false" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoaot: true + # runAsUser: 1000 + +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 + +nodeSelector: {} + +tolerations: [] + +affinity: {}