Skip to content

Commit

Permalink
Merge pull request #251 from bci-oss/feature/improve-helm-chart
Browse files Browse the repository at this point in the history
improve helm chart
  • Loading branch information
tunacicek authored Mar 7, 2024
2 parents b18695b + 86e85c2 commit f95b199
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 123 deletions.
2 changes: 1 addition & 1 deletion charts/semantic-hub/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-semantic-hub

type: application
version: 0.2.1-RC1
version: 0.2.1-RC2
appVersion: 0.3.1-RC1
dependencies:
- repository: https://charts.bitnami.com/bitnami
Expand Down
48 changes: 48 additions & 0 deletions charts/semantic-hub/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "hub.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 "hub.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 "hub.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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


{{- define "hub.selectorLabels" -}}
app.kubernetes.io/name: {{ include "hub.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
51 changes: 25 additions & 26 deletions charts/semantic-hub/templates/graphdb/graphdb-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,44 @@
###############################################################
# Copyright (c) 2021, 2023 Robert Bosch Manufacturing Solutions GmbH
# Copyright (c) 2021, 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
###############################################################
# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
# Copyright (c) 2021 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
###############################################################

{{- if and (.Values.graphdb.enabled) (not .Values.hub.embeddedTripleStore) }}
{{- $deployment_name := printf "cx-%s-graphdb" .Release.Name }}
{{- $sec_name := printf "%s-sec" $deployment_name }}
{{- $pvc_name := printf "%s-pvc" $deployment_name }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $deployment_name }}
name: {{ include "hub.fullname" .}}-graphdb
labels:
{{- include "hub.labels" . | nindent 4 }}-graphdb
spec:
replicas: {{ .Values.graphdb.replicaCount }}
selector:
matchLabels:
app: {{ $deployment_name }}
{{- include "hub.selectorLabels" . | nindent 6 }}-graphdb
template:
metadata:
labels:
app: {{ $deployment_name }}
{{- include "hub.selectorLabels" . | nindent 8 }}-graphdb
spec:
securityContext:
runAsUser: 1000
containers:
- name: {{ $deployment_name }}
- name: {{ include "hub.fullname" .}}-graphdb
image: {{ .Values.graphdb.image }}
imagePullPolicy: {{ .Values.graphdb.imagePullPolicy }}
securityContext:
Expand All @@ -64,5 +63,5 @@ spec:
volumes:
- name: graphdbdata
persistentVolumeClaim:
claimName: {{ $pvc_name }}
claimName: {{ include "hub.fullname" .}}-graphdb
{{- end -}}
40 changes: 19 additions & 21 deletions charts/semantic-hub/templates/graphdb/graphdb-pvc.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
###############################################################
# Copyright (c) 2021, 2023 Robert Bosch Manufacturing Solutions GmbH
# Copyright (c) 2021, 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
###############################################################
# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
# Copyright (c) 2021 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
###############################################################

{{- if and (.Values.graphdb.enabled) (not .Values.hub.embeddedTripleStore) }}
{{- $deployment_name := printf "cx-%s-graphdb" .Release.Name }}
{{- $pvc_name := printf "%s-pvc" $deployment_name }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ $pvc_name }}
name: {{ include "hub.fullname" .}}-graphdb
spec:
storageClassName: {{ .Values.graphdb.storageClassName }}
accessModes:
Expand Down
42 changes: 20 additions & 22 deletions charts/semantic-hub/templates/graphdb/graphdb-service.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
###############################################################
# Copyright (c) 2021, 2023 Robert Bosch Manufacturing Solutions GmbH
# Copyright (c) 2021, 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
###############################################################
# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
# Copyright (c) 2021 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
###############################################################

