Skip to content

Commit 65151e1

Browse files
committed
[skip ci] repo-sync
1 parent daa606d commit 65151e1

File tree

10 files changed

+1024
-56
lines changed

10 files changed

+1024
-56
lines changed

chart/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ maintainers:
3232
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
3333
type: application
3434

35-
version:
35+
version: v4.8.0-alpha.4

chart/templates/_helpers.tpl

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,56 @@ Default image name for a given product
2727
{{- printf "ghcr.io/loft-sh/loft:%s" .Chart.Version -}}
2828
{{- end -}}
2929

30+
{{/*
31+
Populate image ref for a given product
32+
*/}}
33+
{{- define "loft.imageRef" -}}
34+
{{- $registry := default "ghcr.io" .Values.imageRef.registry -}}
35+
{{- $repository := coalesce .Values.imageRef.repository .repo "loft-sh/vcluster-platform" -}}
36+
{{- $tag := default .Chart.Version .Values.imageRef.tag -}}
37+
{{- printf "%s/%s:%s" $registry $repository $tag -}}
38+
{{- end -}}
39+
3040
{{- define "loft.image" -}}
3141
{{- if .Values.product -}}
3242
{{- if eq .Values.product "vcluster-pro" -}}
33-
{{- printf "ghcr.io/loft-sh/vcluster-platform:%s" .Chart.Version -}}
34-
{{- else if eq .Values.product "devpod-pro" -}}
35-
{{- printf "ghcr.io/loft-sh/devpod-pro:%s" .Chart.Version -}}
43+
{{- if .Values.imageRef -}}
44+
{{ include "loft.imageRef" $ }}
45+
{{- else -}}
46+
{{- printf "ghcr.io/loft-sh/vcluster-platform:%s" .Chart.Version -}}
47+
{{- end -}}
3648
{{- else -}}
37-
{{ include "loft.defaultImage" . }}
49+
{{- if .Values.imageRef -}}
50+
{{ include "loft.imageRef" (merge (dict "repo" "loft-sh/loft") $) }}
51+
{{- else -}}
52+
{{ coalesce .Values.image (include "loft.defaultImage" .) }}
53+
{{- end -}}
3854
{{- end -}}
3955
{{- else -}}
40-
{{ include "loft.defaultImage" . }}
56+
{{- if .Values.imageRef -}}
57+
{{ include "loft.imageRef" (merge (dict "repo" "loft-sh/loft") $) }}
58+
{{- else -}}
59+
{{ coalesce .Values.image (include "loft.defaultImage" .) }}
60+
{{- end -}}
61+
{{- end -}}
62+
{{- end -}}
63+
64+
65+
{{/*
66+
Populate audit image ref
67+
*/}}
68+
{{- define "loft.auditImageRef" -}}
69+
{{- $registry := default "docker.io" .Values.audit.imageRef.registry -}}
70+
{{- $repository := default "library/alpine" .Values.audit.imageRef.repository -}}
71+
{{- $tag := default "3.13.1" .Values.audit.imageRef.tag -}}
72+
{{- printf "%s/%s:%s" $registry $repository $tag -}}
73+
{{- end -}}
74+
75+
{{- define "loft.auditImage" -}}
76+
{{- if .Values.audit.imageRef -}}
77+
{{ include "loft.auditImageRef" . }}
78+
{{- else -}}
79+
{{ default "library/alpine:3.13.1" .Values.audit.image }}
4180
{{- end -}}
4281
{{- end -}}
4382

