21 Commits

Author SHA1 Message Date
Devin Canterberry
411fd99f68 🏁 v2.2.0 Release 2022-08-09 10:13:42 -07:00
Devin Canterberry
171632afef Merge pull request #68 from ddelange/garbage-collector-additive
Add option to enable garbage collector
2022-08-09 10:10:53 -07:00
Devin Canterberry
25bf25dda1 🔥 Remove default value for persistence.deleteEnabled
The default value is documented in the README as `nil`, and where referenced, a falsey value is adequate.

Co-authored-by: ddelange <14880945+ddelange@users.noreply.github.com>
2022-08-09 10:09:14 -07:00
ddelange
76ff283a25 PR Suggestions 2022-08-08 10:58:50 +02:00
ddelange
fd7fdcaa44 Make the changes additive 2022-08-05 14:04:37 +02:00
ddelange
3b4ff679f8 Revert version bump in Chart.yaml 2022-08-04 08:45:05 +02:00
Devin Canterberry
79c14893af Merge pull request #61 from joneteus/patch-1
Fix reference in README
2022-06-27 11:25:02 -07:00
Joni Ollikainen
257d223141 Fix reference in README
f158323875/templates/secret.yaml (L17)

According to `secret.yaml` `haSharedSecret` should be inside `secrets` object
2022-06-27 13:18:19 +03:00
ddelange
29a0863ee2 Merge branch 'main' of https://github.com/twuni/docker-registry.helm into garbage-collector
Includes moving additions to demployment.yaml to _helpers.tpl ref https://github.com/twuni/docker-registry.helm/compare/v1.13.0...v2.1.0

* 'main' of https://github.com/twuni/docker-registry.helm: (22 commits)
  Updated README with initContainers value
  Add initContainer support
  🏁 v2.1.0 Release
  Added support for autoscaling using hpa
  🏁 v2.0.1 Release
  🌐 make protocol selection work with istio
  fix(templates): Add checksum on secret.yaml file
  🏁 v2.0.0 Release
  Fix #19 (new kubernetes API version)
  🏁 v1.16.0 Release
  Conditionally create service account and add to deployment
  🏁 v1.15.0 Release
  Support deployment to a namespace
  Updated typo to enable(d)
  🏁 v1.14.0 Release
  Enable metrics via Prometheus Operator
  Support additional env variables
  🏁 v1.13.2 Release
  Add support for S3 bucket to prefix all data
  🏁 v1.13.1 Release
  ...
2022-06-24 09:31:37 +02:00
Devin Canterberry
f158323875 Merge pull request #40 from g-linville/initContainer
Add initContainer support
2022-04-14 17:04:43 -07:00
Grant Linville
39788072e6 Updated README with initContainers value 2022-04-14 10:28:01 -04:00
Grant Linville
0b6729f21d Add initContainer support 2022-04-14 10:27:29 -04:00
Devin Canterberry
b5ad18ea83 🏁 v2.1.0 Release 2022-02-02 19:45:14 -08:00
Devin Canterberry
297f860dd6 Merge pull request #38 from SimonRupar/hpa
Added support for pod autoscaling using Horizontal Pod Autoscaler
2022-02-02 14:20:12 -08:00
SimonRupar
c91c8139c5 Added support for autoscaling using hpa 2022-02-01 20:45:03 +01:00
Devin Canterberry
4b5531d4ef Merge pull request #49 from Eriwyr/patch-1
fix(templates): Add checksum on secret.yaml file
2022-01-30 19:22:42 -08:00
CHABRIER Valentin
98bdab8c45 fix(templates): Add checksum on secret.yaml file
Too bad it's lacking a check in addition to the config that the secret file has not changed too in the deployment :)
2022-01-07 16:53:46 +01:00
Vladimir Kuznichenkov
a95a3480c6 Garbage collector job to keep registry tiny
We don't have unlimited storage, and we would like to run built-in garbage collector to keep storage usage low.
2021-09-18 12:40:25 +03:00
Vladimir Kuznichenkov
c855e53b9e Add empty objects to default envs to prevent validation errors
In case of S3 we can use IAM role to access bucket, in that case we do not need to define anything in secrets. At the same time due to missed parent level field chart will fail with an error.
2021-09-18 12:36:22 +03:00
Vladimir Kuznichenkov
944cf7eb62 Use a single style of indents
`nindent` function insert fist newline before actual content and allow you use it on any level of yaml without breaking visual structure.
2021-09-18 12:34:57 +03:00
Vladimir Kuznichenkov
2726d10083 Move common sections to defined template to prevent code duplication
Cronjob should have the same env variables and volumes to proceed correctly
2021-09-18 12:33:43 +03:00
7 changed files with 338 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
apiVersion: v1
description: A Helm chart for Docker Registry
name: docker-registry
version: 2.0.1
version: 2.2.0
appVersion: 2.7.1
home: https://hub.docker.com/_/registry/
icon: https://helm.twun.io/docker-registry.png

