Skip to content

Commit

Permalink
add new helm chart
Browse files Browse the repository at this point in the history
  • Loading branch information
devops-mher committed Feb 9, 2024
1 parent 8b8b25e commit 451e6db
Show file tree
Hide file tree
Showing 30 changed files with 1,209 additions and 0 deletions.
20 changes: 20 additions & 0 deletions charts/karrio/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.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/
9 changes: 9 additions & 0 deletions charts/karrio/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies:
- name: redis
repository: oci://registry-1.docker.io/bitnamicharts
version: 18.12.1
- name: postgresql
repository: oci://registry-1.docker.io/bitnamicharts
version: 14.0.4
digest: sha256:c510a84973277888dd59c9b3a9680746191e74399856b42ad176ef1de400cefe
generated: "2024-02-09T10:54:39.803392003+04:00"
17 changes: 17 additions & 0 deletions charts/karrio/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v2
name: karrio
description: A karrio Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: "2024.2.rc4"
dependencies:
- name: redis
repository: oci://registry-1.docker.io/bitnamicharts
version: 18.12.1
condition: redis.enabled
- name: postgresql
repository: oci://registry-1.docker.io/bitnamicharts
version: 14.0.4
condition: postgresql.enabled
maintainers:
- name: Mher Poghosyan
Binary file added charts/karrio/charts/postgresql-14.0.4.tgz
Binary file not shown.
Binary file added charts/karrio/charts/redis-18.12.1.tgz
Binary file not shown.
22 changes: 22 additions & 0 deletions charts/karrio/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.api.ingress.enabled }}
{{- range $host := .Values.api.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.api.ingress.tls }}s{{ end }}://{{ $host.host }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.api.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "karrio.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.api.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "karrio.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "karrio.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.api.service.port }}
{{- else if contains "ClusterIP" .Values.api.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "karrio.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
46 changes: 46 additions & 0 deletions charts/karrio/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{{- define "karrio.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "karrio.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 }}

{{- define "karrio.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{- define "karrio.selectorLabels" -}}
app.kubernetes.io/name: {{ include "karrio.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{- define "karrio.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "karrio.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{- define "karrio.capabilities.kubeVersion" -}}
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}}
{{- end -}}
6 changes: 6 additions & 0 deletions charts/karrio/templates/configmap-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ include "karrio.fullname" . }}-api
data:
{{- toYaml .Values.api.config | nindent 2 }}
17 changes: 17 additions & 0 deletions charts/karrio/templates/configmap-cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.cronjob.configMaps }}
{{- range $v := .Values.cronjob.configMaps }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $v.name }}
binaryData:
{{- range $f := $v.files }}
{{- if $f.contentsB64 }}
{{ $f.key }}: "{{ $f.contentsB64 }}"
{{- else }}
{{ $f.key }}: "{{ ($.Files.Get $f.contentsFile) | b64enc }}"
{{- end }}
{{- end }}
---
{{- end }}
{{- end }}
6 changes: 6 additions & 0 deletions charts/karrio/templates/configmap-dashboard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ include "karrio.fullname" . }}-dashboard
data:
{{- toYaml .Values.dashboard.config | nindent 2 }}
6 changes: 6 additions & 0 deletions charts/karrio/templates/configmap-worker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ include "karrio.fullname" . }}-worker
data:
{{- toYaml .Values.worker.config | nindent 2 }}
96 changes: 96 additions & 0 deletions charts/karrio/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{{- if .Values.cronjob.enabled }}
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "karrio.fullname" . }}
spec:
schedule: "{{ .Values.cronjob.schedule }}"
concurrencyPolicy: "{{ .Values.cronjob.concurrencyPolicy }}"
failedJobsHistoryLimit: {{ .Values.cronjob.failedJobsHistoryLimit }}
successfulJobsHistoryLimit: {{ .Values.cronjob.successfulJobsHistoryLimit }}

jobTemplate:
spec:
template:
metadata:
labels:
app: {{ include "karrio.fullname" . }}
annotations:
{{- if .Values.cronjob.configMaps }}
{{- range $v := .Values.cronjob.configMaps }}
{{- range $f := $v.files }}
{{- if $f.contentsB64 }}
checksum/{{ $v.name }}-{{ $f.key }}: "{{ $f.contentsB64 | sha256sum }}"
{{- else }}
checksum/{{ $v.name }}-{{ $f.key }}: "{{ ($.Files.Get $f.contentsFile) | b64enc | sha256sum }}"
{{- end }}
{{- end }}
{{- end }}
{{- end }}
spec:
{{- if .Values.cronjob.cloudserviceaccount.deploy }}
serviceAccountName: {{ .Values.cronjob.cloudserviceaccount.name }}
{{- end }}
automountServiceAccountToken: true

