Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions charts/ctrlc-sync/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
11 changes: 11 additions & 0 deletions charts/ctrlc-sync/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v2
name: ctrlc-sync
description: A Helm chart for ctrlc sync jobs in Kubernetes
type: application
version: 0.1.0
appVersion: "v0.16.2"

maintainers:
- name: ctrlplane
email: support@ctrlplane.com
url: https://ctrlplane.dev
46 changes: 46 additions & 0 deletions charts/ctrlc-sync/templates/_env.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{{- define "ctrlc-sync.envs" -}}
{{- if kindIs "map" .Values.ctrlc.apiKey -}}
- name: CTRLPLANE_API_KEY
{{- toYaml .Values.ctrlc.apiKey | nindent 2 }}
{{- else -}}
- name: CTRLPLANE_API_KEY
valueFrom:
secretKeyRef:
name: "{{ include "ctrlc-sync.secretname" . }}"
key: "apiKey"
{{- end }}

{{- if kindIs "map" .Values.ctrlc.workspaceID }}
- name: CTRLPLANE_WORKSPACE
{{- toYaml .Values.ctrlc.workspaceID | nindent 2 }}
{{- else }}
- name: CTRLPLANE_WORKSPACE
value: "{{ .Values.ctrlc.workspaceID }}"
{{- end }}

{{- if kindIs "map" .Values.ctrlc.apiURL }}
- name: CTRLPLANE_URL
{{- toYaml .Values.ctrlc.apiURL | nindent 2 }}
{{- else }}
- name: CTRLPLANE_URL
value: "{{ .Values.ctrlc.apiURL }}"
{{- end }}

{{- if kindIs "map" .Values.ctrlc.identifier }}
- name: CTRLPLANE_CLUSTER_IDENTIFIER
{{- toYaml .Values.ctrlc.identifier | nindent 2 }}
{{- else }}
- name: CTRLPLANE_CLUSTER_IDENTIFIER
value: "{{ .Values.ctrlc.identifier }}"
{{- end }}

{{- if kindIs "map" .Values.ctrlc.logLevel }}
- name: CTRLPLANE_LOG_LEVEL
{{- toYaml .Values.ctrlc.logLevel | nindent 2 }}
{{- else }}
- name: CTRLPLANE_LOG_LEVEL
value: "{{ .Values.ctrlc.logLevel }}"
{{- end }}

{{- end }}

75 changes: 75 additions & 0 deletions charts/ctrlc-sync/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "ctrlc-sync.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 "ctrlc-sync.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 "ctrlc-sync.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "ctrlc-sync.secretname" -}}
{{- printf "%s-secret" (include "ctrlc-sync.fullname" .) | trunc 63 | trimSuffix "-" }}
{{- end }}


{{/*
Common labels
*/}}
{{- define "ctrlc-sync.labels" -}}
helm.sh/chart: {{ include "ctrlc-sync.chart" . }}
{{ include "ctrlc-sync.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "ctrlc-sync.selectorLabels" -}}
app.kubernetes.io/name: {{ include "ctrlc-sync.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "ctrlc-sync.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "ctrlc-sync.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{- define "ctrlc-sync.clusterRole.k8s" -}}
{{- printf "%s-k8s-sync-role" (include "ctrlc-sync.fullname" .) | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "ctrlc-sync.clusterRoleBinding.k8s" -}}
{{- printf "%s-k8s-sync-rolebinding" (include "ctrlc-sync.fullname" .) | trunc 63 | trimSuffix "-" }}
{{- end }}
16 changes: 16 additions & 0 deletions charts/ctrlc-sync/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if .Values.rbac.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "ctrlc-sync.clusterRoleBinding.k8s" . }}
labels:
{{- include "ctrlc-sync.labels" . | nindent 4 }}
subjects:
- kind: ServiceAccount
name: {{ include "ctrlc-sync.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: {{ include "ctrlc-sync.clusterRole.k8s" . }}
apiGroup: rbac.authorization.k8s.io
{{- end }}
15 changes: 15 additions & 0 deletions charts/ctrlc-sync/templates/clusterroles.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if .Values.rbac.enabled -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "ctrlc-sync.clusterRole.k8s" . }}
labels:
{{- include "ctrlc-sync.labels" . | nindent 4 }}
rules:
- apiGroups: ["apps"]
resources: ["statefulsets", "deployments"]
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources: ["namespaces"]
verbs: ["get", "list", "watch"]
{{- end }}
95 changes: 95 additions & 0 deletions charts/ctrlc-sync/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "ctrlc-sync.fullname" . }}
labels:
{{- include "ctrlc-sync.labels" . | nindent 4 }}
spec:
schedule: "{{ .Values.cron.schedule }}"
{{- if .Values.cron.timeZone }}
timeZone: "{{ .Values.cron.timeZone }}"
{{- end }}
concurrencyPolicy: "{{ .Values.cron.concurrencyPolicy }}"
{{- if ne .Values.cron.startingDeadlineSeconds nil }}
startingDeadlineSeconds: {{ .Values.cron.startingDeadlineSeconds }}
{{- end }}
successfulJobsHistoryLimit: {{ .Values.cron.successfulJobsHistoryLimit }}
failedJobsHistoryLimit: {{ .Values.cron.failedJobsHistoryLimit }}
jobTemplate:
metadata:
{{- with .Values.jobAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "ctrlc-sync.labels" . | nindent 8 }}
{{- with .Values.jobLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
backoffLimit: {{ .Values.job.backoffLimit }}
{{- if ne .Values.job.activeDeadlineSeconds nil }}
activeDeadlineSeconds: {{ .Values.job.activeDeadlineSeconds }}
{{- end }}
{{- if ne .Values.job.ttlSecondsAfterFinished nil }}
ttlSecondsAfterFinished: {{ .Values.job.ttlSecondsAfterFinished }}
{{- end }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 12 }}
{{- end }}
labels:
{{- include "ctrlc-sync.labels" . | nindent 12 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 12 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 12 }}
{{- end }}
serviceAccountName: {{ include "ctrlc-sync.serviceAccountName" . }}
{{- with .Values.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
restartPolicy: OnFailure
containers:
- name: {{ .Chart.Name }}
{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 16 }}
{{- end }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["ctrlc"]
args: ["sync", "kubernetes"]
env:
{{- include "ctrlc-sync.envs" . | nindent 16 }}
{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 16 }}
{{- end }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 16 }}
{{- end }}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 12 }}
{{- end }}

10 changes: 10 additions & 0 deletions charts/ctrlc-sync/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if not (kindIs "map" .Values.ctrlc.apiKey ) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "ctrlc-sync.secretname" . }}
labels:
{{- include "ctrlc-sync.labels" . | nindent 4 }}
data:
apiKey: {{ .Values.ctrlc.apiKey | b64enc }}
{{- end }}
13 changes: 13 additions & 0 deletions charts/ctrlc-sync/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "ctrlc-sync.serviceAccountName" . }}
labels:
{{- include "ctrlc-sync.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
Loading