Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit c0d4b787 authored by Marco Amoia's avatar Marco Amoia
Browse files

Merge branch 'release/0.0.4-RC' into 'main'

0.0.4-RC

See merge request !29
parents 1fb17fac 7374154c
Branches
Tags v0.0.4
2 merge requests!74Feature/align,!290.0.4-RC
Pipeline #204242 passed
Showing
with 603 additions and 1 deletion
* @wouldgo @n00frjum @n00frn4c @n00g35o4 @n00g2z1l @n00g2zq2
\ No newline at end of file
* @simpl/simpl-open/Development/IAA
\ No newline at end of file
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
apiVersion: v2
name: onboarding
description: A Helm chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: ${PROJECT_RELEASE_VERSION}
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: ${PROJECT_RELEASE_VERSION}
# Environment Variables Configuration
This document outlines the environment variables required to configure SSL, EJBCA, and certificate management for the application. These variables are essential for securing communications and managing certificates within a Kubernetes environment.
You can override this configuration changing the values.yaml
## Overview
The environment variables listed below are used to define the connection details, credentials, and file locations necessary for integrating with EJBCA (Enterprise Java Beans Certificate Authority) and managing SSL certificates. The values are templated using Helm, allowing for customization based on the configuration provided in the Helm chart.
## Environment Variables
### Database Configuration
- **PostgreSQL**
- `SPRING_DATASOURCE_URL`: The JDBC URL for connecting to the PostgreSQL database.
- Format: `jdbc:postgresql://postgresql.<namespace>.svc.cluster.local:5432/onboarding`
- `SPRING_DATASOURCE_USERNAME`: The username for the PostgreSQL database.
- `SPRING_DATASOURCE_PASSWORD`: The password for the PostgreSQL database.
### EJBCA Configuration
- **EJBCA URL and Profile**
- `EJBCA_URL`: The URL for the EJBCA enrollment service.
- Value is derived from `ejbca.enrollConfig.url` specified in the Helm values.
- `EJBCA_PROFILE_NAME`: The profile name to be used when enrolling with EJBCA.
- Value is derived from `ejbca.enrollConfig.profileName` specified in the Helm values.
- `EJBCA_END_ENTITY_NAME`: The name of the end entity in EJBCA.
- Value is derived from `ejbca.enrollConfig.endEntityName` specified in the Helm values.
- `EJBCA_CA_NAME`: The name of the Certificate Authority (CA) in EJBCA.
- Value is derived from `ejbca.enrollConfig.caName` specified in the Helm values.
### SSL Configuration
- **Keystore and Truststore**
- `SPRING_SSL_BUNDLE_JKS_EJBCA_KEYSTORE_PASSWORD`: The password for the EJBCA keystore.
- Value is derived from `ejbca.keystore.password` specified in the Helm values.
- `SPRING_SSL_BUNDLE_JKS_EJBCA_TRUSTSTORE_PASSWORD`: The password for the EJBCA truststore.
- Value is derived from `ejbca.truststore.password` specified in the Helm values.
- `SPRING_SSL_BUNDLE_JKS_EJBCA_KEY_ALIAS`: The alias for the key within the keystore.
- Default value: `superadmin`
- `SPRING_SSL_BUNDLE_JKS_EJBCA_KEYSTORE_LOCATION`: The file path for the EJBCA keystore.
- Default path: `/etc/certs/keystore.p12`
- `SPRING_SSL_BUNDLE_JKS_EJBCA_TRUSTSTORE_LOCATION`: The file path for the EJBCA truststore.
- Default path: `/etc/certs/truststore.jks`
### Certificate Configuration
- `SIMPL_CERTIFICATE_SAN`: The Subject Alternative Name (SAN) for the certificate.
- Value is derived from `global.hostTls` specified in the Helm values.
- `SIMPL_CERTIFICATE_PASSWORD`: The password for the certificate used by the service.
- Value is derived from `global.keystore.password` specified in the Helm values.
## Usage
To use these environment variables, define them in your Kubernetes manifests or Helm chart. The values for URLs, passwords, and file paths will be dynamically generated based on the configuration provided in the `values.yaml`.
### Example `values.yaml`
```yaml
global:
hostTls: "your-host-tls"
keystore:
password: "your-keystore-password"
ejbca:
enrollConfig:
url: "https://ejbca.example.com/enroll"
profileName: "your-profile-name"
endEntityName: "your-end-entity-name"
caName: "your-ca-name"
keystore:
password: "your-keystore-password"
truststore:
password: "your-truststore-password"
File added
File added
File added
File added
File added
File added
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "microservices.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "microservices.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "microservices.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "microservices.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
{{/*
Expand the name of the chart.
*/}}
{{- define "microservices.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "microservices.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 "microservices.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "microservices.labels" -}}
helm.sh/chart: {{ include "microservices.chart" . }}
{{ include "microservices.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "microservices.selectorLabels" -}}
app.kubernetes.io/name: {{ include "microservices.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "microservices.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "microservices.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
{{- define "checkEjbcaCredentials" -}}
{{- $ejbcaFilesPath := printf "files/%s/" .Values.ejbca.credentialsFolder -}}
{{- $credential := printf "%s%s" $ejbcaFilesPath . -}}
{{- $content := .Files.Get $credential -}}
{{- if eq $content "" -}}
{{- fail (printf "file not found: %s" $credential) -}}
{{- end -}}
{{- end -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Chart.Name }}-configmap
data:
{{- with .Values.env }}
{{- toYaml . | nindent 2 }}
{{- end }}
SPRING_SSL_BUNDLE_JKS_EJBCA_KEYSTORE_PASSWORD: "{{ .Values.ejbca.keystore.password }}"
EJBCA_URL: "{{ .Values.ejbca.enrollConfig.url }}"
EJBCA_PROFILE_NAME: "{{ .Values.ejbca.enrollConfig.profileName }}"
EJBCA_END_ENTITY_NAME: "{{ .Values.ejbca.enrollConfig.endEntityName }}"
EJBCA_CA_NAME: "{{ .Values.ejbca.enrollConfig.caName }}"
SPRING_SSL_BUNDLE_JKS_EJBCA_TRUSTSTORE_PASSWORD: "{{ .Values.ejbca.truststore.password }}"
SPRING_SSL_BUNDLE_JKS_EJBCA_KEY_ALIAS: "superadmin"
SPRING_SSL_BUNDLE_JKS_EJBCA_KEYSTORE_LOCATION: "/etc/certs/keystore.p12"
SPRING_SSL_BUNDLE_JKS_EJBCA_TRUSTSTORE_LOCATION: "/etc/certs/truststore.jks"
SIMPL_CERTIFICATE_SAN: "{{ .Values.global.hostTls }}"
SIMPL_CERTIFICATE_PASSWORD: "{{ .Values.global.keystore.password }}"
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Chart.Name }}
labels:
{{- include "microservices.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "microservices.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "microservices.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ .Chart.Name }}-svc-account
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
{{- with .Values.envFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- $ejbcaFilesPath := printf "files/%s/" .Values.ejbca.credentialsFolder -}}
{{- $keystore := printf "%s%s" $ejbcaFilesPath .Values.ejbca.keystore.name -}}
{{- $truststore := printf "%s%s" $ejbcaFilesPath .Values.ejbca.truststore.name -}}
{{- $keystoreContent := .Files.Get $keystore -}}
{{- $truststoreContent := .Files.Get $truststore -}}
{{- if eq $keystoreContent "" -}}
{{- fail (printf "Keystore file not found: %s" $keystore) -}}
{{- end -}}
{{- if eq $truststoreContent "" -}}
{{- fail (printf "Truststore file not found: %s" $truststore) -}}
{{- end -}}
apiVersion: v1
kind: Secret
metadata:
name: ejbca-rest-api-secret
namespace: {{ .Release.Namespace }}
type: Opaque
data:
client-cert: {{ $keystoreContent | b64enc }}
ca-truststore: {{ $truststoreContent | b64enc }}
\ No newline at end of file
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ .Chart.Name }}-hpa
labels:
{{- include "microservices.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "microservices.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "microservices.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ .Chart.Name }}-ingress
labels:
{{- include "microservices.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
apiVersion: v1
kind: Service
metadata:
name: {{ .Chart.Name }}
labels:
{{- include "microservices.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "microservices.selectorLabels" . | nindent 4 }}
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Chart.Name }}-svc-account
labels:
{{- include "microservices.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
replicaCount: 1
image:
repository: ${CI_REGISTRY_IMAGE}
pullPolicy: Always
tag: ${PROJECT_RELEASE_VERSION}
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# Automatically mount a ServiceAccount's API credentials?
automount: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
podAnnotations: {}
podLabels: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
type: ClusterIP
port: 8080
ingress:
enabled: false
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources:
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
limits:
cpu: 500m
memory: 1Gi
requests:
cpu: 500m
memory: 1Gi
livenessProbe:
httpGet:
path: "/actuator/health/liveness"
port: http
initialDelaySeconds: 120
periodSeconds: 5
failureThreshold: 10
readinessProbe:
httpGet:
path: "/actuator/health/readiness"
port: http
initialDelaySeconds: 120
periodSeconds: 5
failureThreshold: 10
autoscaling:
enabled: true
minReplicas: 1
maxReplicas: 1
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
# Additional volumes on the output Deployment definition.
volumes:
- name: ejbca-rest-api-client-cert
secret:
secretName: ejbca-rest-api-secret
items:
- key: client-cert
path: keystore.p12
- name: ejbca-rest-api-truststore
secret:
secretName: ejbca-rest-api-secret
items:
- key: ca-truststore
path: truststore.jks
# - name: foo
# secret:
# secretName: mysecret
# optional: false
# Additional volumeMounts on the output Deployment definition.
volumeMounts:
- name: ejbca-rest-api-client-cert
mountPath: "/etc/certs/keystore.p12"
subPath: "keystore.p12"
readOnly: true
- name: ejbca-rest-api-truststore
mountPath: "/etc/certs/truststore.jks"
subPath: "truststore.jks"
readOnly: true
envFrom:
- configMapRef:
name: onboarding-configmap
env:
SPRING_DATASOURCE_URL: "jdbc:postgresql://postgresql.{{ .Release.Namespace }}.svc.cluster.local:5432/onboarding"
SPRING_DATASOURCE_USERNAME: "onboarding"
SPRING_DATASOURCE_PASSWORD: "onboarding"
nodeSelector: {}
tolerations: []
affinity: {}
ejbca:
credentialsFolder: aruba
keystore:
name: keystore.p12
password: "THc77QkT6kf1m2O46DYi9pjZ"
truststore:
name: truststore.jks
password: "ManagementCA"
enrollConfig:
url: "https://ejbca-community-helm.{{ .Release.Namespace }}.svc.cluster.local:30443"
profileName: "Onboarding TLS Profile"
endEntityName: "Onboarding TLS Profile"
caName: "OnBoardingCA"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment