Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ac54efa
feat: add GitHub Actions workflow for linting and testing Helm charts
gomezbc Apr 8, 2025
c5d162d
fix: comment out frontend image build step in Helm workflow
gomezbc Apr 8, 2025
3511c4c
fix: correct template reference for external database secret creation
gomezbc Apr 8, 2025
813a640
fix: update Helm test workflow to use 'testing' tags and set target b…
gomezbc Apr 8, 2025
e88cf88
fix: database secret creation logic
gomezbc Apr 8, 2025
cd2185c
Merge branch 'main' of https://github.com/eclipse-tractusx/industry-c…
gomezbc Apr 9, 2025
fb84563
fix: update Helm test workflow to correctly build frontend image
gomezbc Apr 9, 2025
b413b0a
fix: improve Helm test workflow formatting and structure
gomezbc Apr 9, 2025
30eae69
chore: update package-lock.json
gomezbc Apr 9, 2025
948486b
fix: update frontend service to use port 8080 instead of priviliged p…
gomezbc Apr 9, 2025
8456abd
fix: update backend and frontend service ports to use new port config…
gomezbc Apr 9, 2025
0e150e8
fix: include Dockerfile in Helm test workflow triggers
gomezbc Apr 9, 2025
7af3ab7
fix: comment out unused upgrade_from parameter in Helm test workflow
gomezbc Apr 9, 2025
fd17247
fix: add license header to Helm test workflow file
gomezbc Apr 9, 2025
d404cfb
fix: set action versions to commit tags in Helm test workflow
gomezbc Apr 9, 2025
2f72b32
fix: update Helm chart version to 0.1.1 and fix workflow triggers (on…
gomezbc Apr 10, 2025
e8637f7
fix: ensure newline at end of files and removed trailling spaces in H…
gomezbc Apr 10, 2025
0df816d
fix: add Helm repos setup step in the test workflow
gomezbc Apr 10, 2025
dd2c604
Merge branch 'main' into main
gomezbc Apr 24, 2025
d20f566
chore: update DEPENDENCIES_ICHUB-FRONTEND file
gomezbc Apr 25, 2025
ee20baf
fix: update Docker build-push-action to specific version v6.16.0 in h…
gomezbc Apr 28, 2025
38e79b2
Merge branch 'main' into main
gomezbc Apr 29, 2025
f95a763
Update .github/workflows/helm-test.yaml
gomezbc Apr 29, 2025
facbc1a
Update .github/workflows/helm-test.yaml
gomezbc Apr 29, 2025
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
104 changes: 104 additions & 0 deletions .github/workflows/helm-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Lint and Test Charts

on:
push:
paths:
- "charts/industry-core-hub/**"
- ".github/workflows/helm-test.yaml"
- "**/Dockerfile"
branches: main
pull_request:
paths:
- "charts/industry-core-hub/**"
- ".github/workflows/helm-test.yaml"
- "**/Dockerfile"
branches: main
workflow_dispatch:
inputs:
node_image:
description: "kindest/node image for k8s kind cluster"
# k8s version from 3.1 release as default
default: "kindest/node:v1.27.3"
required: false
type: string
# upgrade_from:
# description: "chart version to upgrade from"
# # chart version from 3.1 release as default
# default: "x.x.x"
# required: false
# type: string
helm_version:
description: "helm version to test (default = latest)"
default: "latest"
required: false
type: string

jobs:
lint-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Kubernetes KinD Cluster
uses: container-tools/kind-action@v1
with:
# upgrade version, default (v0.17.0) uses node image v1.21.1 and doesn't work with more recent node image versions
version: v0.20.0
# default value for event_name != workflow_dispatch
node_image: ${{ github.event.inputs.node_image || 'kindest/node:v1.27.3' }}

- name: Build backend image
uses: docker/build-push-action@v3
with:
context: "{{defaultContext}}:ichub-backend"
push: true
tags: kind-registry:5000/ichub-backend:testing

- name: Build frontend image
uses: docker/build-push-action@v3
with:
context: "{{defaultContext}}:ichub-frontend"
push: true
tags: kind-registry:5000/ichub-frontend:testing

- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: ${{ github.event.inputs.helm_version || 'latest' }}

- uses: actions/setup-python@v4
with:
python-version: "3.9"
check-latest: true
- name: Set up chart-testing
uses: helm/chart-testing-action@v2.3.1

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> $GITHUB_OUTPUT
fi

- name: Run chart-testing (lint)
run: ct lint --validate-maintainers=false --target-branch ${{ github.event.repository.default_branch }}

- name: Run chart-testing (install)
run: ct install --charts charts/industry-core-hub --target-branch ${{ github.event.repository.default_branch }} --helm-extra-set-args "--set backend.image.repository=kind-registry:5000/ichub-backend --set backend.image.tag=testing --set frontend.image.repository=kind-registry:5000/ichub-frontend --set frontend.image.tag=testing"
if: github.event_name != 'pull_request' || steps.list-changed.outputs.changed == 'true'

# Upgrade the released chart version with the locally available chart
# default value for event_name != workflow_dispatch
# industry-core-hub: we don't have yet a released chart
#- name: Run helm upgrade
# run: |
# helm repo add bitnami https://charts.bitnami.com/bitnami
# helm repo add tractusx-dev https://eclipse-tractusx.github.io/charts/dev
# helm install [NAME] tractusx-dev/[CHART] --version ${{ github.event.inputs.upgrade_from || 'x.x.x' }}
# helm dependency update charts/[CHART]
# helm upgrade [NAME] charts/[CHART]
# if: github.event_name != 'pull_request' || steps.list-changed.outputs.changed == 'true'
9 changes: 0 additions & 9 deletions charts/industry-core-hub/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,6 @@ Get the database secret key
{{- end -}}
{{- end -}}

{{/*
Return true if a secret object should be created for external database
*/}}
{{- define "industry-core-hub.externalDatabase.createSecret" -}}
{{- if and (not .Values.postgresql.enabled) (not .Values.externalDatabase.existingSecret) }}
{{- true -}}
{{- end -}}
{{- end -}}

{{/*
Return the postgresql URL
*/}}
Expand Down
8 changes: 4 additions & 4 deletions charts/industry-core-hub/templates/deployment-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/}}
{{ if .Values.backend.enabled }}
apiVersion: apps/v1
kind: Deployment

