Skip to content

Commit

Permalink
Merge pull request #33 from jouve/distribution
Browse files Browse the repository at this point in the history
[distribution] new chart
  • Loading branch information
jouve authored Dec 7, 2023
2 parents 7da9e49 + 5aae8ca commit eafa8b2
Show file tree
Hide file tree
Showing 13 changed files with 852 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/distribution/.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/
6 changes: 6 additions & 0 deletions charts/distribution/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: common
repository: oci://registry-1.docker.io/bitnamicharts
version: 2.13.3
digest: sha256:6fbdc8a525f6f9f98ec4ac5d11b049993f2e5800fd2f44b3abb3b00b74936ee0
generated: "2023-12-07T13:25:57.872831+01:00"
18 changes: 18 additions & 0 deletions charts/distribution/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v2
name: distribution
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: 2.8.3
dependencies:
- name: common
repository: oci://registry-1.docker.io/bitnamicharts
version: 2.x.x
sources:
- https://github.com/jouve/charts
- https://github.com/distribution/distribution/
maintainers:
- name: jouve
url: https://github.com/jouve
annotations:
artifacthub.io/license: GPL-3.0-or-later
100 changes: 100 additions & 0 deletions charts/distribution/README.md

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions charts/distribution/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{/*
Create the name of the service account to use
usage: {{ template "common.names.serviceAccountName" (dict "serviceAccountRoot" .Values.serviceAccount "context" .) }}
*/}}
{{- define "common.names.serviceAccountName" -}}
{{- if .serviceAccountRoot.name -}}
{{ tpl .serviceAccountRoot.name .context }}
{{- else if .serviceAccountRoot.create -}}
{{ template "common.names.fullname" .context }}
{{- else -}}
default
{{- end -}}
{{- end -}}
25 changes: 25 additions & 0 deletions charts/distribution/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "common.names.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" . ) | nindent 4 }}
{{- with .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 4 }}
{{- end }}
data:
config.yml: |
{{- $config := include "common.tplvalues.render" (dict "value" .Values.configYml "context" .) | fromYaml }}
{{- if hasKey $config "storage" | not | and .Values.persistence.enabled }}
{{- $config := merge
$config
(dict
"storage" (dict
"filesystem" (dict
"rootdirectory" "/var/lib/registry"
)
)
)
-}}
{{- end }}
{{- $config | toYaml | nindent 4 }}
143 changes: 143 additions & 0 deletions charts/distribution/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
apiVersion: {{ template "common.capabilities.deployment.apiVersion" . }}
kind: Deployment
metadata:
name: {{ template "common.names.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" . ) | nindent 4 }}
{{- with .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 4 }}
{{- end }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
{{- with .Values.updateStrategy }}
strategy: {{- toYaml . | nindent 4 }}
{{- end }}
{{- $podLabels := include "common.tplvalues.merge" (dict "values" (list .Values.podLabels .Values.commonLabels) "context" .) }}
selector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
template:
metadata:
labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }}
annotations:
checksum/config: {{ include "common.utils.checksumTemplate" (dict "path" "/configmap.yaml" "context" .) }}
{{- with .Values.podAnnotations }}
{{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "common.names.serviceAccountName" (dict "serviceAccountRoot" .Values.serviceAccount "context" .) }}
{{- include "common.images.renderPullSecrets" (dict "images" (list .Values.image) "context" .) | nindent 6 -}}
{{- with .Values.hostAliases }}
hostAliases: {{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity: {{- include "common.tplvalues.render" ( dict "value" . "context" $) | nindent 8 }}
{{- else }}
affinity:
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAffinityPreset "customLabels" $podLabels "context" $) | nindent 10 }}
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAntiAffinityPreset "customLabels" $podLabels "context" $) | nindent 10 }}
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.nodeAffinityPreset.type "key" .Values.nodeAffinityPreset.key "values" .Values.nodeAffinityPreset.values) | nindent 10 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector: {{- include "common.tplvalues.render" ( dict "value" . "context" $) | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations: {{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 8 }}
{{- end }}
{{- with .Values.priorityClassName }}
priorityClassName: {{ . | quote }}
{{- end }}
{{- with .Values.schedulerName }}
schedulerName: {{ . | quote }}
{{- end }}
{{- with .Values.topologySpreadConstraints }}
topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.podSecurityContext.enabled }}
securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }}
{{- end }}
{{- with .Values.terminationGracePeriodSeconds }}
terminationGracePeriodSeconds: {{ . }}
{{- end }}
initContainers:
{{- with .Values.initContainers }}
{{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 8 }}
{{- end }}
containers:
- name: main
image: {{ template "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
{{- if .Values.diagnosticMode.enabled }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
{{- else if .Values.command }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.command "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.diagnosticMode.enabled }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
{{- else if .Values.args }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.args "context" $) | nindent 12 }}
{{- end }}
env:
{{- with .Values.extraEnvVars }}
{{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 12 }}
{{- end }}
envFrom:
{{- with .Values.extraEnvVarsCM }}
- configMapRef:
name: {{ template "common.tplvalues.render" (dict "value" . "context" $) }}
{{- end }}
{{- with .Values.extraEnvVarsSecret }}
- secretRef:
name: {{ template "common.tplvalues.render" (dict "value" . "context" $) }}
{{- end }}
{{- with .Values.resources }}
resources: {{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: 5000
{{- if not .Values.diagnosticMode.enabled }}
{{- with .Values.customLivenessProbe }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 12 }}
{{- else }}
#livenessProbe: {}
{{- end }}
{{- with .Values.customReadinessProbe }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 12 }}
{{- else }}
#readinessProbe: {}
{{- end }}
{{- with .Values.customStartupProbe }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 12 }}
{{- else }}
#startupProbe: {}
{{- end }}
{{- end }}
{{- with .Values.lifecycleHooks }}
lifecycle: {{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 12 }}
{{- end }}
volumeMounts:
- name: etc
mountPath: /etc/docker/registry
- name: registry
mountPath: {{ .Values.persistence.mountPath }}
{{- with .Values.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 12 }}
{{- end }}
{{- with .Values.sidecars }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $) | nindent 8 }}
{{- end }}
volumes:
- name: etc
configMap:
name: {{ template "common.names.fullname" . }}
- name: registry
persistentVolumeClaim:
claimName: {{ with .Values.persistence.existingClaim }}{{ . }}{{ else }}{{ template "common.names.fullname" . }}{{ end }}
{{- with .Values.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 8 }}
{{- end }}
53 changes: 53 additions & 0 deletions charts/distribution/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{{- if .Values.ingress.enabled }}
apiVersion: {{ template "common.capabilities.ingress.apiVersion" . }}
kind: Ingress
metadata:
name: {{ template "common.names.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" . ) | nindent 4 }}
{{- with list .Values.ingress.annotations .Values.commonAnnotations | dict "context" . "values" | include "common.tplvalues.merge" | fromYaml }}
annotations: {{- . | toYaml | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.ingressClassName (eq "true" (include "common.ingress.supportsIngressClassname" .)) }}
ingressClassName: {{ .Values.ingress.ingressClassName | quote }}
{{- end }}
rules:
{{- if .Values.ingress.hostname }}
- host: {{ .Values.ingress.hostname }}
http:
paths:
- path: {{ .Values.ingress.path }}
{{- if eq "true" (include "common.ingress.supportsPathType" .) }}
pathType: {{ .Values.ingress.pathType }}
{{- end }}
backend: {{- include "common.ingress.backend" (dict "serviceName" (include "common.names.fullname" .) "servicePort" "http" "context" $) | nindent 14 }}
{{- with .Values.ingress.extraPaths }}
{{- include "common.tplvalues.render" (dict . "context" $) | nindent 10 }}
{{- end }}
{{- end }}
{{- range .Values.ingress.extraHosts }}
- host: {{ .name | quote }}
http:
paths:
- path: {{ default "/" .path }}
{{- if eq "true" (include "common.ingress.supportsPathType" $) }}
pathType: {{ default "ImplementationSpecific" .pathType }}
{{- end }}
backend: {{- include "common.ingress.backend" (dict "serviceName" (include "common.names.fullname" $) "servicePort" "http" "context" $) | nindent 14 }}
{{- end }}
{{- with .Values.ingress.extraRules }}
{{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 4 }}
{{- end }}
{{- if or (and .Values.ingress.tls (or (include "common.ingress.certManagerRequest" ( dict "annotations" .Values.ingress.annotations )) .Values.ingress.selfSigned)) .Values.ingress.extraTls }}
tls:
{{- if and .Values.ingress.tls (or (include "common.ingress.certManagerRequest" ( dict "annotations" .Values.ingress.annotations )) .Values.ingress.selfSigned) }}
- hosts:
- {{ .Values.ingress.hostname | quote }}
secretName: {{ template "common.names.fullname" . }}-tls
{{- end }}
{{- with .Values.ingress.extraTls }}
{{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}
23 changes: 23 additions & 0 deletions charts/distribution/templates/persistentvolumeclaim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ template "common.names.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" . ) | nindent 4 }}
{{- with include "common.tplvalues.merge" (dict "values" (list .Values.persistence.annotations .Values.commonAnnotations) "context" .) | fromYaml }}
annotations: {{- . | toYaml | nindent 4 }}
{{- end }}
spec:
accessModes: {{- include "common.tplvalues.render" (dict "value" .Values.persistence.accessModes "context" $) | nindent 4 }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- with .Values.persistence.selector }}
selector: {{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 4 }}
{{- end }}
{{- with .Values.persistence.dataSource }}
dataSource: {{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 4 }}
{{- end }}
{{- include "common.storage.class" (dict "persistence" .Values.persistence "global" .Values.global) | nindent 2 }}
{{- end -}}
49 changes: 49 additions & 0 deletions charts/distribution/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "common.names.fullname" . }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" . ) | nindent 4 }}
{{- with include "common.tplvalues.merge" (dict "values" (list .Values.service.annotations .Values.commonAnnotations) "context" .) | fromYaml }}
annotations: {{- . | toYaml | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- if and .Values.service.clusterIP (eq .Values.service.type "ClusterIP") }}
clusterIP: {{ .Values.service.clusterIP }}
{{- end }}
{{- with .Values.service.sessionAffinity }}
sessionAffinity: {{ . }}
{{- end }}
{{- with .Values.service.sessionAffinityConfig }}
sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 4 }}
{{- end }}
{{- if or (eq .Values.service.type "LoadBalancer") (eq .Values.service.type "NodePort") }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy | quote }}
{{- end }}
{{- if and (eq .Values.service.type "LoadBalancer") (not (empty .Values.service.loadBalancerSourceRanges)) }}
loadBalancerSourceRanges: {{ .Values.service.loadBalancerSourceRanges }}
{{- end }}
{{- if and (eq .Values.service.type "LoadBalancer") (not (empty .Values.service.loadBalancerIP)) }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
ports:
- name: http
port: 80
targetPort: http
protocol: TCP
{{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) .Values.service.nodePorts.http }}
nodePort: {{ .Values.service.nodePorts.http }}
{{- end }}
- name: metrics
port: 5001
targetPort: metrics
protocol: TCP
{{- if and (or (eq .Values.service.type "NodePort") (eq .Values.service.type "LoadBalancer")) .Values.service.nodePorts.http }}
nodePort: {{ .Values.service.nodePorts.http }}
{{- end }}
{{- with .Values.service.extraPorts }}
{{- include "common.tplvalues.render" (dict "value" . "context" $) | nindent 4 }}
{{- end }}
{{- $podLabels := include "common.tplvalues.merge" (dict "values" (list .Values.podLabels .Values.commonLabels) "context" .) }}
selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }}
12 changes: 12 additions & 0 deletions charts/distribution/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "common.names.serviceAccountName" (dict "serviceAccountRoot" .Values.serviceAccount "context" .) }}
namespace: {{ include "common.names.namespace" . | quote }}
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- with include "common.tplvalues.merge" (dict "values" (list .Values.serviceAccount.annotations .Values.commonAnnotations) "context" .) | fromYaml }}
annotations: {{- . | toYaml | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
{{- end }}
Loading

0 comments on commit eafa8b2

Please sign in to comment.