Commit f20b0687 authored by Kostis Trantzas's avatar Kostis Trantzas
Browse files

Fix HELM chart config and release 1.0.0

- Chart: build SPRING_APPLICATION_JSON with toJson, configurable
  invokers and truststore, image tag from appVersion, ServiceAccount,
  standard pod values, oslcapif helpers
- Fix controller logger name; take osl-controller.version from the pom
- Version 1.0.0

Refs #4
parent bdd3d753
Loading
Loading
Loading
Loading
Loading
+3 −2
Changes for helm/Chart.yaml: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -15,9 +15,10 @@ 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: 0.0.1
version: 1.0.0

# 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.
appVersion: 0.0.1
# It is also the default image tag, so it must match a released (protected tag) image.
appVersion: "1.0.0"
+49 −10
Changes for helm/templates/_helpers.tpl: 49 added lines, 10 removed lines.
Original line number Diff line number Diff line
{{/*
Expand the name of the chart.
*/}}
{{- define "openslice.name" -}}
{{- define "oslcapif.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

@@ -10,7 +10,7 @@ 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 "openslice.fullname" -}}
{{- define "oslcapif.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
@@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name.
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "openslice.chart" -}}
{{- define "oslcapif.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "openslice.labels" -}}
helm.sh/chart: {{ include "openslice.chart" . }}
{{ include "openslice.selectorLabels" . }}
{{- define "oslcapif.labels" -}}
helm.sh/chart: {{ include "oslcapif.chart" . }}
{{ include "oslcapif.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
@@ -45,18 +45,57 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/*
Selector labels
*/}}
{{- define "openslice.selectorLabels" -}}
app.kubernetes.io/name: {{ include "openslice.name" . }}
{{- define "oslcapif.selectorLabels" -}}
app.kubernetes.io/name: {{ include "oslcapif.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "openslice.serviceAccountName" -}}
{{- define "oslcapif.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "openslice.fullname" .) .Values.serviceAccount.name }}
{{- default (include "oslcapif.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Spring Boot configuration passed to the controller as SPRING_APPLICATION_JSON.
Built as a dict and rendered with toJson, so the result is always valid JSON.
*/}}
{{- define "oslcapif.springConfig" -}}
{{- $c := .Values.capif -}}
{{- $cfg := dict
  "logging.level.org.springframework" (.Values.spring.logLevel | default "INFO")
  "logging.level.org.etsi.osl.controllers.capif.invoker" (.Values.logLevel | default "INFO")
  "spring.activemq.brokerUrl" .Values.activemq.brokerUrl
  "spring.activemq.user" .Values.activemq.user
  "spring.activemq.password" .Values.activemq.password
  "capif.REGISTER_HOSTNAME" $c.registerHostname
  "capif.REGISTER_PORT" $c.registerPort
  "capif.USER_NAME" $c.userName
  "capif.USER_PASSWORD" $c.userPassword
  "capif.CAPIF_HOSTNAME" $c.hostname
  "capif.CAPIF_PORT" $c.port
  "capif.ONBOARDING_URL" $c.onboardingUrl
  "capif.ONBOARDING_URL_INVOKER" $c.onboardingUrlInvoker
  "capif.DISCOVER_URL" $c.discoveryUrl
  "capif.ALLOW_INSECURE" $c.allowInsecure
  "capif.TRUSTSTORE_PATH" $c.truststorePath
  "capif.TRUSTSTORE_PASSWORD" $c.truststorePassword
  "capif.authRefreshTokensPeriod" $c.authRefreshTokensPeriod
  "capif.processBearerRefreshTokenPeriod" $c.processBearerRefreshTokenPeriod
-}}
{{- if $c.truststore.existingSecret }}
{{- $_ := set $cfg "capif.TRUSTSTORE_PATH" (printf "%s/%s" $c.truststore.mountPath $c.truststore.key) }}
{{- if $c.truststore.passwordKey }}
{{- $_ := set $cfg "capif.TRUSTSTORE_PASSWORD" "${CAPIF_TRUSTSTORE_PASSWORD}" }}
{{- end }}
{{- end }}
{{- if $c.invokers }}
{{- $_ := set $cfg "capif.invokers" $c.invokers }}
{{- end }}
{{- toJson $cfg }}
{{- end }}
+66 −33
Changes for helm/templates/deployment.yaml: 66 added lines, 33 removed lines.
Original line number Diff line number Diff line
@@ -3,55 +3,88 @@ kind: Deployment
metadata:
  namespace: {{ .Release.Namespace }}
  labels:
    app: {{ include "openslice.fullname" . }}
    app: {{ include "oslcapif.fullname" . }}
    org.etsi.osl.service: oslcapif
    chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    {{- include "openslice.labels" . | nindent 4 }}
  name: {{ include "openslice.fullname" . }}-oslcapif
    {{- include "oslcapif.labels" . | nindent 4 }}
  name: {{ include "oslcapif.fullname" . }}-oslcapif
spec:
  {{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
  {{- end }}
  selector:
    matchLabels:
      app: {{ include "openslice.fullname" . }}
      app: {{ include "oslcapif.fullname" . }}
      org.etsi.osl.service: oslcapif
      {{- include "openslice.selectorLabels" . | nindent 6 }}
      {{- include "oslcapif.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      labels:
        app: {{ include "openslice.fullname" . }}
        app: {{ include "oslcapif.fullname" . }}
        org.etsi.osl.service: oslcapif
        {{- include "openslice.selectorLabels" . | nindent 8 }}
        {{- include "oslcapif.selectorLabels" . | nindent 8 }}
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      serviceAccountName: {{ include "oslcapif.serviceAccountName" . }}
      {{- with .Values.podSecurityContext }}
      securityContext:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      containers:
        - image: "{{ .Values.image.oslcapif.repository }}:{{ .Values.image.oslcapif.tag | default .Chart.AppVersion }}"
          imagePullPolicy: {{ .Values.image.oslcapif.pullPolicy | default "Always" }}
          name: {{ include "openslice.fullname" . }}-oslcapif
          imagePullPolicy: {{ .Values.image.oslcapif.pullPolicy | default "IfNotPresent" }}
          name: {{ include "oslcapif.fullname" . }}-oslcapif
          {{- with .Values.securityContext }}
          securityContext:
            {{- toYaml . | nindent 12 }}
          {{- end }}
          env:
            - name: SPRING_APPLICATION_JSON
              value: >-
                {
                  "logging.level.org.springframework" : "{{ .Values.spring.logLevel | default "INFO" }}",
                  "logging.level.org.etsi.osl.controllers.capif.invoker.*" : "{{ .Values.logLevel | default "INFO" }}"
                  "spring.activemq.brokerUrl": "{{ .Values.activemq.brokerUrl }}", 
                  "spring.activemq.user": "{{ .Values.activemq.user }}", 
                  "spring.activemq.password": "{{ .Values.activemq.password }}",
                  "capif.REGISTER_HOSTNAME": "{{ .Values.capif.registerHostname }}",
                  "capif.REGISTER_PORT": "{{ .Values.capif.registerPort }}",
                  "capif.USER_NAME": "{{ .Values.capif.userName }}",
                  "capif.USER_PASSWORD": "{{ .Values.capif.userPassword }}",
                  "capif.CAPIF_HOSTNAME": "{{ .Values.capif.hostname }}",
                  "capif.CAPIF_PORT": "{{ .Values.capif.port }}",
                  "capif.ONBOARDING_URL": "{{ .Values.capif.onboardingUrl }}",
                  "capif.ONBOARDING_URL_INVOKER": "{{ .Values.capif.onboardingUrlInvoker }}",
                  "capif.DISCOVER_URL": "{{ .Values.capif.discoveryUrl }}",
                  "capif.ALLOW_INSECURE": "{{ .Values.capif.allowInsecure }}",
                  "capif.TRUSTSTORE_PATH": "{{ .Values.capif.TrustorePath }}",
                  "capif.TRUSTSTORE_PASSWORD": "{{ .Values.capif.TrustorePassword }}",
                  "capif.authRefreshTokensPeriod": "{{ .Values.capif.authRefreshTokensPeriod }}",
                  "capif.processBearerRefreshTokenPeriod": "{{ .Values.capif.processBearerRefreshTokenPeriod }}"
                }
              value: {{ include "oslcapif.springConfig" . | toJson }}
            {{- if and .Values.capif.truststore.existingSecret .Values.capif.truststore.passwordKey }}
            - name: CAPIF_TRUSTSTORE_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: {{ .Values.capif.truststore.existingSecret }}
                  key: {{ .Values.capif.truststore.passwordKey }}
            {{- end }}
          {{- with .Values.capif.invokerKeys.existingSecret }}
          envFrom:
            - secretRef:
                name: {{ . }}
          {{- end }}
          {{- if .Values.capif.truststore.existingSecret }}
          volumeMounts:
            - name: truststore
              mountPath: {{ .Values.capif.truststore.mountPath }}
              readOnly: true
          {{- end }}
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
      {{- if .Values.capif.truststore.existingSecret }}
      volumes:
        - name: truststore
          secret:
            secretName: {{ .Values.capif.truststore.existingSecret }}
            items:
              - key: {{ .Values.capif.truststore.key }}
                path: {{ .Values.capif.truststore.key }}
      {{- 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 }}
      restartPolicy: Always
+14 −0
Changes for helm/templates/serviceaccount.yaml: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
  namespace: {{ .Release.Namespace }}
  name: {{ include "oslcapif.serviceAccountName" . }}
  labels:
    {{- include "oslcapif.labels" . | nindent 4 }}
  {{- with .Values.serviceAccount.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
+70 −14
Changes for helm/values.yaml: 70 added lines, 14 removed lines.
Original line number Diff line number Diff line
@@ -5,16 +5,25 @@ replicaCount: 1
image:
  oslcapif:
    repository: labs.etsi.org:5050/osl/code/addons/org.etsi.osl.controllers.capif.invoker
    pullPolicy: Always
    # Overrides the image tag whose default is the chart appVersion.
    tag: "latest"
    pullPolicy: IfNotPresent
    # Image tag. Released versions are pushed on protected tags (e.g. "1.0.0");
    # "latest" is the current build of main. Leave empty to use the chart appVersion.
    tag: ""

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

# Log level of the controller's own loggers (org.etsi.osl.controllers.capif.invoker)
logLevel: DEBUG
spring:
  loglevel: INFO
  # Log level of org.springframework
  logLevel: INFO

activemq:
  brokerUrl: tcp://osl.etsi.org:61616?jms.watchTopicAdvisories=false
  # Points at the artemis broker of an OpenSlice release named "openslice" in the same namespace.
  # In general: tcp://<openslice-fullname>-artemis:61616?jms.watchTopicAdvisories=false
  brokerUrl: tcp://openslice-artemis:61616?jms.watchTopicAdvisories=false
  user: artemis
  password: artemis

@@ -28,27 +37,74 @@ capif:
  onboardingUrl: api-provider-management/v1/registrations
  onboardingUrlInvoker: api-invoker-management/v1/onboardedInvokers
  discoveryUrl: service-apis/v1/allServiceAPIs
  # Skips TLS validation towards CAPIF Core. Set to false to validate against the truststore.
  allowInsecure: true
  TrustorePath: none
  TrustorePassword: none
  truststorePath: none
  truststorePassword: none
  authRefreshTokensPeriod: 36000
  processBearerRefreshTokenPeriod: 180000

# need to add dynamic invokers
  # Optional JKS truststore mounted from an existing Secret. When existingSecret is set, the
  # truststore path is set to <mountPath>/<key> and truststorePath above is ignored.
  # Remember to set allowInsecure: false, otherwise the truststore is not used.
  truststore:
    existingSecret: ""
    # Key in the Secret that holds the JKS file
    key: truststore.jks
    # Optional key in the same Secret that holds the truststore password; overrides truststorePassword
    passwordKey: ""
    mountPath: /opt/openslice/truststore

  # Optional existing Secret whose keys are exposed to the controller as environment variables.
  # Reference them from the invokers below with Spring placeholders, e.g.
  #   privatekey: "${MY_INVOKER_PRIVATE_KEY}"
  invokerKeys:
    existingSecret: ""

autoscaling:
  enabled: false
  minReplicas: 1
  maxReplicas: 100
  targetCPUUtilizationPercentage: 80
  targetMemoryUtilizationPercentage: 80
  # CAPIF invokers to onboard. When empty, the example invokers built into the image are used.
  # privatekey/publickey take a PEM key, a ${PLACEHOLDER} (see invokerKeys) or "selfsign".
  invokers: []
  #  - name: myInvoker
  #    description: my invoker
  #    privatekey: "${MY_INVOKER_PRIVATE_KEY}"
  #    publickey: "${MY_INVOKER_PUBLIC_KEY}"
  #    apinames:
  #      - api: hello_api_demo

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: {}

podSecurityContext: {}
  # fsGroup: 2000

securityContext: {}
  # capabilities:
  #   drop:
  #   - ALL
  # readOnlyRootFilesystem: true
  # runAsNonRoot: true
  # runAsUser: 1000

resources: {}
  # limits:
  #   cpu: 500m
  #   memory: 768Mi
  # requests:
  #   cpu: 100m
  #   memory: 512Mi

nodeSelector: {}

tolerations: []

affinity: {}
Loading