Check warning on line 23 in charts/industry-core-hub/templates/deployment-backend.yaml

View workflow job for this annotation

GitHub Actions / Analyze

[MEDIUM] Using Unrecommended Namespace

Namespaces like 'default', 'kube-system' or 'kube-public' should not be used
metadata:
name: {{ include "industry-core-hub.fullname.backend" . }}
labels:
Expand Down Expand Up @@ -59,7 +59,7 @@
imagePullPolicy: {{ .Values.backend.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.backend.service.port }}
containerPort: {{ .Values.backend.service.portContainer }}
protocol: TCP
env:
- name: DATABASE__HOST
Expand All @@ -73,13 +73,13 @@
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "industry-core-hub.postgresql.secretName" . }}

Check warning on line 76 in charts/industry-core-hub/templates/deployment-backend.yaml

View workflow job for this annotation

GitHub Actions / Analyze

[MEDIUM] Readiness Probe Is Not Configured

Check if Readiness Probe is not configured.

Check warning on line 76 in charts/industry-core-hub/templates/deployment-backend.yaml

View workflow job for this annotation

GitHub Actions / Analyze

[LOW] Image Pull Policy Of The Container Is Not Set To Always

Image Pull Policy of the container must be defined and set to Always

Check warning on line 76 in charts/industry-core-hub/templates/deployment-backend.yaml

View workflow job for this annotation

GitHub Actions / Analyze

[LOW] Image Without Digest

Images should be specified together with their digests to ensure integrity
key: {{ include "industry-core-hub.postgresql.ichub.secretKey" . }}
{{- if .Values.backend.healthChecks.startup.enabled }}
startupProbe:
httpGet:
path: {{ .Values.backend.healthChecks.startup.path }}
port: {{ .Values.backend.service.port }}
port: {{ .Values.backend.service.portContainer }}
scheme: HTTP
initialDelaySeconds: {{ .Values.startupProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.startupProbe.periodSeconds }}
Expand All @@ -91,7 +91,7 @@
livenessProbe:
httpGet:
path: {{ .Values.backend.healthChecks.liveness.path }}
port: {{ .Values.backend.service.port }}
port: {{ .Values.backend.service.portContainer }}
scheme: HTTP
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
Expand All @@ -103,7 +103,7 @@
readinessProbe:
httpGet:
path: {{ .Values.backend.healthChecks.readiness.path }}
port: {{ .Values.backend.service.port }}
port: {{ .Values.backend.service.portContainer }}
scheme: HTTP
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
Expand Down
8 changes: 4 additions & 4 deletions charts/industry-core-hub/templates/deployment-frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "industry-core-hub.fullname.frontend" . }}

Check warning on line 26 in charts/industry-core-hub/templates/deployment-frontend.yaml

View workflow job for this annotation

GitHub Actions / Analyze

[MEDIUM] Using Unrecommended Namespace

Namespaces like 'default', 'kube-system' or 'kube-public' should not be used
labels:
{{- include "industry-core-hub.labels" . | nindent 4 }}
spec:
Expand Down Expand Up @@ -57,10 +57,10 @@
securityContext:
{{- toYaml .Values.frontend.securityContext | nindent 12 }}
image: "{{ .Values.frontend.image.repository }}:{{ .Values.frontend.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.frontend.image.pullPolicy }}

Check warning on line 60 in charts/industry-core-hub/templates/deployment-frontend.yaml

View workflow job for this annotation

GitHub Actions / Analyze

[LOW] Image Pull Policy Of The Container Is Not Set To Always