chart/templates/application.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{{- if (dig "gcpMarketplace" "enabled" false (.Values|merge (dict) )) }}
2+
apiVersion: app.k8s.io/v1beta1
3+
kind: Application
4+
metadata:
5+
name: "{{ .Release.Name }}"
6+
namespace: "{{ .Release.Namespace }}"
7+
labels:
8+
app.kubernetes.io/name: "{{ .Release.Name }}"
9+
annotations:
10+
marketplace.cloud.google.com/deploy-info: '{"partner_id": "bji0uLnnv1", "product_id": "vcluster", "partner_name": "vCluster Labs"}'
11+
spec:
12+
descriptor:
13+
type: vClusterPlatform
14+
version: {{ .Chart.Version }}
15+
selector:
16+
matchLabels:
17+
app.kubernetes.io/name: "{{ .Release.Name }}"
18+
addOwnerRef: true
19+
componentKinds:
20+
# Core
21+
- group: ""
22+
kind: Service
23+
- group: ""
24+
kind: ServiceAccount
25+
- group: ""
26+
kind: ConfigMap
27+
- group: ""
28+
kind: Secret
29+
- group: policy
30+
kind: PodDisruptionBudget
31+
# Workloads
32+
- group: apps
33+
kind: Deployment
34+
# Networking
35+
- group: networking.k8s.io
36+
kind: Ingress
37+
# RBAC
38+
- group: rbac.authorization.k8s.io
39+
kind: Role
40+
- group: rbac.authorization.k8s.io
41+
kind: RoleBinding
42+
- group: rbac.authorization.k8s.io
43+
kind: ClusterRole
44+
- group: rbac.authorization.k8s.io
45+
kind: ClusterRoleBinding
46+
# Admission webhooks used by the chart
47+
- group: admissionregistration.k8s.io
48+
kind: MutatingWebhookConfiguration
49+
- group: admissionregistration.k8s.io
50+
kind: ValidatingWebhookConfiguration
51+
{{- end }}

chart/templates/deployment.yaml

