Skip to content

Commit

Permalink
Add charts to dockhand-lru-registry repo
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew DeVenny <[email protected]>
  • Loading branch information
matthewdevenny committed May 7, 2024
1 parent b07746f commit 0530e4b
Show file tree
Hide file tree
Showing 10 changed files with 459 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/helm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# based on: https://github.com/helm/charts-repo-actions-demo/blob/main/.github/workflows/release.yaml
name: helm

on:
push:
paths:
- 'charts/**'
branches:
- master

jobs:
helm:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Set up Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78
with:
version: v3.11.2

- name: Run chart-releaser
uses: helm/chart-releaser-action@be16258da8010256c6e82849661221415f031968
with:
charts_dir: charts
config: charts/cr.yaml
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
4 changes: 4 additions & 0 deletions charts/cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# https://github.com/helm/chart-releaser#config-file
pages-branch: gh-pages
pages-index-path: charts/index.yaml
skip-existing: true
25 changes: 25 additions & 0 deletions charts/dockhand-lru-registry/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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/
# Shell scripts
/*.sh
5 changes: 5 additions & 0 deletions charts/dockhand-lru-registry/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2
name: dockhand-lru-registry
description: LRU Registry
type: application
version: 0.2.1
62 changes: 62 additions & 0 deletions charts/dockhand-lru-registry/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "dockhand-lru-registry.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "dockhand-lru-registry.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 }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "dockhand-lru-registry.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

{{/*
Selector labels
*/}}
{{- define "dockhand-lru-registry.selectorLabels" -}}
app.kubernetes.io/name: {{ include "dockhand-lru-registry.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "dockhand-lru-registry.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "dockhand-lru-registry.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
10 changes: 10 additions & 0 deletions charts/dockhand-lru-registry/templates/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "dockhand-lru-registry.name" . }}-conf
labels:
{{- include "dockhand-lru-registry.labels" . | nindent 4 }}
data:
registry-config.yaml: |
{{ (tpl (.Values.registry.conf) .) | nindent 4 }}
140 changes: 140 additions & 0 deletions charts/dockhand-lru-registry/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "dockhand-lru-registry.name" . }}
labels:
{{- include "dockhand-lru-registry.labels" . | nindent 4 }}
spec:
serviceName: {{ include "dockhand-lru-registry.name" . }}
replicas: 1
selector:
matchLabels:
{{- include "dockhand-lru-registry.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "dockhand-lru-registry.selectorLabels" . | nindent 8 }}
annotations:
checksum/config-maps: {{ (tpl (.Values.registry.conf) .) | sha256sum }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
initContainers:
- name: init-registry-proxy
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.registry.image.repository }}:{{ .Values.registry.image.tag }}"
imagePullPolicy: {{ .Values.registry.image.pullPolicy }}
command:
- cp
- /bin/registry
- /registry/bin/registry
args:
volumeMounts:
- name: registry-bin
mountPath: /registry/bin
containers:
- name: cache-lru-proxy
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.proxy.image.repository }}:{{ .Values.proxy.image.tag }}"
imagePullPolicy: {{ .Values.proxy.image.pullPolicy }}
args:
- start
- --use-forwarded-headers
- --target-disk-usage
- {{ .Values.proxy.cleanSettings.targetDiskUsage | quote}}
- --clean-tags-percentage
- {{ .Values.proxy.cleanSettings.cleanTagPercentage | quote}}
- --registry-dir
- /var/lib/registry
- --timezone
- {{ .Values.proxy.cleanSettings.timezone | quote }}
- --cleanup-cron
- {{ .Values.proxy.cleanSettings.cron | quote }}
- --registry-host
- 127.0.0.1:5000
- --port
- {{ .Values.proxy.port | quote }}
{{- if .Values.proxy.cleanSettings.useSeparateDiskCalculation }}
- --separate-disk
{{- end }}
{{- if .Values.proxy.debug }}
- --debug
{{- end }}
ports:
- name: cache
containerPort: {{ .Values.proxy.port }}
protocol: TCP
volumeMounts:
- name: registry-bin
mountPath: /registry/bin
- name: conf
mountPath: /etc/docker/registry/config.yml
subPath: config.yml
- name: registry-cache
mountPath: /var/lib/registry
- name: registry
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.registry.image.repository }}:{{ .Values.registry.image.tag }}"
imagePullPolicy: {{ .Values.registry.image.pullPolicy }}
volumeMounts:
- name: conf
mountPath: /etc/docker/registry/config.yml
subPath: config.yml
- name: registry-cache
mountPath: /var/lib/registry
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: registry-bin
emptyDir: {}
- name: conf
configMap:
name: {{ include "dockhand-lru-registry.name" . }}-conf
items:
- key: registry-config.yaml
path: config.yml
{{- if eq .Values.registry.cache.persistence.type "emptyDir" }}
- name: registry-cache
{{- if .Values.registry.cache.persistence.emptyDir }}
emptyDir:
{{- toYaml .Values.registry.cache.persistence.emptyDir | nindent 12 }}
{{- else }}
emptyDir: {}
{{- end }}
{{- end }}
{{- if eq .Values.registry.cache.persistence.type "hostPath" }}
- name: registry-cache
hostPath:
{{- toYaml .Values.registry.cache.persistence.hostPath | nindent 12 }}
{{- end }}
{{- if eq .Values.registry.cache.persistence.type "pvc" }}
volumeClaimTemplates:
- metadata:
name: registry-cache
spec:
{{- if .Values.registry.cache.persistence.pvc.storageClass }}
storageClassName: {{ .Values.registry.cache.persistence.pvc.storageClass }}
{{- end }}
accessModes:
- {{ .Values.registry.cache.persistence.pvc.accessMode }}
resources:
requests:
storage: {{ .Values.registry.cache.persistence.pvc.size | quote }}
{{- end }}
61 changes: 61 additions & 0 deletions charts/dockhand-lru-registry/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{- if .Values.ingress.enabled -}}
{{- $name := include "dockhand-lru-registry.name" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $name }}
labels:
{{- include "dockhand-lru-registry.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $name }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $name }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
21 changes: 21 additions & 0 deletions charts/dockhand-lru-registry/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "dockhand-lru-registry.name" . }}
labels:
{{- include "dockhand-lru-registry.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
{{- if .Values.service.clusterIP }}
clusterIP: {{ .Values.service.clusterIP }}
{{- end }}
ports:
- port: {{ .Values.service.port }}
targetPort: cache
{{- if eq .Values.service.type "NodePort" }}
nodePort: {{ .Values.service.nodePort }}
{{- end }}
protocol: TCP
name: cache
selector:
{{- include "dockhand-lru-registry.selectorLabels" . | nindent 4 }}
Loading

0 comments on commit 0530e4b

Please sign in to comment.