Skip to content

Commit

Permalink
update registry chart
Browse files Browse the repository at this point in the history
  • Loading branch information
mxyng committed Oct 15, 2021
1 parent 8195f6d commit c88c9f2
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 31 deletions.
62 changes: 62 additions & 0 deletions helm/charts/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 "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 "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 "registry.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "registry.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "registry.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
5 changes: 3 additions & 2 deletions helm/charts/registry/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: infra-registry
namespace: {{ .Release.Namespace }}
name: {{ include "registry.fullname" . }}
labels:
{{- include "registry.labels" . | nindent 4 }}
data:
{{- if kindIs "map" .Values.config }}
infra.yaml: |
Expand Down
18 changes: 11 additions & 7 deletions helm/charts/registry/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: infra-registry
namespace: {{ .Release.Namespace }}
name: {{ include "registry.fullname" . }}
labels:
{{- include "registry.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
app: infra-registry
{{- include "registry.selectorLabels" . | nindent 6 }}
replicas: 1
template:
metadata:
labels:
app: infra-registry
{{- include "registry.selectorLabels" . | nindent 8 }}
{{- with .Values.pod.annotations }}
annotations:
rollme: {{ randAlphaNum 5 | quote }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
automountServiceAccountToken: true
serviceAccountName: infra-registry
serviceAccountName: {{ include "registry.serviceAccountName" . }}
dnsPolicy: ClusterFirst
{{- with .Values.image.pullSecrets }}
imagePullSecrets:
{{- range . }}
{{- range . }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- end }}
containers:
- name: registry
Expand Down
5 changes: 2 additions & 3 deletions helm/charts/registry/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
apiVersion: {{ $apiVersion }}
kind: Ingress
metadata:
name: infra-registry
namespace: {{ .Release.Namespace }}
name: {{ include "registry.fullname" . }}
labels:
app: infra-registry
{{- include "registry.labels" . | nindent 4 }}
{{- with .Values.ingress.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
5 changes: 3 additions & 2 deletions helm/charts/registry/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: infra-registry
namespace: {{ .Release.Namespace }}
name: {{ include "registry.fullname" . }}
labels:
{{- include "registry.labels" . | nindent 4 }}
spec:
accessModes:
- ReadWriteOnce
Expand Down
5 changes: 3 additions & 2 deletions helm/charts/registry/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: infra-registry-secret-reader
namespace: {{ .Release.Namespace }}
name: {{ include "registry.fullname" . }}
labels:
{{- include "registry.labels" . | nindent 4 }}
rules:
- apiGroups: [""]
resources: ["secrets"]
Expand Down
13 changes: 7 additions & 6 deletions helm/charts/registry/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: infra-registry-secret-reader
namespace: {{ .Release.Namespace }}
name: {{ include "registry.fullname" . }}
labels:
{{- include "registry.labels" . | nindent 4 }}
subjects:
- kind: ServiceAccount
name: infra-registry
namespace: {{ .Release.Namespace }}
- kind: ServiceAccount
name: {{ include "registry.fullname" . }}
namespace: {{ .Release.Namespace }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: infra-registry-secret-reader
name: {{ include "registry.fullname" . }}
4 changes: 2 additions & 2 deletions helm/charts/registry/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
apiVersion: v1
kind: Secret
metadata:
name: infra-registry
namespace: {{ .Release.Namespace }}
name: {{ include "registry.fullname" . }}
labels:
{{- include "registry.labels" . | nindent 4 }}
type: Opaque
data:
rootApiKey: {{ include "rootApiKey" . | b64enc | quote }}
Expand Down
9 changes: 4 additions & 5 deletions helm/charts/registry/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
apiVersion: v1
kind: Service
metadata:
name: infra-registry
namespace: {{ .Release.Namespace }}
name: {{ include "registry.fullname" . }}
labels:
app: infra-registry
{{- include "registry.labels" . | nindent 4 }}
{{- with .Values.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
Expand Down Expand Up @@ -34,7 +33,7 @@ spec:
{{- end }}
{{- with .Values.service.externalIPs }}
externalIPs:
{{ toYaml . | indent 4 }}
{{- toYaml . | nindent 4 }}
{{- end }}
ports:
{{- range .Values.service.ports }}
Expand All @@ -47,4 +46,4 @@ spec:
{{- end }}
{{- end }}
selector:
app: infra-registry
{{- include "registry.selectorLabels" . | nindent 6 }}
5 changes: 3 additions & 2 deletions helm/charts/registry/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: infra-registry
namespace: {{ .Release.Namespace }}
name: {{ include "registry.fullname" . }}
labels:
{{- include "registry.labels" . | nindent 4 }}
7 changes: 7 additions & 0 deletions helm/charts/registry/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ storage: 1Gi
engineApiKey: ""
config: null

pod:
annotations: {}

serviceAccount:
create: true
annotations: {}

image:
repository: infrahq/infra
tag: ""
Expand Down

0 comments on commit c88c9f2

Please sign in to comment.