Lines changed: 96 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
{{- if and .Values.multiRegion.enabled (eq .Values.multiRegion.dataSource "") -}}
2+
{{ fail "multiRegion.dataSource must be set when multiRegion.enabled is true" }}
3+
{{- end }}
4+
{{- if and .Values.multiRegion.enabled (eq .Values.multiRegion.host "") -}}
5+
{{ fail "multiRegion.host must be set when multiRegion.enabled is true" }}
6+
{{- end }}
17
apiVersion: apps/v1
28
kind: Deployment
39
metadata:
@@ -55,7 +61,7 @@ spec:
5561
- name: loft-data
5662
emptyDir: {}
5763
{{- end }}
58-
{{- if .Values.additionalCA }}
64+
{{- if and .Values.additionalCA (not .Values.insecureSkipVerify) }}
5965
- name: loft-additional-ca
6066
secret:
6167
secretName: loft-additional-ca
@@ -65,7 +71,10 @@ spec:
6571
{{- if .Values.agentOnly }}
6672
command: ["loft", "agent"]
6773
{{- end }}
68-
image: {{ default (include "loft.image" .) .Values.image }}
74+
image: {{ include "loft.image" . }}
75+
{{- if .Values.imagePullPolicy }}
76+
imagePullPolicy: {{ .Values.imagePullPolicy }}
77+
{{- end }}
6978
ports:
7079
- name: http
7180
containerPort: 8080
@@ -98,19 +107,35 @@ spec:
98107
{{- end }}
99108
{{- end }}
100109
env:
110+
{{- if not .Values.admin.create }}
111+
- name: ADMIN_SKIP_CREATE
112+
value: "true"
113+
{{- end }}
101114
- name: ADMIN_EMAIL
102115
value: {{ .Values.admin.email | quote }}
103116
- name: CHART_VERSION
104117
value: {{ .Chart.Version }}
105118
{{- if .Values.admin.password }}
119+
{{- if hasPrefix "$" .Values.admin.password }}
120+
- name: ADMIN_PASSWORD_ENV
121+
value: {{ .Values.admin.password }}
122+
{{- else }}
106123
- name: ADMIN_PASSWORD_HASH
107124
value: {{ .Values.admin.password | sha256sum | quote }}
108125
{{- end }}
126+
{{- end }}
127+
{{- if .Values.admin.username }}
128+
- name: ADMIN_USERNAME
129+
value: {{ .Values.admin.username | quote }}
130+
{{- end }}
109131
{{- if (gt (int .Values.replicaCount) 1) }}
110132
{{- if not (and .Values.env .Values.env.LEADER_ELECTION_ENABLED) }}
111133
- name: LEADER_ELECTION_ENABLED
112134
value: "true"
113135
{{- end }}
136+
{{- else if .Values.multiRegion.enabled }}
137+
- name: LEADER_ELECTION_ENABLED
138+
value: "true"
114139
{{- end }}
115140
{{- range $key, $value := .Values.envValueFrom }}
116141
- name: {{ $key | quote }}
@@ -141,6 +166,36 @@ spec:
141166
- name: TS_DEBUG_TLS_DIAL_INSECURE_SKIP_VERIFY
142167
value: "true"
143168
{{- end }}
169+
{{- if not (hasKey .Values.env "LOFT_MANAGER_IMAGE") }}
170+
- name: LOFT_MANAGER_IMAGE
171+
value: {{ include "loft.image" . | quote }}
172+
{{- end }}
173+
{{- if .Values.multiRegion.enabled }}
174+
{{- if .Values.config.loftHost }}
175+
- name: LOFT_HOST
176+
value: {{ .Values.config.loftHost | quote }}
177+
{{- end }}
178+
- name: LOFT_MULTI_REGION_PLATFORM
179+
value: "true"
180+
- name: LOFT_MULTI_REGION_PLATFORM_HOST
181+
value: {{ .Values.multiRegion.host | quote }}
182+
- name: LOFT_EMBEDDED_K8S
183+
value: "true"
184+
- name: LOFT_EMBEDDED_K8S_DATA_SOURCE
185+
value: {{ .Values.multiRegion.dataSource | quote }}
186+
{{- if .Values.multiRegion.dataSourceIdentityProvider }}
187+
- name: LOFT_EMBEDDED_K8S_DATA_SOURCE_IDENTITY_PROVIDER
188+
value: {{ .Values.multiRegion.dataSourceIdentityProvider | quote }}
189+
{{- end }}
190+
{{- if (gt (int .Values.multiRegion.dataSourceMaxConnections) 1) }}
191+
- name: LOFT_EMBEDDED_K8S_MAX_DATABASE_CONNECTIONS
192+
value: {{ .Values.multiRegion.dataSourceMaxConnections | quote }}
193+
{{- end }}
194+
{{- if (gt (int .Values.multiRegion.dataSourceMaxIdleConnections) 1) }}
195+
- name: LOFT_EMBEDDED_K8S_MAX_IDLE_CONNECTIONS
196+
value: {{ .Values.multiRegion.dataSourceMaxIdleConnections | quote }}
197+
{{- end }}
198+
{{- end }}
144199
{{- range $key, $value := .Values.env }}
145200
- name: {{ $key | quote }}
146201
value: {{ $value | quote }}
@@ -151,7 +206,7 @@ spec:
151206
{{- end }}
152207
- mountPath: /var/lib/loft
153208
name: loft-data
154-
{{- if .Values.additionalCA }}
209+
{{- if and .Values.additionalCA (not .Values.insecureSkipVerify) }}
155210
- name: loft-additional-ca
156211
mountPath: /etc/ssl/certs/loft-additional-ca.crt
157212
readOnly: true
@@ -164,25 +219,60 @@ spec:
164219
{{- if .Values.audit }}
165220
{{- if .Values.audit.enableSideCar }}
166221
- name: audit
167-
image: "{{ .Values.audit.image }}"
222+
image: {{ include "loft.auditImage" . }}
168223
command: ["sh"]
169224
args: ["-c", "touch /var/lib/loft/audit.log && tail -F /var/lib/loft/audit.log"]
170225
volumeMounts:
171226
- mountPath: /var/lib/loft
172227
name: loft-data
228+
securityContext:
229+
{{- toYaml .Values.audit.securityContext | nindent 12 }}
173230
{{- end }}
174231
{{- end }}
175232
{{- if .Values.nodeSelector }}
176233
nodeSelector:
177234
{{ toYaml .Values.nodeSelector | indent 8 }}
178235
{{- end }}
179-
{{- if .Values.affinity }}
236+
237+
{{- $preferredSchedulingTerms := list -}}
238+
{{- if and .Values.affinity.nodeAffinity.preferNotToRunOnSpotInstances .Values.affinity.nodeAffinity.preferNotToRunOnSpotInstances.enabled }}
239+
{{- range $index, $term := .Values.affinity.nodeAffinity.preferNotToRunOnSpotInstances.terms -}}
240+
{{- $preferredSchedulingTerms = append $preferredSchedulingTerms $term -}}
241+
{{- end }}
242+
{{- end }}
243+
{{- range $index, $term := .Values.affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution -}}
244+
{{- $preferredSchedulingTerms = append $preferredSchedulingTerms $term -}}
245+
{{- end }}
246+
{{- if or .Values.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution $preferredSchedulingTerms .Values.affinity.podAffinity .Values.affinity.podAntiAffinity }}
180247
affinity:
181-
{{ toYaml .Values.affinity | indent 8 }}
248+
{{- if or .Values.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution $preferredSchedulingTerms }}
249+
nodeAffinity:
250+
{{- if $preferredSchedulingTerms }}
251+
preferredDuringSchedulingIgnoredDuringExecution:
252+
{{ toYaml $preferredSchedulingTerms | indent 12 }}
253+
{{- end }}
254+
{{- if .Values.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution }}
255+
requiredDuringSchedulingIgnoredDuringExecution:
256+
{{ toYaml .Values.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution | indent 12 }}
257+
{{- end }}
258+
{{- end }}
259+
{{- if or .Values.affinity.podAffinity }}
260+
podAffinity:
261+
{{ toYaml .Values.affinity.podAffinity | indent 10 }}
262+
{{- end }}
263+
{{- if or .Values.affinity.podAntiAffinity }}
264+
podAntiAffinity:
265+
{{ toYaml .Values.affinity.podAntiAffinity | indent 10 }}
266+
{{- end }}
182267
{{- end }}
268+
183269
{{- if .Values.tolerations }}
184270
tolerations:
185271
{{ toYaml .Values.tolerations | indent 8 }}
272+
{{- end }}
273+
{{- if .Values.hostAliases }}
274+
hostAliases:
275+
{{ toYaml .Values.hostAliases | indent 8 }}
186276
{{- end }}
187277
securityContext:
188278
{{- toYaml .Values.podSecurityContext | nindent 8 }}

