Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm improvement #281

Merged
merged 11 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion charts/registry/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ sources:
- https://github.com/eclipse-tractusx/sldt-digital-twin-registry

type: application
version: 0.3.31
version: 0.3.32
appVersion: 0.3.23

dependencies:
Expand Down
48 changes: 48 additions & 0 deletions charts/registry/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "chart.name" -}}
florianrusch-zf marked this conversation as resolved.
Show resolved Hide resolved
{{- default .Chart.Name .Values.nameOverride | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end }}

{{/*
Create a default fully qualified app name.
If release name contains chart name it will be used as a full name.
*/}}
{{- define "chart.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 "chart.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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


{{- define "chart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "chart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
4 changes: 3 additions & 1 deletion charts/registry/templates/keycloak/database-credentials.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
# SPDX-License-Identifier: Apache-2.0
###############################################################

{{- $fullName := include "chart.fullname" . }}
{{- $keycloak_sec_name := printf "%s-keycloak-sec" $fullName }}
apiVersion: v1
tunacicek marked this conversation as resolved.
Show resolved Hide resolved
kind: Secret
metadata:
name: keycloak-database-credentials
name: {{ $keycloak_sec_name }}
tunacicek marked this conversation as resolved.
Show resolved Hide resolved
type: Opaque
data:
db-host: {{ printf "%s-postgresql" .Release.Name | b64enc }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
# SPDX-License-Identifier: Apache-2.0
---

{{- $fullName := include "chart.fullname" . }}
{{- $keycloak_config_name := printf "%s-keycloak-configmap" $fullName }}
kind: ConfigMap
apiVersion: v1
metadata:
name: init-script-vol
name: {{ $keycloak_config_name }}
data:
default-realm-import.json: |-
{{ .Files.Get "config/default-realm-import.json" | indent 4 }}
16 changes: 9 additions & 7 deletions charts/registry/templates/registry/registry-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,29 @@
# SPDX-License-Identifier: Apache-2.0
###############################################################

{{- $deployment_name := printf "cx-%s-registry" .Release.Name }}
{{- $sec_name := printf "%s-sec" $deployment_name }}
{{- $svc_name := printf "%s-svc" $deployment_name }}
{{- $fullName := include "chart.fullname" . }}
{{- $svc_name := printf "%s-svc" $fullName }}
{{- $sec_name := printf "%s-sec" $fullName }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $deployment_name }}
name: {{ include "chart.fullname" . }}
labels:
{{- include "chart.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.registry.replicaCount }}
selector:
matchLabels:
app: {{ $deployment_name }}
{{- include "chart.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
app: {{ $deployment_name }}
{{- include "chart.selectorLabels" . | nindent 8 }}
spec:
securityContext:
runAsUser: 100
containers:
- name: {{ $deployment_name }}
- name: {{ .Chart.Name }}
image: {{ .Values.registry.image.registry }}/{{ .Values.registry.image.repository }}:{{ .Values.registry.image.version | default .Chart.AppVersion }}
imagePullPolicy: {{ .Values.registry.imagePullPolicy }}
securityContext:
Expand Down
5 changes: 3 additions & 2 deletions charts/registry/templates/registry/registry-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@

{{- $deployment_name := printf "cx-%s-registry" .Release.Name }}
{{- $svc_name := printf "%s-svc" $deployment_name }}
{{- $ingr_name := printf "%s-ingr" $deployment_name }}
{{- $fullName := include "chart.fullname" . }}
{{- $ingr_name := printf "%s-ingr" $fullName }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $ingr_name }}
annotations:
{{ .Values.registry.ingress.annotations | toYaml | indent 4 }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- include "chart.labels" . | nindent 4 }}
spec:
ingressClassName: {{ .Values.registry.ingress.className }}
{{- if .Values.registry.ingress.tls }}
Expand Down
4 changes: 2 additions & 2 deletions charts/registry/templates/registry/registry-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
# SPDX-License-Identifier: Apache-2.0
###############################################################

{{- $deployment_name := printf "cx-%s-registry" .Release.Name }}
{{- $sec_name := printf "%s-sec" $deployment_name }}
{{- $fullName := include "chart.fullname" . }}
{{- $sec_name := printf "%s-sec" $fullName }}
apiVersion: v1
kind: Secret
metadata:
Expand Down
8 changes: 4 additions & 4 deletions charts/registry/templates/registry/registry-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
# SPDX-License-Identifier: Apache-2.0
###############################################################

{{- $deployment_name := printf "cx-%s-registry" .Release.Name }}
{{- $svc_name := printf "%s-svc" $deployment_name }}
{{- $fullName := include "chart.fullname" . }}
{{- $svc_name := printf "%s-svc" $fullName }}
apiVersion: v1
kind: Service
metadata:
name: {{ $svc_name }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- include "chart.labels" . | nindent 4 }}
spec:
type: {{ .Values.registry.service.type }}
ports:
- port: {{ .Values.registry.service.port }}
targetPort: {{ .Values.registry.containerPort }}
selector:
app: {{ $deployment_name }}
{{- include "chart.selectorLabels" . | nindent 6 }}
tunacicek marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 8 additions & 3 deletions charts/registry/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@
#
# SPDX-License-Identifier: Apache-2.0
###############################################################

{{- $fullName := include "chart.fullname" . }}
{{- $testconnection_name := printf "%s-test-script-pod" $fullName }}
{{- $testsec_name := printf "%s-test-credentials" $fullName }}
{{- $testconfig_name := printf "%s-test-script" $fullName }}
tunacicek marked this conversation as resolved.
Show resolved Hide resolved
apiVersion: v1
kind: Pod
metadata:
name: "test-script-pod"
name: {{ $testconnection_name }}
annotations:
"helm.sh/hook": test
spec:
Expand All @@ -40,12 +45,12 @@ spec:
- name: AAS_REGISTRY_API_URL
valueFrom:
secretKeyRef:
name: test-credentials
name: {{ $testsec_name }}
key: aasRegistryUrl
volumes:
- name: test-script
configMap:
name: test-script
name: {{ $testconfig_name }}
defaultMode: 0777
- name: test-output
hostPath:
Expand Down
8 changes: 6 additions & 2 deletions charts/registry/templates/tests/test-credentials.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
#
# SPDX-License-Identifier: Apache-2.0
###############################################################

{{- $fullName := include "chart.fullname" . }}
{{- $testsec_name := printf "%s-test-credentials" $fullName }}
{{- $svc_name := printf "%s-svc" $fullName }}
tunacicek marked this conversation as resolved.
Show resolved Hide resolved
apiVersion: v1
kind: Secret
metadata:
name: test-credentials
name: {{ $testsec_name }}
type: Opaque
data:
aasRegistryUrl: {{ printf "http://cx-%s-registry-svc:8080" .Release.Name | b64enc }}
aasRegistryUrl: {{ printf "http://%s:8080" $svc_name| b64enc }}
5 changes: 4 additions & 1 deletion charts/registry/templates/tests/test-script-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
#
# SPDX-License-Identifier: Apache-2.0
###############################################################

{{- $fullName := include "chart.fullname" . }}
{{- $testconfig_name := printf "%s-test-script" $fullName }}
kind: ConfigMap
apiVersion: v1
metadata:
name: test-script
name: {{ $testconfig_name }}
data:
test-script.sh: |
#!/bin/sh
Expand Down
4 changes: 3 additions & 1 deletion charts/registry/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@
# SPDX-License-Identifier: Apache-2.0
###############################################################


nameOverride:
fullnameOverride:
# enables the default postgres database
enablePostgres: true
# enables the default keycloak identity provider
# relies on a postgres instance
enableKeycloak: false

registry:
name: registry
tunacicek marked this conversation as resolved.
Show resolved Hide resolved
image:
registry: docker.io
repository: tractusx/sldt-digital-twin-registry
Expand Down
Loading