View File

@@ -61,6 +61,12 @@ their default values.
| `podDisruptionBudget` | Pod disruption budget | `{}` |
| `resources.limits.cpu` | Container requested CPU | `nil` |
| `resources.limits.memory` | Container requested memory | `nil` |
| `autoscaling.enabled` | Enable autoscaling using HorizontalPodAutoscaler | `false` |
| `autoscaling.minReplicas` | Minimal number of replicas | `1` |
| `autoscaling.maxReplicas` | Maximal number of replicas | `2` |
| `autoscaling.targetCPUUtilizationPercentage` | Target average utilization of CPU on Pods | `60` |
| `autoscaling.targetMemoryUtilizationPercentage` | (Kubernetes ≥1.23) Target average utilization of Memory on Pods | `60` |
| `autoscaling.behavior` | (Kubernetes ≥1.23) Configurable scaling behavior | `{}` |
| `priorityClassName ` | priorityClassName | `""` |
| `storage` | Storage system to use | `filesystem` |
| `tlsSecretName` | Name of secret for TLS certs | `nil` |
@@ -70,7 +76,7 @@ their default values.
| `secrets.s3.secretRef` | The ref for an external secret containing the accessKey and secretKey keys | `""` |
| `secrets.swift.username` | Username for Swift configuration | `nil` |
| `secrets.swift.password` | Password for Swift configuration | `nil` |
| `haSharedSecret` | Shared secret for Registry | `nil` |
| `secrets.haSharedSecret` | Shared secret for Registry | `nil` |
| `configData` | Configuration hash for docker | `nil` |
| `s3.region` | S3 region | `nil` |
| `s3.regionEndpoint` | S3 region endpoint | `nil` |
@@ -108,6 +114,10 @@ their default values.
| `extraVolumeMounts` | Additional volumeMounts to the registry container | `[]` |
| `extraVolumes` | Additional volumes to the pod | `[]` |
| `extraEnvVars` | Additional environment variables to the pod | `[]` |
| `initContainers` | Init containers to be created in the pod | `[]` |
| `garbageCollect.enabled` | If true, will deploy garbage-collector cronjob | `false` |
| `garbageCollect.deleteUntagged` | If true, garbage-collector will delete manifests that are not currently referenced via tag | `true` | |
| `garbageCollect.schedule` | CronTab schedule, please use standard crontab format | `0 1 * * *` | |
Specify each parameter using the `--set key=value[,key=value]` argument to
`helm install`.

222
templates/cronjob.yaml Normal file
View File