{{- if not .Values.cronjob.image.isRepositoryPublic }}
imagePullSecrets:
- name: {{ .Values.cronjob.dockerconfigjson.name }}
{{- end }}

restartPolicy: "{{ .Values.cronjob.restartPolicy }}"

{{- if .Values.cronjob.configMaps }}
volumes:
{{- range $v := .Values.cronjob.configMaps }}
- configMap:
name: {{ $v.name }}
optional: false
name: {{ $v.name }}
{{- end }}
{{- end }}
{{- with .Values.cronjob.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: "{{ include "karrio.fullname" . }}"
image: "{{ .Values.cronjob.image.repository }}:{{ .Values.cronjob.image.tag }}"
imagePullPolicy: {{ default "IfNotPresent" .Values.cronjob.image.pullPolicy }}

{{- if .Values.cronjob.config.command }}
command:
{{- toYaml .Values.cronjob.config.command | nindent 14 }}
{{- end }}

{{- if .Values.cronjob.config.args }}
args:
{{- range $v := .Values.cronjob.config.args }}
- "{{ $v }}"
{{- end }}
{{- end }}

{{- with .Values.cronjob.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}

{{- if .Values.cronjob.config.secrets }}
envFrom:
- secretRef:
name: {{ .Release.Name }}-cronjob-secret
{{- end }}

{{- if .Values.cronjob.configMaps }}
volumeMounts:
{{- range $v := .Values.cronjob.configMaps }}
- mountPath: "{{ $v.mountPath }}"
{{- if $v.mountPropagation }}
mountPropagation: {{ $v.mountPropagation }}
{{- else }}
mountPropagation: None
{{- end }}
name: {{ $v.name }}
{{- end }}
{{- end }}
{{- end }}
102 changes: 102 additions & 0 deletions charts/karrio/templates/deployment-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "karrio.fullname" . }}-api
labels:
{{- include "karrio.labels" . | nindent 4 }}
spec:
{{- if .Values.api.minReadySeconds }}
minReadySeconds: {{ .Values.api.minReadySeconds }}
{{- end }}
{{- if .Values.api.revisionHistoryLimit }}
revisionHistoryLimit: {{ .Values.api.revisionHistoryLimit }}
{{- end }}
{{- if not .Values.api.autoscaling.enabled }}
replicas: {{ .Values.api.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "karrio.selectorLabels" . | nindent 6 }}
{{- if .Values.api.strategy }}
strategy:
{{- toYaml .Values.api.strategy | nindent 4 }}
{{- end }}
template:
metadata:
annotations:
configmap: {{ .Values.api.config | toYaml | sha256sum | trunc 10 }}
{{- with .Values.api.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "karrio.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.api.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "karrio.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.api.podSecurityContext | nindent 8 }}
{{- if .Values.api.initContainers }}
initContainers:
{{- toYaml .Values.api.initContainers | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}-api
securityContext:
{{- toYaml .Values.api.securityContext | nindent 12 }}
image: "{{ .Values.api.image.repository }}:{{ .Values.api.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.api.image.pullPolicy }}
{{- if .Values.api.command }}
command:
{{- toYaml .Values.api.command | nindent 12 }}
{{- end }}
{{- if .Values.api.extraEnv }}
env:
{{- range $key, $value := .Values.api.extraEnv }}
- name: {{ $key | quote }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
ports:
- name: http
containerPort: {{ .Values.api.containerPort | default 80 }}
protocol: TCP
{{- if .Values.api.livenessProbe }}
livenessProbe:
{{- toYaml .Values.api.livenessProbe | nindent 12 }}
{{- end }}
{{- if .Values.api.readinessProbe }}
readinessProbe:
{{- toYaml .Values.api.readinessProbe | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.api.resources | nindent 12 }}
envFrom:
- configMapRef:
name: {{ include "karrio.fullname" . }}-api
- secretRef:
name: {{ include "karrio.fullname" . }}-api
optional: true
volumeMounts:
{{- with .Values.api.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
{{- with .Values.api.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.api.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.api.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.api.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

Loading

0 comments on commit 451e6db

Please sign in to comment.