From 49cf9b001945397a3aa47a472e9558f6d37bae90 Mon Sep 17 00:00:00 2001 From: Stefan Wiedemann Date: Mon, 25 Sep 2023 13:51:18 +0200 Subject: [PATCH] orion-ld adapter --- aws/apps/dome/consumer/orion-ld-adapter.yaml | 20 ++ .../blockchain-connector-core/values.yaml | 2 +- .../connector/orionld-adapter/Chart.yaml | 7 + .../orionld-adapter/templates/_helpers.tpl | 74 ++++++ .../orionld-adapter/templates/configmap.yml | 23 ++ .../templates/deployment-hpa.yaml | 19 ++ .../orionld-adapter/templates/deployment.yaml | 93 ++++++++ .../orionld-adapter/templates/service.yaml | 21 ++ .../templates/serviceaccount.yaml | 12 + .../connector/orionld-adapter/values.yaml | 222 ++++++++++++++++++ 10 files changed, 492 insertions(+), 1 deletion(-) create mode 100644 aws/apps/dome/consumer/orion-ld-adapter.yaml create mode 100644 aws/dome/consumer/connector/orionld-adapter/Chart.yaml create mode 100644 aws/dome/consumer/connector/orionld-adapter/templates/_helpers.tpl create mode 100644 aws/dome/consumer/connector/orionld-adapter/templates/configmap.yml create mode 100644 aws/dome/consumer/connector/orionld-adapter/templates/deployment-hpa.yaml create mode 100644 aws/dome/consumer/connector/orionld-adapter/templates/deployment.yaml create mode 100644 aws/dome/consumer/connector/orionld-adapter/templates/service.yaml create mode 100644 aws/dome/consumer/connector/orionld-adapter/templates/serviceaccount.yaml create mode 100644 aws/dome/consumer/connector/orionld-adapter/values.yaml diff --git a/aws/apps/dome/consumer/orion-ld-adapter.yaml b/aws/apps/dome/consumer/orion-ld-adapter.yaml new file mode 100644 index 00000000..2bbbdadc --- /dev/null +++ b/aws/apps/dome/consumer/orion-ld-adapter.yaml @@ -0,0 +1,20 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: dome-consumer-orion-ld-adapter + namespace: argocd + labels: + participant: consumer +spec: + destination: + namespace: dome + server: https://kubernetes.default.svc + project: default + source: + path: aws/dome/consumer/connector/orion-ld-adapter + repoURL: https://github.com/FIWARE-Ops/fiware-gitops + targetRevision: HEAD + syncPolicy: + automated: + prune: true + selfHeal: true \ No newline at end of file diff --git a/aws/dome/consumer/connector/blockchain-connector-core/values.yaml b/aws/dome/consumer/connector/blockchain-connector-core/values.yaml index 2c054021..98677a4f 100644 --- a/aws/dome/consumer/connector/blockchain-connector-core/values.yaml +++ b/aws/dome/consumer/connector/blockchain-connector-core/values.yaml @@ -209,7 +209,7 @@ orion: subscription: type: Subscription notificationEndpoint: http://dome-consumer-blockchain-connector-core:8080/notifications/orion-ld - entities: ProductOrder, ProductOffering + entities: product-order, product-offering prefix: "urn:ngsi-ld:Subscription:" adapter: host: http://dome-consumer-dlt-adapter:8080 diff --git a/aws/dome/consumer/connector/orionld-adapter/Chart.yaml b/aws/dome/consumer/connector/orionld-adapter/Chart.yaml new file mode 100644 index 00000000..6ebc9896 --- /dev/null +++ b/aws/dome/consumer/connector/orionld-adapter/Chart.yaml @@ -0,0 +1,7 @@ +apiVersion: v2 +name: orionld-adapter +description: A Helm chart for Orion-LD Adapter Kubernetes + +type: application +version: 0.0.1 +appVersion: v1alpha1 diff --git a/aws/dome/consumer/connector/orionld-adapter/templates/_helpers.tpl b/aws/dome/consumer/connector/orionld-adapter/templates/_helpers.tpl new file mode 100644 index 00000000..96f7c9a5 --- /dev/null +++ b/aws/dome/consumer/connector/orionld-adapter/templates/_helpers.tpl @@ -0,0 +1,74 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "orionldadapter.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 "orionldadapter.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 "orionldadapter.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "orionldadapter.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "orionldadapter.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "orionldadapter.labels" -}} +app.kubernetes.io/name: {{ include "orionldadapter.name" . }} +helm.sh/chart: {{ include "orionldadapter.chart" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Support for existing database secret +*/}} +{{- define "orionldadapter.secretName" -}} + {{- if .Values.database.existingSecret.enabled -}} + {{- printf "%s" (tpl .Values.database.existingSecret.name $) -}} + {{- else -}} + {{- printf "%s" (include "orionldadapter.fullname" .) -}} + {{- end -}} +{{- end -}} + +{{- define "orionldadapter.passwordKey" -}} + {{- if .Values.database.existingSecret.enabled -}} + {{- printf "%s" (tpl .Values.database.existingSecret.key $) -}} + {{- else -}} + {{- printf "password" -}} + {{- end -}} +{{- end -}} diff --git a/aws/dome/consumer/connector/orionld-adapter/templates/configmap.yml b/aws/dome/consumer/connector/orionld-adapter/templates/configmap.yml new file mode 100644 index 00000000..b3851dd7 --- /dev/null +++ b/aws/dome/consumer/connector/orionld-adapter/templates/configmap.yml @@ -0,0 +1,23 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "orionldadapter.fullname" . }} +data: + custom-config.yml: | + orion-ld-if: + orion-ld: + domain: {{ .Values.orion.address }} + path: + entities: {{ .Values.orion.entitiesPath }} + subscriptions: {{ .Values.orion.subscriptionPath }} + api: + domain: {{ .Values.adapter.host }} + path: + subscription: {{ .Values.adapter.subscriptionPath }} + entities: {{ .Values.adapter.publishPath }} + subscription: + type: {{ .Values.orion.subscription.type }} + notification-endpoint-uri: {{ .Values.orion.subscription.notificationEndpoint }} + entities: > + {{ .Values.orion.subscription.entities }} + id-prefix: {{ .Values.orion.subscription.prefix | quote }} \ No newline at end of file diff --git a/aws/dome/consumer/connector/orionld-adapter/templates/deployment-hpa.yaml b/aws/dome/consumer/connector/orionld-adapter/templates/deployment-hpa.yaml new file mode 100644 index 00000000..2cc1df6b --- /dev/null +++ b/aws/dome/consumer/connector/orionld-adapter/templates/deployment-hpa.yaml @@ -0,0 +1,19 @@ +{{- if .Values.autoscaling.enabled -}} +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "orionldadapter.fullname" . }} + labels: + {{ include "orionldadapter.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "orionldadapter.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} +{{- with .Values.autoscaling.metrics }} + metrics: + {{- toYaml . | nindent 2 }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/aws/dome/consumer/connector/orionld-adapter/templates/deployment.yaml b/aws/dome/consumer/connector/orionld-adapter/templates/deployment.yaml new file mode 100644 index 00000000..27def011 --- /dev/null +++ b/aws/dome/consumer/connector/orionld-adapter/templates/deployment.yaml @@ -0,0 +1,93 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "orionldadapter.fullname" . }} + labels: + {{ include "orionldadapter.labels" . | nindent 4 }} + namespace: default +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.deployment.replicaCount }} + {{- end }} + revisionHistoryLimit: {{ .Values.deployment.revisionHistoryLimit }} + strategy: + {{- with .Values.deployment.updateStrategy }} + {{- toYaml . | nindent 4 }} + {{- end }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "orionldadapter.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + {{ include "orionldadapter.labels" . | nindent 8 }} + {{- with .Values.deployment.additionalLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- if .Values.deployment.additionalAnnotations -}} + annotations: + prometheus.io/scrape: {{ .Values.prometheus.enabled | quote }} + prometheus.io/path: {{ .Values.prometheus.path }} + prometheus.io/port: {{ .Values.prometheus.port }} + {{- with .Values.deployment.additionalAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- end }} + spec: + serviceAccountName: {{ include "orionldadapter.serviceAccountName" . }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.deployment.image.repository }}:{{ .Values.deployment.image.tag }}" + imagePullPolicy: {{ .Values.deployment.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.port}} + protocol: TCP + - name: http-health + containerPort: {{ .Values.deployment.healthPort }} + protocol: TCP + livenessProbe: + httpGet: + path: /health + port: http-health + initialDelaySeconds: {{ .Values.deployment.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.deployment.livenessProbe.periodSeconds }} + successThreshold: {{ .Values.deployment.livenessProbe.successThreshold }} + timeoutSeconds: {{ .Values.deployment.livenessProbe.timeoutSeconds }} + readinessProbe: + httpGet: + path: /health + port: http-health + initialDelaySeconds: {{ .Values.deployment.readinessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.deployment.readinessProbe.periodSeconds }} + successThreshold: {{ .Values.deployment.readinessProbe.successThreshold }} + timeoutSeconds: {{ .Values.deployment.readinessProbe.timeoutSeconds }} + env: + - name: SPRING_PROFILES_ACTIVE + value: dev + - name: SPRING_CONFIG_IMPORT + value: "/src/main/resources/custom-config.yml" + volumeMounts: + - name: config-volume + mountPath: "/src/main/resources/" + readOnly: true + resources: + {{- toYaml .Values.deployment.resources | nindent 12 }} + volumes: + - name: config-volume + configMap: + name: orionld-adapter-configmap + {{- with .Values.deployment.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.deployment.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.deployment.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + restartPolicy: Always diff --git a/aws/dome/consumer/connector/orionld-adapter/templates/service.yaml b/aws/dome/consumer/connector/orionld-adapter/templates/service.yaml new file mode 100644 index 00000000..1817fc82 --- /dev/null +++ b/aws/dome/consumer/connector/orionld-adapter/templates/service.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "orionldadapter.fullname" . }} + {{- if .Values.service.annotations }} + annotations: + {{ toYaml .Values.service.annotations | nindent 4 }} + {{- end }} + labels: + {{ include "orionldadapter.labels" . | nindent 4 }} + namespace: default +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.port }} + protocol: TCP + name: http + selector: + app.kubernetes.io/name: {{ include "orionldadapter.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/aws/dome/consumer/connector/orionld-adapter/templates/serviceaccount.yaml b/aws/dome/consumer/connector/orionld-adapter/templates/serviceaccount.yaml new file mode 100644 index 00000000..b83e9ed6 --- /dev/null +++ b/aws/dome/consumer/connector/orionld-adapter/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "orionldadapter.fullname" . }} +{{- if .Values.serviceAccount.annotations }} + annotations: + {{ toYaml .Values.serviceAccount.annotations | nindent 4 }} +{{- end }} + labels: + {{ include "orionldadapter.labels" . | nindent 4 }} +{{- end }} \ No newline at end of file diff --git a/aws/dome/consumer/connector/orionld-adapter/values.yaml b/aws/dome/consumer/connector/orionld-adapter/values.yaml new file mode 100644 index 00000000..3605d32a --- /dev/null +++ b/aws/dome/consumer/connector/orionld-adapter/values.yaml @@ -0,0 +1,222 @@ +## Default values for orionld-adapter. +## This is a YAML-formatted file. +## Declare variables to be passed into your templates. + +# -- option to override the name config in the _helpers.tpl +nameOverride: "" + +# -- option to override the fullname config in the _helpers.tpl +fullnameOverride: "" + +## configuration for the k8s service to access orionld-adapter +service: + # -- service type + type: ClusterIP + # -- port to be used by the service + port: 8080 + # -- additional annotations, if required + annotations: { } + +# -- if an orionld-adapter specific service account should be used, it can be configured here +# ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ +serviceAccount: + # -- specifies if the account should be created + create: false + +## deployment specific configuration +deployment: + # -- initial number of target replications, can be different if autoscaling is enabled + replicaCount: 1 + # -- number of old replicas to be retained + revisionHistoryLimit: 3 + ## configuration of the orionld-adapter update strategy + updateStrategy: + # -- type of the update + type: RollingUpdate + # -- new pods will be added gradually + rollingUpdate: + # -- number of pods that can be created above the desired amount while updating + maxSurge: 1 + # -- number of pods that can be unavailable while updating + maxUnavailable: 0 + ## configuration of the image to be used + image: + # -- orionld-adapter image name + # ref: https://hub.docker.com/repository/docker/ocanades/orionld-adapter + repository: ocanades/orionld-adapter + # -- tag of the image to be used + tag: 1.0.0 + # -- specification of the image pull policy + pullPolicy: IfNotPresent + # -- additional labels for the deployment, if required + additionalLabels: { } + # -- additional annotations for the deployment, if required + additionalAnnotations: { } + ## orionld-adapter resource requests and limits, we leave the default empty to make that a conscious + ## choice by the user. For the autoscaling to make sense, you should configure this. + # resources: + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + # -- selector template + # ref: https://kubernetes.io/docs/user-guide/node-selection/ + nodeSelector: { } + # -- tolerations template + # ref: ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ + tolerations: [ ] + # -- affinity template + # ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity + affinity: { } + # -- port to request health information at + healthPort: 9092 + ## liveness and readiness probes + # ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-probes + livenessProbe: + initialDelaySeconds: 30 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 30 + readinessProbe: + initialDelaySeconds: 31 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 30 + +## pod autoscaling configuration, use for automatic scaling of the broker pods +autoscaling: + # -- should autoscaling be enabled for til + enabled: false + # -- minimum number of running pods + minReplicas: 1 + # -- maximum number of running pods + maxReplicas: 10 + # -- metrics to react on + metrics: [ ] + ## List of MetricSpecs to decide whether to scale + # See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#metricspec-v2beta2-autoscaling + # scaler targets to hold average cpu around 80% + #- type: Resource + # resource: + # name: cpu + # target: + # type: Utilization + # averageUtilization: 80 + ## scaler targets to hold average memory around 80% + # - type: Resource + # resource: + # name: memory + # target: + # type: Utilization + # averageUtilization: 80 + +### openshift specific route definition. Will not work on plain k8s +#route: +# # -- route config for the trusted issuers list endpoint +# til: +# ## -- should the deployment create openshift routes +# enabled: false +# # -- annotations to be added to the route +# annotations: { } +# # -- host to be used +# # host: localhost +# # -- tls configuration for the route +# tls: { } +# # termination: edge +# # configuration for creation of certificates, using cert-manager. +# certificate: { } +# # allows to specify the issuer to be used. +# # issuer: +# # kind: ClusterIssuer +# # name: letsencrypt-aws-prod +# # -- route config for the trusted issuers registry endpoint +# tir: +# ## -- should the deployment create openshift routes +# enabled: false +# # -- annotations to be added to the route +# annotations: { } +# # -- host to be used +# # host: localhost +# # -- tls configuration for the route +# tls: { } +# # termination: edge +# # configuration for creation of certificates, using cert-manager. +# certificate: { } +# # allows to specify the issuer to be used. +# # issuer: +# # kind: ClusterIssuer +# # name: letsencrypt-aws-prod + +## ingress configuration +#ingress: +# # -- route config for the blockchain-connector-core endpoint +# bcc: +# # -- should there be an ingress to connect blockchain-connector-core with the public internet +# enabled: false +# # -- annotations to be added to the ingress +# annotations: { } +# # kubernetes.io/ingress.class: "ambassador" +# ## example annotations, allowing cert-manager to automatically create tls-certs and forcing everything to use ssl. +# # kubernetes.io/tls-acme: "true" +# # ingress.kubernetes.io/ssl-redirect: "true" +# # -- all hosts to be provided +# hosts: [ ] +# ## provide a hosts and the paths that should be available +# # - host: localhost +# # -- configure the ingress' tls +# tls: [ ] +# # - secretName: bcc-tls +# # hosts: +# # - bcc.fiware.org +# # -- route config for the trusted issuers registry endpoint +# tir: +# # -- should there be an ingress to connect til with the public internet +# enabled: false +# # -- annotations to be added to the ingress +# annotations: { } +# # kubernetes.io/ingress.class: "ambassador" +# ## example annotations, allowing cert-manager to automatically create tls-certs and forcing everything to use ssl. +# # kubernetes.io/tls-acme: "true" +# # ingress.kubernetes.io/ssl-redirect: "true" +# # -- all hosts to be provided +# hosts: [ ] +# ## provide a hosts and the paths that should be available +# # - host: localhost +# # -- configure the ingress' tls +# tls: [ ] +# # - secretName: til-tls +# # hosts: +# # - til.fiware.org + +# -- port that the orionld-adapter container uses +port: 8080 + +## configuration for prometheus monitoring +prometheus: + # -- should prometheus scrape be enabled + enabled: true + # -- path for prometheus scrape + path: /prometheus + # -- port prometheus scrape is available at + port: 9090 + +orion: + address: https://orion.dome-consumer.fiware.dev + entitiesPath: /ngsi-ld/v1/entities + subscriptionPath: /ngsi-ld/v1/subscriptions + subscription: + type: Subscription + notificationEndpoint: http://dome-consumer-blockchain-connector-core:8080/notifications/orion-ld + entities: product-order, product-offering + prefix: "urn:ngsi-ld:Subscription:" + +adapter: + host: http://dome-consumer-dlt-adapter:8080 + subscriptionPath: /api/v1/subscribe + publishPath: /api/v1/publish + + +# -- a list of additional env vars to be set, check the blockchain-connector-core doc for all available options +additionalEnvVars: [ ]