@@ -0,0 +1,222 @@
{{- if .Values.garbageCollect.enabled }}
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ template "docker-registry.fullname" . }}-garbage-collector
namespace: {{ .Values.namespace | default .Release.Namespace }}
labels:
app: {{ template "docker-registry.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
schedule: {{ .Values.garbageCollect.schedule | quote }}
jobTemplate:
metadata:
labels:
app: {{ template "docker-registry.name" . }}
release: {{ .Release.Name }}
{{- with .Values.podLabels }}
{{ toYaml . | nindent 8 }}
{{- end }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- if $.Values.podAnnotations }}
{{ toYaml $.Values.podAnnotations | indent 8 }}
{{- end }}
spec:
template:
spec:
{{- if or (eq .Values.serviceAccount.create true) (ne .Values.serviceAccount.name "") }}
serviceAccountName: {{ .Values.serviceAccount.name | default (include "docker-registry.fullname" .) }}
{{- end }}
{{- if .Values.imagePullSecrets }}
imagePullSecrets: {{ toYaml .Values.imagePullSecrets | nindent 12 }}
{{- end }}
{{- if .Values.priorityClassName }}
priorityClassName: "{{ .Values.priorityClassName }}"
{{- end }}
{{- if .Values.securityContext.enabled }}
securityContext:
fsGroup: {{ .Values.securityContext.fsGroup }}
runAsUser: {{ .Values.securityContext.runAsUser }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- /bin/registry
- garbage-collect
- --delete-untagged={{ .Values.garbageCollect.deleteUntagged }}
- /etc/docker/registry/config.yml
env:
{{- if .Values.secrets.htpasswd }}
- name: REGISTRY_AUTH
value: "htpasswd"
- name: REGISTRY_AUTH_HTPASSWD_REALM
value: "Registry Realm"
- name: REGISTRY_AUTH_HTPASSWD_PATH
value: "/auth/htpasswd"
{{- end }}
- name: REGISTRY_HTTP_SECRET
valueFrom:
secretKeyRef:
name: {{ template "docker-registry.fullname" . }}-secret
key: haSharedSecret
{{- if .Values.tlsSecretName }}
- name: REGISTRY_HTTP_TLS_CERTIFICATE
value: /etc/ssl/docker/tls.crt
- name: REGISTRY_HTTP_TLS_KEY
value: /etc/ssl/docker/tls.key
{{- end }}
{{- if eq .Values.storage "filesystem" }}
- name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY
value: "/var/lib/registry"
{{- else if eq .Values.storage "azure" }}
- name: REGISTRY_STORAGE_AZURE_ACCOUNTNAME
valueFrom:
secretKeyRef:
name: {{ template "docker-registry.fullname" . }}-secret
key: azureAccountName
- name: REGISTRY_STORAGE_AZURE_ACCOUNTKEY
valueFrom:
secretKeyRef:
name: {{ template "docker-registry.fullname" . }}-secret
key: azureAccountKey
- name: REGISTRY_STORAGE_AZURE_CONTAINER
valueFrom:
secretKeyRef:
name: {{ template "docker-registry.fullname" . }}-secret
key: azureContainer
{{- else if eq .Values.storage "s3" }}
{{- if or (and .Values.secrets.s3.secretKey .Values.secrets.s3.accessKey) .Values.secrets.s3.secretRef }}
- name: REGISTRY_STORAGE_S3_ACCESSKEY
valueFrom:
secretKeyRef:
name: {{ if .Values.secrets.s3.secretRef }}{{ .Values.secrets.s3.secretRef }}{{ else }}{{ template "docker-registry.fullname" . }}-secret{{ end }}
key: s3AccessKey
- name: REGISTRY_STORAGE_S3_SECRETKEY
valueFrom:
secretKeyRef:
name: {{ if .Values.secrets.s3.secretRef }}{{ .Values.secrets.s3.secretRef }}{{ else }}{{ template "docker-registry.fullname" . }}-secret{{ end }}
key: s3SecretKey
{{- end }}
- name: REGISTRY_STORAGE_S3_REGION
value: {{ required ".Values.s3.region is required" .Values.s3.region }}
{{- if .Values.s3.regionEndpoint }}
- name: REGISTRY_STORAGE_S3_REGIONENDPOINT
value: {{ .Values.s3.regionEndpoint }}
{{- end }}
- name: REGISTRY_STORAGE_S3_BUCKET
value: {{ required ".Values.s3.bucket is required" .Values.s3.bucket }}
{{- if .Values.s3.rootdirectory }}
- name: REGISTRY_STORAGE_S3_ROOTDIRECTORY
value: {{ .Values.s3.rootdirectory | quote }}
{{- end }}
{{- if .Values.s3.encrypt }}
- name: REGISTRY_STORAGE_S3_ENCRYPT
value: {{ .Values.s3.encrypt | quote }}
{{- end }}
{{- if .Values.s3.secure }}
- name: REGISTRY_STORAGE_S3_SECURE
value: {{ .Values.s3.secure | quote }}
{{- end }}
{{- else if eq .Values.storage "swift" }}
- name: REGISTRY_STORAGE_SWIFT_AUTHURL
value: {{ required ".Values.swift.authurl is required" .Values.swift.authurl }}
- name: REGISTRY_STORAGE_SWIFT_USERNAME
valueFrom:
secretKeyRef:
name: {{ template "docker-registry.fullname" . }}-secret
key: swiftUsername
- name: REGISTRY_STORAGE_SWIFT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "docker-registry.fullname" . }}-secret
key: swiftPassword
- name: REGISTRY_STORAGE_SWIFT_CONTAINER
value: {{ required ".Values.swift.container is required" .Values.swift.container }}
{{- end }}
{{- if .Values.proxy.enabled }}
- name: REGISTRY_PROXY_REMOTEURL
value: {{ required ".Values.proxy.remoteurl is required" .Values.proxy.remoteurl }}
- name: REGISTRY_PROXY_USERNAME
valueFrom:
secretKeyRef:
name: {{ if .Values.proxy.secretRef }}{{ .Values.proxy.secretRef }}{{ else }}{{ template "docker-registry.fullname" . }}-secret{{ end }}
key: proxyUsername
- name: REGISTRY_PROXY_PASSWORD
valueFrom:
secretKeyRef:
name: {{ if .Values.proxy.secretRef }}{{ .Values.proxy.secretRef }}{{ else }}{{ template "docker-registry.fullname" . }}-secret{{ end }}
key: proxyPassword
{{- end }}
{{- if .Values.persistence.deleteEnabled }}
- name: REGISTRY_STORAGE_DELETE_ENABLED
value: "true"
{{- end }}
{{- with .Values.extraEnvVars }}
{{- toYaml . | nindent 14 }}
{{- end }}
volumeMounts:
{{- if .Values.secrets.htpasswd }}
- name: auth
mountPath: /auth
readOnly: true
{{- end }}
{{- if eq .Values.storage "filesystem" }}
- name: data
mountPath: /var/lib/registry/
{{- end }}
- name: "{{ template "docker-registry.fullname" . }}-config"
mountPath: "/etc/docker/registry"
{{- if .Values.tlsSecretName }}
- mountPath: /etc/ssl/docker
name: tls-cert
readOnly: true
{{- end }}
{{- with .Values.extraVolumeMounts }}
{{- toYaml . | nindent 16 }}
{{- end }}
restartPolicy: OnFailure
{{- if .Values.nodeSelector }}
nodeSelector: {{ toYaml .Values.nodeSelector | nindent 12 }}
{{- end }}
{{- if .Values.affinity }}
affinity: {{ toYaml .Values.affinity | nindent 12 }}
{{- end }}
{{- if .Values.tolerations }}
tolerations: {{ toYaml .Values.tolerations | nindent 12 }}
{{- end }}
volumes:
{{- if .Values.secrets.htpasswd }}
- name: auth
secret:
secretName: {{ template "docker-registry.fullname" . }}-secret
items:
- key: htpasswd
path: htpasswd
{{- end }}
{{- if eq .Values.storage "filesystem" }}
- name: data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "docker-registry.fullname" . }}{{- end }}
{{- else }}
emptyDir: {}
{{- end -}}
{{- end }}
- name: {{ template "docker-registry.fullname" . }}-config
configMap:
name: {{ template "docker-registry.fullname" . }}-config
{{- if .Values.tlsSecretName }}
- name: tls-cert
secret:
secretName: {{ .Values.tlsSecretName }}
{{- end }}
{{- with .Values.extraVolumes }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}