chart/templates/ingress-wakeup-service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
namespace: {{ .Release.Namespace }}
66
labels:
77
app: {{ template "loft.fullname" . }}
8-
loft.sh/service: {{ template "loft.fullname" . }}
8+
loft.sh/service: {{ template "loft.fullname" . }}-ingress-wakeup-agent
99
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
1010
release: "{{ .Release.Name }}"
1111
heritage: "{{ .Release.Service }}"

chart/templates/ingress.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ metadata:
1313
{{- toYaml . | nindent 4 }}
1414
{{- end }}
1515
annotations:
16-
nginx.ingress.kubernetes.io/proxy-read-timeout: "43200"
17-
nginx.ingress.kubernetes.io/proxy-send-timeout: "43200"
1816
nginx.org/websocket-services: loft
1917
{{- with .Values.ingress.annotations }}
2018
{{- toYaml . | nindent 4 }}
@@ -27,7 +25,7 @@ spec:
2725
ingressClassName: {{ .Values.ingress.ingressClass }}
2826
{{- end }}
2927
rules:
30-
- host: {{ .Values.ingress.host }}
28+
- host: {{ .Values.ingress.host | quote }}
3129
http:
3230
paths:
3331
- path: {{ .Values.ingress.path }}
@@ -40,7 +38,7 @@ spec:
4038
{{- if .Values.ingress.tls.enabled }}
4139
tls:
4240
- hosts:
43-
- {{ .Values.ingress.host }}
41+
- {{ .Values.ingress.host | quote }}
4442
{{- if .Values.ingress.tls.secret }}
4543
secretName: {{ .Values.ingress.tls.secret }}
4644
{{- end }}

chart/templates/secret.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ data:
7575
url: {{ toYaml .Values.url | b64enc }}
7676
{{- end }}
7777

78-
{{- if .Values.additionalCA }}
78+
{{- if and .Values.additionalCA (not .Values.insecureSkipVerify) }}
7979
---
8080
apiVersion: v1
8181
kind: Secret

chart/tests/application_test.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
suite: gcpMarketplace Application test
2+
templates:
3+
- templates/application.yaml
4+
5+
tests:
6+
- it: does not panic if gcpMarketplace is null and does not render the application
7+
set:
8+
gcpMarketplace: null
9+
asserts:
10+
- hasDocuments:
11+
count: 0
12+
13+
- it: does not panic if gcpMarketplace is not set
14+
asserts:
15+
- hasDocuments:
16+
count: 0
17+
18+
- it: renders application if gcpMarketplace.enabled is true
19+
set:
20+
gcpMarketplace:
21+
enabled: true
22+
asserts:
23+
- hasDocuments:
24+
count: 1
25+
- isKind:
26+
of: Application
27+
28+
- it: does not render application if gcpMarketplace.enabled is false
29+
set:
30+
gcpMarketplace:
31+
enabled: false
32+
asserts:
33+
- hasDocuments:
34+
count: 0

0 commit comments

Comments
 (0)