Skip to content

Commit bb0f31f

Browse files
committed
add docker registry chart
1 parent 34c4980 commit bb0f31f

File tree

11 files changed

+519
-0
lines changed

11 files changed

+519
-0
lines changed

charts/docker-registry/Chart.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v2
2+
name: docker-registry
3+
description: |-
4+
Helm chart to deploy [docker-registry](https://github.com/distribution/distribution).
5+
type: application
6+
version: 0.0.1
7+
appVersion: 2.8.1
8+
home: https://github.com/slamdev/helm-charts/tree/master/charts/docker-registry
9+
icon: https://docs.docker.com/favicons/docs@2x.ico
10+
maintainers:
11+
- name: slamdev
12+
email: valentin.fedoskin@gmail.com

charts/docker-registry/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# docker-registry
2+
3+
![Version: 0.0.1](https://img.shields.io/badge/Version-0.0.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 2.8.1](https://img.shields.io/badge/AppVersion-2.8.1-informational?style=flat-square)
4+
5+
Helm chart to deploy [docker-registry](https://github.com/distribution/distribution).
6+
7+
**Homepage:** <https://github.com/slamdev/helm-charts/tree/master/charts/docker-registry>
8+
9+
## Maintainers
10+
11+
| Name | Email | Url |
12+
| ---- | ------ | --- |
13+
| slamdev | <valentin.fedoskin@gmail.com> | |
14+
15+
## Values
16+
17+
| Key | Type | Default | Description |
18+
|-----|------|---------|-------------|
19+
| additionalResources | list | `[]` | list of additional resources to create (are processed via `tpl` function) |
20+
| affinity | object | `{}` | affinity for scheduler pod assignment |
21+
| config | string | `"http:\n addr: :5000"` | docker-registry config to provision inside of the container |
22+
| containerPorts | list | `[{"containerPort":5000,"name":"http","protocol":"TCP"}]` | ports exposed by container |
23+
| env | list | `[]` | additional environment variables for the deployment |
24+
| fullnameOverride | string | `""` | full name of the chart. |
25+
| garbageCollectCronJob.deleteUntagged | bool | `true` | delete manifests that are not currently referenced via tag |
26+
| garbageCollectCronJob.dryRun | bool | `false` | do everything except remove the blobs |
27+
| garbageCollectCronJob.failedJobsHistoryLimit | int | `1` | the number of failed finished jobs to retain |
28+
| garbageCollectCronJob.resources | object | `{}` | custom resource configuration |
29+
| garbageCollectCronJob.restartPolicy | string | `"Never"` | container restart policy |
30+
| garbageCollectCronJob.schedule | string | `"@daily"` | the schedule in Cron format, see https://en.wikipedia.org/wiki/Cron |
31+
| garbageCollectCronJob.successfulJobsHistoryLimit | int | `3` | the number of successful finished jobs to retain |
32+
| image.pullPolicy | string | `"IfNotPresent"` | image pull policy |
33+
| image.repository | string | `"registry"` | image repository |
34+
| image.tag | string | `""` | image tag (chart's appVersion value will be used if not set) |
35+
| imagePullSecrets | list | `[]` | image pull secret for private images |
36+
| livenessProbe.httpGet.path | string | `"/"` | path for liveness probe |
37+
| livenessProbe.httpGet.port | string | `"http"` | port for liveness probe |
38+
| nameOverride | string | `""` | override name of the chart |
39+
| nodeSelector | object | `{}` | node for scheduler pod assignment |
40+
| podSecurityContext | object | `{}` | specifies security settings for a pod |
41+
| readinessProbe.httpGet.path | string | `"/"` | path for readiness probe |
42+
| readinessProbe.httpGet.port | string | `"http"` | port for readiness probe |
43+
| replicaCount | int | `1` | number of replicas for docker-registry deployment. |
44+
| resources | object | `{}` | custom resource configuration |
45+
| securityContext | object | `{}` | specifies security settings for a container |
46+
| service.annotations | object | `{}` | annotations to add to the service |
47+
| service.loadBalancerSourceRanges | list | `[]` | traffic through the load-balancer will be restricted to the specified client IPs |
48+
| service.ports | list | `[{"name":"http","port":80,"protocol":"TCP","targetPort":"http"}]` | service ports |
49+
| service.type | string | `"ClusterIP"` | service type |
50+
| serviceAccount.annotations | object | `{}` | annotations to add to the service account |
51+
| serviceAccount.create | bool | `false` | specifies whether a service account should be created |
52+
| serviceAccount.name | string | `nil` | the name of the service account to use; if not set and create is true, a name is generated using the fullname template |
53+
| tolerations | list | `[]` | tolerations for scheduler pod assignment |
54+
| volumeMounts | list | `[]` | additional volume mounts |
55+
| volumes | list | `[]` | additional volumes |
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
1. Get the application URL by running these commands:
2+
{{- if contains "NodePort" .Values.service.type }}
3+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "docker-registry.fullname" . }})
4+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
5+
echo http://$NODE_IP:$NODE_PORT
6+
{{- else if contains "LoadBalancer" .Values.service.type }}
7+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
8+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "docker-registry.fullname" . }}'
9+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "docker-registry.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
10+
echo http://$SERVICE_IP:{{ .Values.service.port }}
11+
{{- else if contains "ClusterIP" .Values.service.type }}
12+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "docker-registry.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
13+
echo "Visit http://127.0.0.1:8080 to use your application"
14+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
15+
{{- end }}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "docker-registry.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "docker-registry.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "docker-registry.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
33+
34+
{{/*
35+
Common labels
36+
*/}}
37+
{{- define "docker-registry.labels" -}}
38+
helm.sh/chart: {{ include "docker-registry.chart" . }}
39+
{{ include "docker-registry.selectorLabels" . }}
40+
{{- if .Chart.AppVersion }}
41+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
42+
{{- end }}
43+
app.kubernetes.io/managed-by: {{ .Release.Service }}
44+
{{- end -}}
45+
46+
{{/*
47+
Selector labels
48+
*/}}
49+
{{- define "docker-registry.selectorLabels" -}}
50+
app.kubernetes.io/name: {{ include "docker-registry.name" . }}
51+
app.kubernetes.io/instance: {{ .Release.Name }}
52+
{{- end -}}
53+
54+
{{/*
55+
Create the name of the service account to use
56+
*/}}
57+
{{- define "docker-registry.serviceAccountName" -}}
58+
{{- if .Values.serviceAccount.create -}}
59+
{{ default (include "docker-registry.fullname" .) .Values.serviceAccount.name }}
60+
{{- else -}}
61+
{{ default "default" .Values.serviceAccount.name }}
62+
{{- end -}}
63+
{{- end -}}
64+
65+
{{/*
66+
Create the tag for the docker image to use
67+
*/}}
68+
{{- define "docker-registry.tag" -}}
69+
{{- .Values.image.tag | default .Chart.AppVersion -}}
70+
{{- end -}}
71+
72+
73+
{{/*
74+
docker-registry.rawResource will create a resource template that can be
75+
merged with each item in `.Values.additionalResources`.
76+
*/}}
77+
{{- define "docker-registry.rawResource" -}}
78+
metadata:
79+
labels:
80+
{{- include "docker-registry.labels" . | nindent 4 }}
81+
{{- end }}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{{- $template := fromYaml (include "docker-registry.rawResource" .) -}}
2+
{{- range $i, $t := .Values.additionalResources }}
3+
---
4+
{{ toYaml (merge (tpl $t $ | fromYaml) $template) -}}
5+
{{- end }}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "docker-registry.fullname" . }}
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
{{- include "docker-registry.labels" . | nindent 4 }}
8+
data:
9+
config.yml: |-
10+
{{- .Values.config | nindent 4 }}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
apiVersion: batch/v1
2+
kind: CronJob
3+
metadata:
4+
name: {{ include "docker-registry.fullname" . }}
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
{{- include "docker-registry.labels" . | nindent 4 }}
8+
app.kubernetes.io/component: garbage-collect
9+
spec:
10+
concurrencyPolicy: Forbid
11+
successfulJobsHistoryLimit: {{ .Values.garbageCollectCronJob.successfulJobsHistoryLimit }}
12+
failedJobsHistoryLimit: {{ .Values.garbageCollectCronJob.failedJobsHistoryLimit }}
13+
schedule: {{ .Values.garbageCollectCronJob.schedule | quote }}
14+
jobTemplate:
15+
metadata:
16+
labels:
17+
{{- include "docker-registry.selectorLabels" . | nindent 8 }}
18+
app.kubernetes.io/component: garbage-collect
19+
spec:
20+
template:
21+
metadata:
22+
labels:
23+
{{- include "docker-registry.selectorLabels" . | nindent 12 }}
24+
app.kubernetes.io/component: garbage-collect
25+
spec:
26+
restartPolicy: {{ .Values.garbageCollectCronJob.restartPolicy }}
27+
{{- with .Values.imagePullSecrets }}
28+
imagePullSecrets:
29+
{{- toYaml . | nindent 12 }}
30+
{{- end }}
31+
serviceAccountName: {{ include "docker-registry.serviceAccountName" . }}
32+
securityContext:
33+
{{- toYaml .Values.podSecurityContext | nindent 12 }}
34+
containers:
35+
- name: {{ .Chart.Name }}
36+
args:
37+
- garbage-collect
38+
- /opt/config.yml
39+
- --delete-untagged={{ .Values.garbageCollectCronJob.deleteUntagged }}
40+
- --dry-run={{ .Values.garbageCollectCronJob.dryRun }}
41+
securityContext:
42+
{{- toYaml .Values.securityContext | nindent 16 }}
43+
image: "{{ .Values.image.repository }}:{{ include "docker-registry.tag" . }}"
44+
imagePullPolicy: {{ .Values.image.pullPolicy }}
45+
resources:
46+
{{- toYaml .Values.garbageCollectCronJob.resources | nindent 16 }}
47+
{{- with .Values.env }}
48+
env:
49+
{{- toYaml . | nindent 16 }}
50+
{{- end }}
51+
volumeMounts:
52+
- name: {{ include "docker-registry.fullname" . }}
53+
mountPath: /opt/config.yml
54+
subPath: config.yml
55+
{{- with .Values.volumeMounts }}
56+
{{- toYaml . | nindent 16 }}
57+
{{- end }}
58+
volumes:
59+
- name: {{ include "docker-registry.fullname" . }}
60+
configMap:
61+
name: {{ include "docker-registry.fullname" . }}
62+
items:
63+
- key: config.yml
64+
path: config.yml
65+
mode: 292 # 0444
66+
{{- with .Values.volumes }}
67+
{{- toYaml . | nindent 12 }}
68+
{{- end }}
69+
{{- with .Values.nodeSelector }}
70+
nodeSelector:
71+
{{- toYaml . | nindent 12 }}
72+
{{- end }}
73+
{{- with .Values.affinity }}
74+
affinity:
75+
{{- toYaml . | nindent 12 }}
76+
{{- end }}
77+
{{- with .Values.tolerations }}
78+
tolerations:
79+
{{- toYaml . | nindent 12 }}
80+
{{- end }}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "docker-registry.fullname" . }}
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
{{- include "docker-registry.labels" . | nindent 4 }}
8+
spec:
9+
replicas: {{ .Values.replicaCount }}
10+
selector:
11+
matchLabels:
12+
{{- include "docker-registry.selectorLabels" . | nindent 6 }}
13+
template:
14+
metadata:
15+
labels:
16+
{{- include "docker-registry.selectorLabels" . | nindent 8 }}
17+
annotations:
18+
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
19+
spec:
20+
{{- with .Values.imagePullSecrets }}
21+
imagePullSecrets:
22+
{{- toYaml . | nindent 8 }}
23+
{{- end }}
24+
serviceAccountName: {{ include "docker-registry.serviceAccountName" . }}
25+
securityContext:
26+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
27+
containers:
28+
- name: {{ .Chart.Name }}
29+
args:
30+
- serve
31+
- /opt/config.yml
32+
securityContext:
33+
{{- toYaml .Values.securityContext | nindent 12 }}
34+
image: "{{ .Values.image.repository }}:{{ include "docker-registry.tag" . }}"
35+
imagePullPolicy: {{ .Values.image.pullPolicy }}
36+
{{- with .Values.containerPorts }}
37+
ports:
38+
{{- toYaml . | nindent 12 }}
39+
{{- end }}
40+
livenessProbe:
41+
{{- toYaml .Values.livenessProbe | nindent 12 }}
42+
readinessProbe:
43+
{{- toYaml .Values.readinessProbe | nindent 12 }}
44+
resources:
45+
{{- toYaml .Values.resources | nindent 12 }}
46+
{{- with .Values.env }}
47+
env:
48+
{{- toYaml . | nindent 12 }}
49+
{{- end }}
50+
volumeMounts:
51+
- name: {{ include "docker-registry.fullname" . }}
52+
mountPath: /opt/config.yml
53+
subPath: config.yml
54+
{{- with .Values.volumeMounts }}
55+
{{- toYaml . | nindent 12 }}
56+
{{- end }}
57+
volumes:
58+
- name: {{ include "docker-registry.fullname" . }}
59+
configMap:
60+
name: {{ include "docker-registry.fullname" . }}
61+
items:
62+
- key: config.yml
63+
path: config.yml
64+
mode: 292 # 0444
65+
{{- with .Values.volumes }}
66+
{{- toYaml . | nindent 8 }}
67+
{{- end }}
68+
{{- with .Values.nodeSelector }}
69+
nodeSelector:
70+
{{- toYaml . | nindent 8 }}
71+
{{- end }}
72+
{{- with .Values.affinity }}
73+
affinity:
74+
{{- toYaml . | nindent 8 }}
75+
{{- end }}
76+
{{- with .Values.tolerations }}
77+
tolerations:
78+
{{- toYaml . | nindent 8 }}
79+
{{- end }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "docker-registry.fullname" . }}
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
{{- include "docker-registry.labels" . | nindent 4 }}
8+
{{- with .Values.service.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
spec:
13+
type: {{ .Values.service.type }}
14+
{{- with .Values.service.ports }}
15+
ports:
16+
{{- toYaml . | nindent 4 }}
17+
{{- end }}
18+
selector:
19+
{{- include "docker-registry.selectorLabels" . | nindent 4 }}
20+
loadBalancerSourceRanges: {{ .Values.service.loadBalancerSourceRanges }}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "docker-registry.serviceAccountName" . }}
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "docker-registry.labels" . | nindent 4 }}
9+
{{- with .Values.serviceAccount.annotations }}
10+
annotations:
11+
{{- toYaml . | nindent 4 }}
12+
{{- end }}
13+
{{- end -}}

0 commit comments

Comments
 (0)