View File

@@ -29,6 +29,7 @@ spec:
{{- end }}
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- if $.Values.podAnnotations }}
{{ toYaml $.Values.podAnnotations | indent 8 }}
{{- end }}
@@ -47,6 +48,10 @@ spec:
securityContext:
fsGroup: {{ .Values.securityContext.fsGroup }}
runAsUser: {{ .Values.securityContext.runAsUser }}
{{- end }}
{{- with .Values.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}

42
templates/hpa.yaml Normal file
View File

@@ -0,0 +1,42 @@
{{- if .Values.autoscaling.enabled }}
{{- $apiVersions := .Capabilities.APIVersions -}}
{{- if $apiVersions.Has "autoscaling/v2" }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "docker-registry.fullname" . }}
labels:
app: {{ template "docker-registry.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "docker-registry.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- with .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ . }}
{{- end }}
{{- with .Values.autoscaling.behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}

22
templates/hpaV1.yaml Normal file
View File

@@ -0,0 +1,22 @@
{{- if .Values.autoscaling.enabled }}
{{- $apiVersions := .Capabilities.APIVersions -}}
{{- if not ($apiVersions.Has "autoscaling/v2") }}
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "docker-registry.fullname" . }}
labels:
app: {{ template "docker-registry.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "docker-registry.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
targetCPUUtilizationPercentage: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- end }}

View File

@@ -163,6 +163,30 @@ podDisruptionBudget: {}
# maxUnavailable: 1
# minAvailable: 2
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 2
targetCPUUtilizationPercentage: 60
targetMemoryUtilizationPercentage: 60 # available only on Kubernetes ≥1.23 [required "autoscaling/v2"]
behavior: {} # available only on Kubernetes ≥1.23 [required "autoscaling/v2"]
# scaleDown:
# stabilizationWindowSeconds: 300
# policies:
# - type: Percent
# value: 100
# periodSeconds: 15
# scaleUp:
# stabilizationWindowSeconds: 0
# policies:
# - type: Percent
# value: 100
# periodSeconds: 15
# - type: Pods
# value: 4
# periodSeconds: 15
# selectPolicy: Max
nodeSelector: {}
affinity: {}
@@ -189,3 +213,14 @@ extraEnvVars: []
## Additional ENV variables to set
# - name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY
# value: "/var/lib/example"
initContainers: []
## Init containers to add to the Deployment
# - name: init
# image: busybox
# command: []
garbageCollect:
enabled: false
deleteUntagged: true
schedule: "0 1 * * *"