Image Pull Policy of the container must be defined and set to Always
ports:
- name: http
containerPort: {{ .Values.frontend.service.port }}
containerPort: {{ .Values.frontend.service.portContainer }}
protocol: TCP
env:
- name: ICHUB_BACKEND_URL
Expand All @@ -69,7 +69,7 @@
startupProbe:
httpGet:
path: {{ .Values.frontend.healthChecks.startup.path }}
port: {{ .Values.frontend.service.port }}
port: {{ .Values.frontend.service.portContainer }}
scheme: HTTP
initialDelaySeconds: {{ .Values.startupProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.startupProbe.periodSeconds }}
Expand All @@ -81,7 +81,7 @@
livenessProbe:
httpGet:
path: {{ .Values.frontend.healthChecks.liveness.path }}
port: {{ .Values.frontend.service.port }}
port: {{ .Values.frontend.service.portContainer }}
scheme: HTTP
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
Expand All @@ -93,7 +93,7 @@
readinessProbe:
httpGet:
path: {{ .Values.frontend.healthChecks.readiness.path }}
port: {{ .Values.frontend.service.port }}
port: {{ .Values.frontend.service.portContainer }}
scheme: HTTP
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* SPDX-License-Identifier: Apache-2.0
*/}}

{{- if and .Values.backend.enabled (not .Values.postgresql.enabled) (include "industry-core-hub.industry-core-hub.externalDatabase.createSecret" .) -}}
{{- if not .Values.postgresql.enabled -}}
apiVersion: v1
kind: Secret
metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* SPDX-License-Identifier: Apache-2.0
*/}}

{{- if and .Values.backend.enabled .Values.postgresql.enabled -}}
{{- if .Values.postgresql.enabled -}}
apiVersion: v1
kind: Secret
metadata:
Expand Down
4 changes: 2 additions & 2 deletions charts/industry-core-hub/templates/service-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
{{ if .Values.backend.enabled }}
apiVersion: v1
kind: Service
metadata:

Check warning on line 25 in charts/industry-core-hub/templates/service-backend.yaml

View workflow job for this annotation

GitHub Actions / Analyze

[MEDIUM] Using Unrecommended Namespace

Namespaces like 'default', 'kube-system' or 'kube-public' should not be used
name: {{ include "industry-core-hub.fullname.backend" . }}
labels: {{ include "industry-core-hub.labels" . | nindent 4 }}
spec:
type: {{ .Values.backend.service.type }}
ports:
- port: {{ .Values.backend.service.port }}
targetPort: {{ .Values.backend.service.targetPort }}
- port: {{ .Values.backend.service.portService }}
targetPort: {{ .Values.backend.service.portContainer }}
protocol: TCP
name: http
selector: {{ include "industry-core-hub.frontend.selectorLabels" . | nindent 4 }}
Expand Down
4 changes: 2 additions & 2 deletions charts/industry-core-hub/templates/service-frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
{{ if .Values.frontend.enabled }}
apiVersion: v1
kind: Service
metadata:

Check warning on line 25 in charts/industry-core-hub/templates/service-frontend.yaml

View workflow job for this annotation

GitHub Actions / Analyze

[MEDIUM] Using Unrecommended Namespace

Namespaces like 'default', 'kube-system' or 'kube-public' should not be used
name: {{ include "industry-core-hub.fullname.frontend" . }}
labels: {{ include "industry-core-hub.labels" . | nindent 4 }}
spec:
type: {{ .Values.frontend.service.type }}
ports:
- port: {{ .Values.frontend.service.port }}
targetPort: {{ .Values.frontend.service.targetPort }}
- port: {{ .Values.frontend.service.portService }}
targetPort: {{ .Values.frontend.service.portContainer }}
protocol: TCP
name: http
selector: {{ include "industry-core-hub.frontend.selectorLabels" . | nindent 4 }}
Expand Down
10 changes: 5 additions & 5 deletions charts/industry-core-hub/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ replicaCount: 1

# -- Backend configuration
backend:
enabled: false
enabled: true
name: "industry-core-hub-backend"
image:
repository: "ichub-backend"
Expand All @@ -42,8 +42,8 @@ backend:
service:
# -- [Service type](https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types) to expose the running application on a set of Pods as a network service
type: ClusterIP
port: 80
targetPort: 8000
portService: 8000
portContainer: 8000

podAnnotations: {}

Expand Down Expand Up @@ -175,8 +175,8 @@ frontend:
service:
# -- [Service type](https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types) to expose the running application on a set of Pods as a network service
type: ClusterIP
port: 80
targetPort: 8000
portService: 8080
portContainer: 8080

podAnnotations: {}

Expand Down
6 changes: 3 additions & 3 deletions ichub-frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ RUN chmod +x /docker-entrypoint.d/00-inject-dynamic-env.sh \
# Change to nginx user
USER 101

# Expose port 80
EXPOSE 80
# Expose port 8080
EXPOSE 8080

# Healthcheck to verify Nginx is running
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD wget --spider -q http://localhost || exit 1
CMD wget --spider -q http://localhost:8080 || exit 1

# Start Nginx
CMD ["nginx", "-g", "daemon off;"]
6 changes: 3 additions & 3 deletions ichub-frontend/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#################################################################################

server {
listen 80;
server_name localhost;

listen 8080;
server_name _;
location / {
root /usr/share/nginx/html;
index index.html;
Expand Down
Loading
Loading