Skip to content

Commit 0a8909f

Browse files
committed
feat: add chart helm
1 parent 26db625 commit 0a8909f

10 files changed

Lines changed: 360 additions & 1 deletion

File tree

.github/workflows/helm-release.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Release Helm Chart
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
11+
jobs:
12+
release-chart:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Install Helm
23+
uses: azure/setup-helm@v4
24+
with:
25+
version: "latest"
26+
27+
- name: Login to Helm OCI Registry
28+
run: |
29+
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ${{ env.REGISTRY }} -u ${{ github.actor }} --password-stdin
30+
31+
- name: Extract version from Chart.yaml
32+
id: version
33+
run: |
34+
# Extract version from Chart.yaml
35+
VERSION=$(grep '^version:' ./chart/Chart.yaml | awk '{print $2}')
36+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
37+
echo "Chart version: ${VERSION}"
38+
39+
- name: Package Helm Chart
40+
run: |
41+
helm package ./chart
42+
43+
- name: Push Helm Chart to OCI Registry
44+
run: |
45+
helm push ditto-${{ steps.version.outputs.version }}.tgz \
46+
oci://${{ env.REGISTRY }}/${{ github.repository_owner }}

chart/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

chart/Chart.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: ditto
3+
description: A Helm chart for ditto - Docker Image Tracking & Transfer Operation
4+
type: application
5+
version: 0.1.0
6+
appVersion: "0.1.0"

chart/templates/_helpers.tpl

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "ditto.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "ditto.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "ditto.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "ditto.labels" -}}
37+
helm.sh/chart: {{ include "ditto.chart" . }}
38+
{{ include "ditto.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "ditto.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "ditto.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "ditto.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "ditto.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}

chart/templates/configmap.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "ditto.fullname" . }}
5+
labels:
6+
{{- include "ditto.labels" . | nindent 4 }}
7+
data:
8+
config.yaml: |
9+
{{- toYaml .Values.config.ditto | nindent 4 }}

chart/templates/deployment.yaml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "ditto.fullname" . }}
5+
labels:
6+
{{- include "ditto.labels" . | nindent 4 }}
7+
spec:
8+
replicas: {{ .Values.replicaCount }}
9+
selector:
10+
matchLabels:
11+
{{- include "ditto.selectorLabels" . | nindent 6 }}
12+
template:
13+
metadata:
14+
annotations:
15+
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
16+
{{- with .Values.podAnnotations }}
17+
{{- toYaml . | nindent 8 }}
18+
{{- end }}
19+
labels:
20+
{{- include "ditto.selectorLabels" . | nindent 8 }}
21+
spec:
22+
{{- with .Values.imagePullSecrets }}
23+
imagePullSecrets:
24+
{{- toYaml . | nindent 8 }}
25+
{{- end }}
26+
serviceAccountName: {{ include "ditto.serviceAccountName" . }}
27+
securityContext:
28+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
29+
containers:
30+
- name: {{ .Chart.Name }}
31+
securityContext:
32+
allowPrivilegeEscalation: true
33+
capabilities:
34+
add:
35+
- SETUID
36+
- SETGID
37+
appArmorProfile:
38+
type: Unconfined
39+
seccompProfile:
40+
type: Unconfined
41+
runAsUser: 1000
42+
runAsGroup: 1000
43+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
44+
imagePullPolicy: {{ .Values.image.pullPolicy }}
45+
args:
46+
- "--config"
47+
- "/config.yaml"
48+
- "--log-format"
49+
- "{{ .Values.config.logFormat }}"
50+
ports:
51+
- name: http
52+
containerPort: {{ .Values.service.port }}
53+
protocol: TCP
54+
livenessProbe:
55+
httpGet:
56+
path: /health
57+
port: http
58+
initialDelaySeconds: 30
59+
periodSeconds: 10
60+
timeoutSeconds: 5
61+
failureThreshold: 3
62+
readinessProbe:
63+
httpGet:
64+
path: /ready
65+
port: http
66+
initialDelaySeconds: 10
67+
periodSeconds: 5
68+
timeoutSeconds: 3
69+
failureThreshold: 3
70+
startupProbe:
71+
httpGet:
72+
path: /health
73+
port: http
74+
initialDelaySeconds: 0
75+
periodSeconds: 10
76+
timeoutSeconds: 3
77+
failureThreshold: 30
78+
resources:
79+
{{- toYaml .Values.resources | nindent 12 }}
80+
volumeMounts:
81+
- name: config
82+
mountPath: /config.yaml
83+
subPath: config.yaml
84+
readOnly: true
85+
- name: buildkit-cache
86+
mountPath: /home/user/.local/share/buildkit
87+
volumes:
88+
- name: config
89+
configMap:
90+
name: {{ include "ditto.fullname" . }}
91+
- name: buildkit-cache
92+
emptyDir:
93+
sizeLimit: {{ .Values.volumes.buildkitCache.sizeLimit }}
94+
{{- with .Values.nodeSelector }}
95+
nodeSelector:
96+
{{- toYaml . | nindent 8 }}
97+
{{- end }}
98+
{{- with .Values.affinity }}
99+
affinity:
100+
{{- toYaml . | nindent 8 }}
101+
{{- end }}
102+
{{- with .Values.tolerations }}
103+
tolerations:
104+
{{- toYaml . | nindent 8 }}
105+
{{- end }}

