Skip to content

Commit

Permalink
Merge pull request #105 from bci-oss/feature/chart-improvments
Browse files Browse the repository at this point in the history
Helm Improvements
  • Loading branch information
tunacicek authored Feb 14, 2024
2 parents b97648f + 4eddb57 commit fdb82ab
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 50 deletions.
2 changes: 1 addition & 1 deletion charts/discoveryfinder/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ home: https://eclipse-tractusx.github.io/
sources:
- https://github.com/eclipse-tractusx/sldt-discovery-finder
type: application
version: 0.2.0
version: 0.2.1
appVersion: 0.2.7

dependencies:
Expand Down
12 changes: 10 additions & 2 deletions charts/discoveryfinder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ helm install discoveryfinder -n discovery charts/discoveryfinder
## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
|-----|------|-------|-------------|
| discoveryfinder.authentication | bool | `true` | |
| discoveryfinder.containerPort | int | `4243` | |
| discoveryfinder.dataSource.driverClassName | string | `"org.postgresql.Driver"` | |
Expand Down Expand Up @@ -57,9 +57,17 @@ helm install discoveryfinder -n discovery charts/discoveryfinder
| discoveryfinder.service.port | int | `8080` | |
| discoveryfinder.service.type | string | `"ClusterIP"` | |
| enablePostgres | bool | `true` | |
| discoveryfinder.livenessProbe.initialDelaySeconds | int | `100` | |
| discoveryfinder.livenessProbe.failureThreshold | int | `3` | |
| discoveryfinder.livenessProbe.periodSeconds | int | `3` | |
| discoveryfinder.readinessProbe.initialDelaySeconds | int | `100` | |
| discoveryfinder.readinessProbe.failureThreshold | int | `3` | |
| discoveryfinder.readinessProbe.periodSeconds | int | `3` | |
| postgresql.auth.database | string | `"discoveryfinder"` | |
| postgresql.auth.password | string | `"password"` | |
| postgresql.auth.password | string | `` | |
| postgresql.auth.username | string | `"catenax"` | |
| postgresql.auth.existingSecret | string | `"secret-discoveryfinder-postgres-init"` | |

