Skip to content

Commit 1c9ad24

Browse files
committed
feat: add helm chart for IF
Signed-off-by: Mateusz Urbanek <[email protected]>
1 parent d782950 commit 1c9ad24

15 files changed

+1016
-0
lines changed

charts/image-factory/.helmignore

Whitespace-only changes.

charts/image-factory/Chart.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v2
2+
type: application
3+
name: image-factory
4+
description: |
5+
A service to generate Talos boot assets.
6+
home: https://github.com/siderolabs/image-factory
7+
version: 0.0.0-alpha.1
8+
appVersion: "v0.8.4"
9+
sources:
10+
- https://github.com/siderolabs/image-factory
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else }}
9+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "imageFactory.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
10+
echo "Visit http://127.0.0.1:8080 to use your application"
11+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:{{ .Values.service.port }}
12+
{{- end }}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "imageFactory.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "imageFactory.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "imageFactory.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "imageFactory.labels" -}}
37+
helm.sh/chart: {{ include "imageFactory.chart" . }}
38+
{{ include "imageFactory.selectorLabels" . }}
39+
app.kubernetes.io/managed-by: {{ .Release.Service }}
40+
{{- end }}
41+
42+
{{/*
43+
Selector labels
44+
*/}}
45+
{{- define "imageFactory.selectorLabels" -}}
46+
app.kubernetes.io/name: {{ include "imageFactory.name" . }}
47+
app.kubernetes.io/instance: {{ .Release.Name }}
48+
{{- end }}
49+
50+
{{/*
51+
Create the name of the service account to use
52+
*/}}
53+
{{- define "imageFactory.serviceAccountName" -}}
54+
{{- if .Values.serviceAccount.create }}
55+
{{- default (include "imageFactory.fullname" .) .Values.serviceAccount.name }}
56+
{{- else }}
57+
{{- default "default" .Values.serviceAccount.name }}
58+
{{- end }}
59+
{{- end }}
60+
61+
{{/*
62+
Create secret name used for configuring imageFactory.
63+
*/}}
64+
{{- define "imageFactory.secret" -}}
65+
{{- default (printf "%s" (include "imageFactory.fullname" .)) .Values.secret.name }}
66+
{{- end }}
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
{{- $replicaCount := int (.Values.replicaCount | default 1) }}
2+
{{- $cacheRepository := .Values.config.cacheRepository | required ".Values.config.cacheRepository is required." }}
3+
{{- $schematicServiceRepository := .Values.config.schematicServiceRepository | required ".Values.config.schematicServiceRepository is required." }}
4+
apiVersion: apps/v1
5+
kind: Deployment
6+
metadata:
7+
name: {{ include "imageFactory.fullname" . }}
8+
namespace: {{ .Release.Namespace }}
9+
labels:
10+
{{- include "imageFactory.labels" . | nindent 4 }}
11+
spec:
12+
serviceName: {{ include "imageFactory.fullname" . }}
13+
replicas: {{ $replicaCount }}
14+
selector:
15+
matchLabels:
16+
{{- include "imageFactory.selectorLabels" . | nindent 6 }}
17+
template:
18+
metadata:
19+
{{- with .Values.podAnnotations }}
20+
annotations:
21+
{{- toYaml . | nindent 8 }}
22+
{{- end }}
23+
labels:
24+
{{- include "imageFactory.labels" . | nindent 8 }}
25+
{{- with .Values.podLabels }}
26+
{{- toYaml . | nindent 8 }}
27+
{{- end }}
28+
spec:
29+
{{- with .Values.imagePullSecrets }}
30+
imagePullSecrets:
31+
{{- toYaml . | nindent 8 }}
32+
{{- end }}
33+
serviceAccountName: {{ include "imageFactory.serviceAccountName" . }}
34+
securityContext:
35+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
36+
volumes:
37+
- name: secret
38+
secret:
39+
secretName: {{ include "imageFactory.secret" . }}
40+
containers:
41+
- name: image-factory
42+
securityContext:
43+
{{- toYaml .Values.securityContext | nindent 12 }}
44+
args:
45+
- -cache-repository={{ $cacheRepository }}
46+
- -cache-signing-key-path=/opt/image-factory/cache-signing-key.pem
47+
- -http-port=:8080
48+
- -schematic-service-repository={{ $schematicServiceRepository }}
49+
{{- with .Values.config }}
50+
{{- if .assetBuilderMaxConcurrency }}
51+
- -asset-builder-max-concurrency={{ .assetBuilderMaxConcurrency }}
52+
{{- end }}
53+
{{- if .cacheCdnEnabled }}
54+
- -cache-cdn-enabled
55+
{{- end }}
56+
{{- if .cacheCdnHost }}
57+
- -cache-cdn-host={{ .cacheCdnHost }}
58+
{{- end }}
59+
{{- if .cacheCdnTrimPrefix }}
60+
- -cache-cdn-trim-prefix={{ .cacheCdnTrimPrefix }}
61+
{{- end }}
62+
{{- if .cacheS3Bucket }}
63+
- -cache-s3-bucket={{ .cacheS3Bucket }}
64+
{{- end }}
65+
{{- if .cacheS3Enabled }}
66+
- -cache-s3-enabled
67+
{{- end }}
68+
{{- if .cacheS3Endpoint }}
69+
- -cache-s3-endpoint={{ .cacheS3Endpoint }}
70+
{{- end }}
71+
{{- if .cacheS3Region }}
72+
- -cache-s3-region={{ .cacheS3Region }}
73+
{{- end }}
74+
{{- if .containerSignatureDisabled }}
75+
- -container-signature-disabled
76+
{{- end }}
77+
{{- if .containerSignatureIssuer }}
78+
- -container-signature-issuer={{ .containerSignatureIssuer }}
79+
{{- end }}
80+
{{- if .containerSignatureIssuerRegexp }}
81+
- -container-signature-issuer-regexp={{ .containerSignatureIssuerRegexp }}
82+
{{- end }}
83+
{{- if .containerSignaturePubkey }}
84+
- -container-signature-pubkey={{ .containerSignaturePubkey }}
85+
{{- end }}
86+
{{- if .containerSignaturePubkeyHashalgo }}
87+
- -container-signature-pubkey-hashalgo={{ .containerSignaturePubkeyHashalgo }}
88+
{{- end }}
89+
{{- if .containerSignatureSubjectRegexp }}
90+
- -container-signature-subject-regexp={{ .containerSignatureSubjectRegexp }}
91+
{{- end }}
92+
{{- if .externalPxeUrl }}
93+
- -external-pxe-url={{ .externalPxeUrl }}
94+
{{- end }}
95+
{{- if .externalUrl }}
96+
- -external-url={{ .externalUrl }}
97+
{{- end }}
98+
{{- if .imageRegistry }}
99+
- -image-registry={{ .imageRegistry }}
100+
{{- end }}
101+
{{- if .insecureCacheRepository }}
102+
- -insecure-cache-repository
103+
{{- end }}
104+
{{- if .insecureCacheS3 }}
105+
- -insecure-cache-s3
106+
{{- end }}
107+
{{- if .insecureImageRegistry }}
108+
- -insecure-image-registry
109+
{{- end }}
110+
{{- if .insecureInstallerInternalRepository }}
111+
- -insecure-installer-internal-repository
112+
{{- end }}
113+
{{- if .insecureSchematicServiceRepository }}
114+
- -insecure-schematic-service-repository
115+
{{- end }}
116+
{{- if .installerExternalRepository }}
117+
- -installer-external-repository={{ .installerExternalRepository }}
118+
{{- end }}
119+
{{- if .installerInternalRepository }}
120+
- -installer-internal-repository={{ .installerInternalRepository }}
121+
{{- end }}
122+
{{- if .logLevel }}
123+
- -log-level={{ .logLevel }}
124+
{{- end }}
125+
{{- if .metricsListenAddr }}
126+
- -metrics-listen-addr={{ .metricsListenAddr }}
127+
{{- end }}
128+
{{- if .minTalosVersion }}
129+
- -min-talos-version={{ .minTalosVersion }}
130+
{{- end }}
131+
{{- if .registryRefreshInterval }}
132+
- -registry-refresh-interval={{ .registryRefreshInterval }}
133+
{{- end }}
134+
{{- if .secureboot }}
135+
- -secureboot
136+
{{- end }}
137+
{{- if .securebootAwsCertPath }}
138+
- -secureboot-aws-cert-path={{ .securebootAwsCertPath }}
139+
{{- end }}
140+
{{- if .securebootAwsKmsIdKeyId }}
141+
- -secureboot-aws-kms-id-key-id={{ .securebootAwsKmsIdKeyId }}
142+
{{- end }}
143+
{{- if .securebootAwsPcrKmsKeyId }}
144+
- -secureboot-aws-pcr-kms-key-id={{ .securebootAwsPcrKmsKeyId }}
145+
{{- end }}
146+
{{- if .securebootAwsRegion }}
147+
- -secureboot-aws-region={{ .securebootAwsRegion }}
148+
{{- end }}
149+
{{- if .securebootAzureCertificateName }}
150+
- -secureboot-azure-certificate-name={{ .securebootAzureCertificateName }}
151+
{{- end }}
152+
{{- if .securebootAzureKeyName }}
153+
- -secureboot-azure-key-name={{ .securebootAzureKeyName }}
154+
{{- end }}
155+
{{- if .securebootAzureKeyVaultUrl }}
156+
- -secureboot-azure-key-vault-url={{ .securebootAzureKeyVaultUrl }}
157+
{{- end }}
158+
{{- if .securebootPcrKeyPath }}
159+
- -secureboot-pcr-key-path={{ .securebootPcrKeyPath }}
160+
{{- end }}
161+
{{- if .securebootSigningCertPath }}
162+
- -secureboot-signing-cert-path={{ .securebootSigningCertPath }}
163+
{{- end }}
164+
{{- if .securebootSigningKeyPath }}
165+
- -secureboot-signing-key-path={{ .securebootSigningKeyPath }}
166+
{{- end }}
167+
{{- if .talosVersionsRecheckInterval }}
168+
- -talos-versions-recheck-interval={{ .talosVersionsRecheckInterval }}
169+
{{- end }}
170+
{{- end }}
171+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
172+
imagePullPolicy: {{ .Values.image.pullPolicy }}
173+
ports:
174+
- name: api
175+
containerPort: 8080
176+
protocol: TCP
177+
resources:
178+
{{- toYaml .Values.resources | nindent 12 }}
179+
volumeMounts:
180+
- name: secret
181+
mountPath: /opt/image-factory
182+
{{- with .Values.nodeSelector }}
183+
nodeSelector:
184+
{{- toYaml . | nindent 8 }}
185+
{{- end }}
186+
{{- with .Values.affinity }}
187+
affinity:
188+
{{- toYaml . | nindent 8 }}
189+
{{- end }}
190+
{{- with .Values.tolerations }}
191+
tolerations:
192+
{{- toYaml . | nindent 8 }}
193+
{{- end }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{- if .Values.ingress.enabled -}}
2+
{{- $fullName := include "imageFactory.fullname" . -}}
3+
{{- $svcPort := .Values.service.port -}}
4+
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
5+
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
6+
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
7+
{{- end }}
8+
{{- end }}
9+
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
10+
apiVersion: networking.k8s.io/v1
11+
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
12+
apiVersion: networking.k8s.io/v1beta1
13+
{{- else -}}
14+
apiVersion: extensions/v1beta1
15+
{{- end }}
16+
kind: Ingress
17+
metadata:
18+
name: {{ $fullName }}
19+
namespace: {{ .Release.Namespace }}
20+
labels:
21+
{{- include "imageFactory.labels" . | nindent 4 }}
22+
{{- with .Values.ingress.annotations }}
23+
annotations:
24+
{{- toYaml . | nindent 4 }}
25+
{{- end }}
26+
spec:
27+
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
28+
ingressClassName: {{ .Values.ingress.className }}
29+
{{- end }}
30+
{{- if .Values.ingress.tls }}
31+
tls:
32+
{{- range .Values.ingress.tls }}
33+
- hosts:
34+
{{- range .hosts }}
35+
- {{ . | quote }}
36+
{{- end }}
37+
{{ with .secretName }}
38+
secretName: {{ . }}
39+
{{- end }}
40+
{{- end }}
41+
{{- end }}
42+
rules:
43+
- host: {{ .Values.ingress.host | quote }}
44+
http:
45+
paths:
46+
{{- range .Values.ingress.paths }}
47+
- path: {{ .path }}
48+
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
49+
pathType: {{ .pathType }}
50+
{{- end }}
51+
backend:
52+
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
53+
service:
54+
name: {{ $fullName }}
55+
port:
56+
number: {{ $svcPort }}
57+
{{- else }}
58+
serviceName: {{ $fullName }}
59+
servicePort: {{ $svcPort }}
60+
{{- end }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{- if .Values.secret.create -}}
2+
{{- $key := default (genPrivateKey "ecdsa") .Values.secret.cacheSigningKey }}
3+
apiVersion: v1
4+
kind: Secret
5+
metadata:
6+
name: {{ include "imageFactory.secret" . }}
7+
namespace: {{ .Release.Namespace }}
8+
labels:
9+
{{- include "imageFactory.labels" . | nindent 4 }}
10+
annotations:
11+
helm.sh/resource-policy: keep
12+
type: Opaque
13+
stringData:
14+
cache-signing-key.pem: |
15+
{{- $key | nindent 4 }}
16+
{{- end }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{{- $svcPort := .Values.service.port | default 80 -}}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ include "imageFactory.fullname" . }}
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "imageFactory.labels" . | nindent 4 }}
9+
{{- with .Values.service.annotations }}
10+
annotations:
11+
{{- toYaml . | nindent 4 }}
12+
{{- end }}
13+
spec:
14+
type: {{ .Values.service.type | default "ClusterIP" }}
15+
ports:
16+
- port: {{ $svcPort }}
17+
targetPort: api
18+
protocol: TCP
19+
name: api
20+
selector:
21+
{{- include "imageFactory.selectorLabels" . | nindent 4 }}

0 commit comments

Comments
 (0)