chart/templates/service.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "ditto.fullname" . }}
5+
labels:
6+
{{- include "ditto.labels" . | nindent 4 }}
7+
spec:
8+
type: {{ .Values.service.type }}
9+
ports:
10+
- port: {{ .Values.service.port }}
11+
targetPort: http
12+
protocol: TCP
13+
name: http
14+
selector:
15+
{{- include "ditto.selectorLabels" . | nindent 4 }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "ditto.serviceAccountName" . }}
6+
labels:
7+
{{- include "ditto.labels" . | nindent 4 }}
8+
{{- with .Values.serviceAccount.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
{{- end }}

chart/values.yaml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Default values for ditto.
2+
replicaCount: 1
3+
4+
image:
5+
repository: ghcr.io/devops-works/ditto
6+
pullPolicy: Always
7+
tag: "0.1.0"
8+
9+
imagePullSecrets: []
10+
nameOverride: ""
11+
fullnameOverride: ""
12+
13+
serviceAccount:
14+
# Specifies whether a service account should be created
15+
create: true
16+
# Annotations to add to the service account
17+
annotations: {}
18+
# The name of the service account to use.
19+
# If not set and create is true, a name is generated using the fullname template
20+
name: ""
21+
22+
podAnnotations: {}
23+
24+
podSecurityContext: {}
25+
# fsGroup: 2000
26+
27+
service:
28+
type: ClusterIP
29+
port: 8080
30+
31+
resources:
32+
limits:
33+
memory: 1Gi
34+
requests:
35+
cpu: 1000m
36+
memory: 1Gi
37+
38+
# Volumes configuration
39+
volumes:
40+
buildkitCache:
41+
sizeLimit: 10Gi
42+
43+
# Application configuration
44+
config:
45+
logFormat: json
46+
47+
# ditto configuration (config.yaml content)
48+
ditto:
49+
# Source repositories configuration
50+
sources: []
51+
# - name: "bigcorp"
52+
# repo_url: "https://github.com/bigcorp/containers.git"
53+
# base_path: "bigcorp"
54+
# images:
55+
# - name: nginx
56+
# - name: elasticsearch
57+
58+
# Monitoring configuration
59+
monitoring:
60+
check_interval: "1h"
61+
62+
# Build configuration
63+
build:
64+
parallel_builds: 3
65+
build_timeout: "30m"
66+
cleanup_after_build: true
67+
68+
# Observability configuration
69+
observability:
70+
port: 8080
71+
72+
# Registry configuration
73+
registry:
74+
url: ""
75+
namespace: "bigcorp"
76+
77+
nodeSelector: {}
78+
79+
tolerations: []
80+
81+
affinity: {}

config.example.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# DITTO Configuration
1+
# ditto Configuration
22
# Docker Image Tracking & Transfer Operation
33
# Copy this file to config.yaml and customize for your environment
44

0 commit comments

Comments
 (0)