{{- if and (.Values.graphdb.enabled) (not .Values.hub.embeddedTripleStore) }}
{{- $deployment_name := printf "cx-%s-graphdb" .Release.Name }}
{{- $service_name := printf "cx-%s-graphdb-svc" .Release.Name }}
apiVersion: v1
kind: Service
metadata:
name: {{ $service_name }}
name: {{ include "hub.fullname" .}}-graphdb
spec:
type: ClusterIP
ports:
- port: {{ .Values.graphdb.service.port }}
targetPort: {{ .Values.graphdb.containerPort }}
selector:
app: {{ $deployment_name }}
{{- include "hub.selectorLabels" . | nindent 4}}-graphdb
{{- end -}}
20 changes: 10 additions & 10 deletions charts/semantic-hub/templates/hub/hub-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###############################################################
# Copyright (c) 2021, 2023 Robert Bosch Manufacturing Solutions GmbH
# Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
# Copyright (c) 2021 2023 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
Expand All @@ -25,23 +25,23 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $deployment_name }}
name: {{ include "hub.fullname" . }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- include "hub.labels" . | nindent 4 }}
spec:
replicas: {{ default 1 .Values.hub.replicaCount | int }}
selector:
matchLabels:
app: {{ $deployment_name }}
replicas: {{ default 1 .Values.hub.replicaCount | int }}
{{- include "hub.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
app: {{ $deployment_name }}
{{- include "hub.selectorLabels" . | nindent 8 }}
spec:
securityContext:
runAsUser: 100
containers:
- name: {{ $deployment_name }}
- name: {{ .Chart.Name }}
image: {{ .Values.hub.image.registry }}/{{ .Values.hub.image.repository }}:{{ .Values.hub.image.version | default .Chart.AppVersion }}
imagePullPolicy: {{ .Values.hub.imagePullPolicy }}
securityContext:
Expand All @@ -57,7 +57,7 @@ spec:
value: "{{ .Values.hub.embeddedTripleStore }}"
- name: HUB_TRIPLE_STORE_BASE_URL
{{- if .Values.graphdb.enabled }}
value: {{ printf "http://%s:%v" $graphdb_svc_name .Values.graphdb.service.port }}/ds
value: {{ printf "http://%s-graphdb:%v" (include "hub.fullname" .) .Values.graphdb.service.port }}/ds
{{- else }}
value: {{ .Values.hub.graphdbBaseUrl }}
{{- end }}
Expand All @@ -67,7 +67,7 @@ spec:
value: {{ .Values.graphdb.updateEndpoint }}
envFrom:
- secretRef:
name: {{ $sec_name }}
name: {{ include "hub.fullname" . }}
livenessProbe:
httpGet:
path: /actuator/health/liveness
Expand Down
45 changes: 21 additions & 24 deletions charts/semantic-hub/templates/hub/hub-ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
###############################################################
# Copyright (c) 2021, 2023 Robert Bosch Manufacturing Solutions GmbH
# Copyright (c) 2021, 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
###############################################################
# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
# Copyright (c) 2021 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
###############################################################

{{- if .Values.hub.ingress.enabled }}
{{- $deployment_name := printf "cx-%s-hub" .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 "hub.fullname" . }}
annotations:
{{ .Values.hub.ingress.annotations | toYaml | indent 4 }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- include "hub.labels" . | nindent 4 }}
spec:
ingressClassName: {{ .Values.hub.ingress.className }}
{{- if .Values.hub.ingress.tls }}
Expand All @@ -46,7 +43,7 @@ spec:
pathType: Prefix
backend:
service:
name: {{ $svc_name }}
name: {{ include "hub.fullname" . }}
port:
number: {{ .Values.hub.service.port }}
{{- end}}
12 changes: 5 additions & 7 deletions charts/semantic-hub/templates/hub/hub-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###############################################################
# Copyright (c) 2021, 2024 Robert Bosch Manufacturing Solutions GmbH
# Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation
# Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
# Copyright (c) 2021 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
Expand All @@ -18,14 +18,12 @@
# SPDX-License-Identifier: Apache-2.0
###############################################################

{{- $deployment_name := printf "cx-%s-hub" .Release.Name }}
{{- $sec_name := printf "%s-sec" $deployment_name }}
apiVersion: v1
kind: Secret
metadata:
name: {{ $sec_name }}
name: {{ include "hub.fullname" . }}
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- include "hub.labels" . | nindent 4 }}
type: Opaque
data:
{{- if .Values.hub.idpIssuerUri }}
Expand All @@ -40,7 +38,7 @@ data:
{{ if .Values.graphdb.password -}}
HUB_TRIPLE_STORE_PASSWORD: {{ ( .Values.graphdb.password | b64enc) }}
{{ else }}
{{- $secret := (lookup "v1" "Secret" .Release.Namespace $sec_name) }}
{{- $secret := (lookup "v1" "Secret" .Release.Namespace (include "hub.fullname" .)) }}
{{ if $secret -}}
HUB_TRIPLE_STORE_PASSWORD: {{ index $secret.data "HUB_TRIPLE_STORE_PASSWORD" | quote }}
{{- else -}}
Expand Down
Loading

0 comments on commit f95b199

Please sign in to comment.