Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions charts/kellnr/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,22 @@ KELLNR_OAUTH2__BUTTON_TEXT: {{ .Values.kellnr.oauth2.buttonText | quote }}
{{ end }}
{{- end }}

{{/*
Build the origin URL (protocol + hostname + optional port).
Omits the port when it matches the default for the protocol (443 for https, 80 for http).
*/}}
{{- define "kellnr.originUrl" -}}
{{- $protocol := default "http" .Values.kellnr.origin.protocol -}}
{{- $port := include "kellnr.serviceOriginPort" . | int -}}
{{- $defaultPort := 80 -}}
{{- if eq $protocol "https" -}}
{{- $defaultPort = 443 -}}
{{- end -}}
{{- if eq (int $port) (int $defaultPort) -}}
{{- printf "%s://%s" $protocol .Values.kellnr.origin.hostname -}}
{{- else -}}
{{- printf "%s://%s:%d" $protocol .Values.kellnr.origin.hostname $port -}}
{{- end -}}
{{- end }}


25 changes: 23 additions & 2 deletions charts/kellnr/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ spec:
{{- else if not .Values.secret.enabled }}
configHash: {{ include (print $.Template.BasePath "/config.yaml") . | sha256sum }}
{{- end }}
{{- if .Values.docBuilder.enabled }}
docConfigHash: {{ include (print $.Template.BasePath "/doc-config.yaml") . | sha256sum }}
{{- end }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "kellnr.selectorLabels" . | nindent 8 }}
spec:
{{- if or .Values.pvc.enabled .Values.importCert.enabled }}
{{- if or .Values.pvc.enabled .Values.importCert.enabled .Values.docBuilder.enabled }}
volumes:
{{- if .Values.pvc.enabled }}
- name: {{ .Values.deployment.volumes.name }}
Expand All @@ -45,6 +48,11 @@ spec:
configMap:
name: {{ .Values.importCert.configMapName | quote }}
{{- end }}
{{- if .Values.docBuilder.enabled }}
- name: cargo-config
configMap:
name: {{ .Values.docBuilder.configMapName | quote }}
{{- end }}
- name: certs
emptyDir: {}
- name: tmp
Expand Down Expand Up @@ -87,6 +95,13 @@ spec:
valueFrom:
secretKeyRef: {{ toYaml .Values.kellnr.oauth2.clientSecretRef | nindent 16 }}
{{- end }}
{{- if and .Values.docBuilder.enabled .Values.docBuilder.tokenSecretRef.name }}
- name: RUSTUP_TOOLCHAIN
value: {{ .Values.docBuilder.rustupToolchain | quote }}
- name: CARGO_REGISTRIES_{{ .Values.docBuilder.registryName | upper }}_TOKEN
valueFrom:
secretKeyRef: {{ toYaml .Values.docBuilder.tokenSecretRef | nindent 16 }}
{{- end }}
envFrom:
{{- if .Values.secret.enabled }}
- secretRef:
Expand All @@ -99,7 +114,7 @@ spec:
- containerPort: {{ .Values.service.api.port }}
name: kellnr-api
protocol: TCP
{{- if or .Values.pvc.enabled .Values.importCert.enabled }}
{{- if or .Values.pvc.enabled .Values.importCert.enabled .Values.docBuilder.enabled }}
volumeMounts:
{{- if .Values.pvc.enabled }}
- mountPath: {{ .Values.kellnr.registry.dataDir | quote }}
Expand All @@ -111,6 +126,12 @@ spec:
mountPath: "/usr/local/share/ca-certificates/"
readOnly: true
{{- end }}
{{- if .Values.docBuilder.enabled }}
- name: cargo-config
mountPath: "/usr/local/cargo/config.toml"
subPath: config.toml
readOnly: true
{{- end }}
- mountPath: /etc/ssl/certs
name: certs
- mountPath: /tmp
Expand Down
24 changes: 24 additions & 0 deletions charts/kellnr/templates/doc-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# ConfigMap providing Cargo registry configuration for rustdoc auto-generation.
# Allows Kellnr to resolve and download crates from itself (localhost) when
# building documentation inside the container.

{{- if .Values.docBuilder.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.docBuilder.configMapName | quote }}
labels:
{{- include "kellnr.labels" . | nindent 4 }}
data:
config.toml: |-
[registries.{{ .Values.docBuilder.registryName }}]
index = "sparse+http://localhost:{{ .Values.service.api.port }}/api/v1/crates/"
credential-provider = ["cargo:token"]

[source.{{ .Values.docBuilder.registryName }}]
registry = "sparse+{{ include "kellnr.originUrl" . }}/api/v1/crates/"
replace-with = "{{ .Values.docBuilder.registryName }}-local"

[source.{{ .Values.docBuilder.registryName }}-local]
registry = "sparse+http://localhost:{{ .Values.service.api.port }}/api/v1/crates/"
{{- end }}
9 changes: 9 additions & 0 deletions charts/kellnr/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,15 @@ importCert:
volumeName: "kellnr-cert-storage"
certificate: ""

docBuilder:
enabled: false
rustupToolchain: "stable"
registryName: kellnr
configMapName: kellnr-doc-config
tokenSecretRef:
name: kellnr-doc-token
key: token

dns:
enabled: false
dnsPolicy: "None"
Expand Down