| postgresql.primary.persistence.enabled | bool | `true` | |
| postgresql.primary.persistence.size | string | `"50Gi"` | |
| postgresql.service.ports.postgresql | int | `5432` | |
Expand Down
48 changes: 48 additions & 0 deletions charts/discoveryfinder/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "df.name" -}}
{{- 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 "df.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 "df.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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


{{- define "df.selectorLabels" -}}
app.kubernetes.io/name: {{ include "df.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
28 changes: 14 additions & 14 deletions charts/discoveryfinder/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
#
# SPDX-License-Identifier: Apache-2.0
###############################################################
{{- $deployment_name := printf "cx-%s" .Release.Name }}
{{- $sec_name := printf "%s-sec" $deployment_name }}
{{- $svc_name := printf "%s-svc" $deployment_name }}

apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $deployment_name }}
name: {{ include "df.fullname" . }}
labels:
{{- include "df.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.discoveryfinder.replicaCount }}
selector:
matchLabels:
app: {{ $deployment_name }}
{{- include "df.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
app: {{ $deployment_name }}
{{- include "df.selectorLabels" . | nindent 8 }}
spec:
securityContext:
runAsUser: 100
Expand All @@ -40,7 +40,7 @@ spec:
configMap:
name: properties-discoveryfinder
containers:
- name: {{ $deployment_name }}
- name: {{ .Chart.Name }}
image: {{ .Values.discoveryfinder.image.registry }}/{{ .Values.discoveryfinder.image.repository }}:{{ .Values.discoveryfinder.image.version | default .Chart.AppVersion }}
imagePullPolicy: {{ .Values.discoveryfinder.image.imagePullPolicy }}
volumeMounts:
Expand All @@ -60,19 +60,19 @@ spec:
httpGet:
path: /actuator/health/liveness
port: {{ .Values.discoveryfinder.containerPort }}
initialDelaySeconds: 100
periodSeconds: 3
failureThreshold: 3
initialDelaySeconds: {{ .Values.discoveryfinder.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.discoveryfinder.livenessProbe.periodSeconds }}
failureThreshold: {{ .Values.discoveryfinder.livenessProbe.failureThreshold }}
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: {{ .Values.discoveryfinder.containerPort }}
initialDelaySeconds: 60
periodSeconds: 3
failureThreshold: 3
initialDelaySeconds: {{ .Values.discoveryfinder.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.discoveryfinder.readinessProbe.periodSeconds }}
failureThreshold: {{ .Values.discoveryfinder.readinessProbe.failureThreshold }}
envFrom:
- secretRef:
name: {{ $sec_name }}
name: {{ include "df.fullname" . }}
- secretRef:
name: {{ .Values.postgresql.auth.existingSecret }}
resources:
Expand Down
43 changes: 20 additions & 23 deletions charts/discoveryfinder/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
{{- if .Values.discoveryfinder.ingress.enabled }}
# Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH
# Copyright (c) 2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
###############################################################
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
###############################################################

{{- if .Values.discoveryfinder.ingress.enabled }}
{{- $deployment_name := printf "cx-%s" .Release.Name }}
{{- $svc_name := printf "%s-svc" $deployment_name }}
{{- $ingr_name := printf "%s-ingr" $deployment_name }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $ingr_name }}
name: {{ include "df.fullname" . }}
annotations:
{{ .Values.discoveryfinder.ingress.annotations | toYaml | indent 4 }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- include "df.labels" . | nindent 4 }}
spec:
ingressClassName: {{ .Values.discoveryfinder.ingress.className }}
{{- if .Values.discoveryfinder.ingress.tls }}
Expand All @@ -45,7 +42,7 @@ spec:
pathType: Prefix
backend:
service:
name: {{ $svc_name }}
name: {{ include "df.fullname" . }}
port:
number: {{ .Values.discoveryfinder.service.port }}
{{- end }}
3 changes: 2 additions & 1 deletion charts/discoveryfinder/templates/postgres-init.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if .Values.enablePostgres }}
# Copyright (c) 2024 Robert Bosch Manufacturing Solutions GmbH
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
Expand All @@ -16,7 +17,7 @@
#
# SPDX-License-Identifier: Apache-2.0
###############################################################
{{- if .Values.enablePostgres }}

apiVersion: v1
kind: Secret
metadata:
Expand Down
4 changes: 1 addition & 3 deletions charts/discoveryfinder/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
# SPDX-License-Identifier: Apache-2.0
###############################################################

{{- $deployment_name := printf "cx-%s" .Release.Name }}
{{- $sec_name := printf "%s-sec" $deployment_name }}
apiVersion: v1
kind: Secret
metadata:
name: {{ $sec_name }}
name: {{ include "df.fullname" . }}
type: Opaque
data:
# If postgres enabled the environment values will be used from postgres-init.yaml
Expand Down
8 changes: 3 additions & 5 deletions charts/discoveryfinder/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@
# SPDX-License-Identifier: Apache-2.0
###############################################################

{{- $deployment_name := printf "cx-%s" .Release.Name }}
{{- $svc_name := printf "%s-svc" $deployment_name }}
apiVersion: v1
kind: Service
metadata:
name: {{ $svc_name }}
name: {{ include "df.fullname" . }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- include "df.labels" . | nindent 4 }}
spec:
type: {{ .Values.discoveryfinder.service.type }}
ports:
- port: {{ .Values.discoveryfinder.service.port }}
targetPort: {{ .Values.discoveryfinder.containerPort }}
selector:
app: {{ $deployment_name }}
{{- include "df.selectorLabels" . | nindent 4 }}
11 changes: 10 additions & 1 deletion charts/discoveryfinder/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
#
# SPDX-License-Identifier: Apache-2.0
###############################################################

nameOverride:
fullnameOverride:
enablePostgres: true

discoveryfinder:
Expand Down Expand Up @@ -45,6 +46,14 @@ discoveryfinder:
service:
port: 8080
type: ClusterIP
livenessProbe:
failureThreshold: 3
periodSeconds: 3
initialDelaySeconds: 100
readinessProbe:
failureThreshold: 3
periodSeconds: 3
initialDelaySeconds: 100
dataSource:
driverClassName: org.postgresql.Driver
sqlInitPlatform: pg
Expand Down

0 comments on commit fdb82ab

Please sign in to comment.