diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml new file mode 100644 index 00000000..a1873c49 --- /dev/null +++ b/.github/workflows/build-deploy.yml @@ -0,0 +1,75 @@ +name: Manual build and deploy + +on: + workflow_dispatch: + inputs: + env: + description: 'Which environment to update.' + type: choice + required: true + default: dev + options: + - dev + - uat + - prod + +defaults: + run: + shell: bash + +permissions: + id-token: write # This is required for requesting the JWT + contents: read # This is required for actions/checkout + +jobs: + manual-build: + if: github.event_name == 'workflow_dispatch' + strategy: + matrix: + environment: ["${{ inputs.env }}"] + + name: "manual-build" + runs-on: ubuntu-latest + environment: ${{ matrix.environment }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 + with: + role-to-assume: ${{ secrets.IAM_ROLE }} + aws-region: ${{ vars.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Build, tag, and push docker image to Amazon ECR + env: + REGISTRY: ${{ steps.login-ecr.outputs.registry }} + REPOSITORY: ${{ vars.DOCKER_IMAGE_NAME}} + IMAGE_TAG: ${{ github.sha }} + run: | + docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG . + docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG + + - name: Update Kubernetes Config + run: | + aws eks --region ${{ vars.AWS_REGION }} update-kubeconfig --name pagopa-dev-atm-layer-eks + + - name: Install Helm + run: | + curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 + chmod 700 get_helm.sh + ./get_helm.sh + + - name: Upgrade Helm Chart + run: | + helm upgrade --install ${{ vars.DOCKER_IMAGE_NAME }} helm-chart/ \ + --namespace pagopa \ + -f helm-chart/environments/values-${{ inputs.env }}.yaml \ + --set image.tag=${{ github.sha }} \ + --set image.repository=${{ steps.login-ecr.outputs.registry }}/${{ vars.DOCKER_IMAGE_NAME }} \ + --set serviceAccount.annotations."eks\.amazonaws\.com/role-arn"=${{ secrets.SERVICEACCOUNT_IAM_ROLE }} diff --git a/.github/workflows/build-feature.yml b/.github/workflows/build-feature.yml new file mode 100644 index 00000000..3a29fcb4 --- /dev/null +++ b/.github/workflows/build-feature.yml @@ -0,0 +1,45 @@ +name: Build everytime push or merge + +on: + push: + branches: + - '**' # matches every branch + +defaults: + run: + shell: bash + +permissions: + id-token: write # This is required for requesting the JWT + contents: read # This is required for actions/checkout + +jobs: + build: + strategy: + matrix: + environment: [dev] + name: "build" + runs-on: ubuntu-latest + environment: ${{ matrix.environment }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 + with: + role-to-assume: ${{ secrets.IAM_ROLE }} + aws-region: ${{ vars.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Build, tag, and push docker image to Amazon ECR + env: + REGISTRY: ${{ steps.login-ecr.outputs.registry }} + REPOSITORY: ${{ vars.DOCKER_IMAGE_NAME}} + IMAGE_TAG: ${{ github.sha }} + run: | + docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG . diff --git a/helm-chart/Chart.yaml b/helm-chart/Chart.yaml new file mode 100644 index 00000000..96c37b4d --- /dev/null +++ b/helm-chart/Chart.yaml @@ -0,0 +1,25 @@ +apiVersion: v2 +name: chart-1 +description: | + Helm Chart for Model ATM Layer + +# 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: 0.1.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. +# It is recommended to use it with quotes. +appVersion: "1.16.0" \ No newline at end of file diff --git a/helm-chart/environments/values-dev.yaml b/helm-chart/environments/values-dev.yaml new file mode 100644 index 00000000..a1b76abd --- /dev/null +++ b/helm-chart/environments/values-dev.yaml @@ -0,0 +1,140 @@ +# Default values for chart-1. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 2 + +image: + repository: 00000000000.dkr.ecr.eu-south-1.amazonaws.com/xxxxxxx + pullPolicy: Always + # Overrides the image tag whose default is the chart appVersion. + tag: latest + +namespace: pagopa + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +milAdapter: + disableBackoffStrategy: true + lockDuration: 20000 + asyncResponseTimeout: 20000 + milBasePath: https://mil-d-apim.azure-api.net + enableInterceptorLogging: true + logEngineInputVariables: true + restReadTimeout: 20000 + restConnectionTmieout: 20000 + milAuthRelativePath: /mil-auth/token + milAuthClientCredentials: client_credentials + tokenCacheName: token-cache + tokenCacheMaxEntries: 100 + +milAuth: + credentialsSecretName: "pagopa-dev-atm-layer-model-mil-auth" + credentialsSecretKeys: + clientId: CLIENT_ID + clientSecret: CLIENT_SECRET + +camundaWebUser: + address: http://pagopa-dev-atm-layer-wf-engine.pagopa.svc.cluster.local:8080 + credentialsSecretName: "pagopa-dev-atm-layer-model-camunda" + credentialsSecretKeys: + username: WEB_USER + password: WEB_PASSWORD + +database: + driver: org.postgresql.Driver + url: jdbc:postgresql://pagopa-dev-atm-layer-rds.cluster-cyezwzpjc2tj.eu-south-1.rds.amazonaws.com:5431 + db_name: pagopadb + schema: atm_layer_engine + credentialsSecretName: "pagopa-dev-atm-layer-model-database" + credentialsSecretKeys: + username: DB_USERNAME + password: DB_PASSWORD + +secretProviderClass: + name: atm-layer-model-secrets + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: + eks.amazonaws.com/role-arn: arn:aws:iam::00000000000:role/pagopa-dev-atm-layer-xxxxxx-serviceaccount-role + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: pagopa-dev-atm-layer-model + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +deployment: + name: pagopa-dev-atm-layer-model + annotations: + reloader.stakater.com/auto: "true" + secret.reloader.stakater.com/reload: pagopa-dev-atm-layer-mil-adapter-database, pagopa-dev-atm-layer-mil-adapter-camunda, pagopa-dev-atm-layer-mil-adapter-mil-auth + +service: + name: pagopa-dev-atm-layer-model + type: NodePort + port: 8080 + +ingress: + enabled: false + name: pagopa-dev-atm-layer-model + className: "" + annotations: + kubernetes.io/ingress.class: "alb" + alb.ingress.kubernetes.io/scheme: "internal" + alb.ingress.kubernetes.io/group.name: "alb-controller" + alb.ingress.kubernetes.io/load-balancer-name: "pagopa-dev-atm-layer-alb-int" + alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTP": 8080}]' + hosts: + - host: + paths: + - path: /mil/ + pathType: Prefix + 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: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +Release: + Time: + Seconds: 60 diff --git a/helm-chart/environments/values-prod.yaml b/helm-chart/environments/values-prod.yaml new file mode 100644 index 00000000..992d0a87 --- /dev/null +++ b/helm-chart/environments/values-prod.yaml @@ -0,0 +1,91 @@ +# Default values for chart-1. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 2 + +image: + repository: 00000000000.dkr.ecr.eu-south-1.amazonaws.com/xxxxxxx + pullPolicy: Always + # Overrides the image tag whose default is the chart appVersion. + tag: prod + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: 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: xxxxxx + namespace: pagopa + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: NodePort + port: 8080 + +ingress: + enabled: false + className: "" + annotations: + kubernetes.io/ingress.class: "alb" + alb.ingress.kubernetes.io/scheme: "internal" + alb.ingress.kubernetes.io/group.name: "alb-controller" + alb.ingress.kubernetes.io/load-balancer-name: "pagopa-dev-atm-layer-alb-int" + alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTP": 8080}]' + hosts: + - host: chart-example.local + paths: + - path: /microservice5/ + pathType: Prefix + 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: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + + +Release: + Time: + Seconds: 60 diff --git a/helm-chart/environments/values-uat.yaml b/helm-chart/environments/values-uat.yaml new file mode 100644 index 00000000..0b339688 --- /dev/null +++ b/helm-chart/environments/values-uat.yaml @@ -0,0 +1,91 @@ +# Default values for chart-1. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 2 + +image: + repository: 00000000000.dkr.ecr.eu-south-1.amazonaws.com/xxxxxxx + pullPolicy: Always + # Overrides the image tag whose default is the chart appVersion. + tag: uat + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: 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: xxxxxxx + namespace: pagopa + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: NodePort + port: 8080 + +ingress: + enabled: false + className: "" + annotations: + kubernetes.io/ingress.class: "alb" + alb.ingress.kubernetes.io/scheme: "internal" + alb.ingress.kubernetes.io/group.name: "alb-controller" + alb.ingress.kubernetes.io/load-balancer-name: "pagopa-dev-atm-layer-alb-int" + alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTP": 8080}]' + hosts: + - host: chart-example.local + paths: + - path: /microservice5/ + pathType: Prefix + 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: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + + +Release: + Time: + Seconds: 60 diff --git a/helm-chart/templates/NOTES.txt b/helm-chart/templates/NOTES.txt new file mode 100644 index 00000000..660d4d50 --- /dev/null +++ b/helm-chart/templates/NOTES.txt @@ -0,0 +1,22 @@ +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 "chart-1.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 "chart-1.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "chart-1.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 "chart-1.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 }} \ No newline at end of file diff --git a/helm-chart/templates/_helpers.tpl b/helm-chart/templates/_helpers.tpl new file mode 100644 index 00000000..6ca7929a --- /dev/null +++ b/helm-chart/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "chart-1.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 "chart-1.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 "chart-1.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "chart-1.labels" -}} +helm.sh/chart: {{ include "chart-1.chart" . }} +{{ include "chart-1.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "chart-1.selectorLabels" -}} +app.kubernetes.io/name: {{ include "chart-1.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "chart-1.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "chart-1.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} \ No newline at end of file diff --git a/helm-chart/templates/deployment.yaml b/helm-chart/templates/deployment.yaml new file mode 100644 index 00000000..6d540511 --- /dev/null +++ b/helm-chart/templates/deployment.yaml @@ -0,0 +1,125 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.deployment.name }} + namespace: {{ .Values.namespace }} + labels: + App: {{ .Values.deployment.name }} + annotations: + {{- toYaml .Values.deployment.annotations | nindent 4 }} + +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + App: {{ .Values.deployment.name }} + template: + metadata: + labels: + App: {{ .Values.deployment.name }} + force-recreate: {{ randAlphaNum 5 | quote }} + spec: + serviceAccountName: {{ include "chart-1.serviceAccountName" . }} + volumes: + - name: secrets-store-inline-1 + csi: + driver: secrets-store.csi.k8s.io + readOnly: true + volumeAttributes: + secretProviderClass: {{ .Values.secretProviderClass.name }} + - name: secrets-store-inline-2 + csi: + driver: secrets-store.csi.k8s.io + readOnly: true + volumeAttributes: + secretProviderClass: {{ .Values.secretProviderClass.name }} + - name: secrets-store-inline-3 + csi: + driver: secrets-store.csi.k8s.io + readOnly: true + volumeAttributes: + secretProviderClass: {{ .Values.secretProviderClass.name }} + containers: + - name: {{ .Values.deployment.name }} + image: {{ .Values.image.repository }}:{{ .Values.image.tag }} + ports: + - containerPort: {{ .Values.service.port }} + imagePullPolicy: Always + env: + - name: MIL_ADAPTER_ENGINE_URL + value: "{{ .Values.camundaWebUser.address }}" + - name: MIL_ADAPTER_DISABLE_BACKOFF_STRATEGY + value: "{{ .Values.milAdapter.disableBackoffStrategy }}" + - name: MIL_ADAPTER_LOCK_DURATION + value: "{{ .Values.milAdapter.lockDuration }}" + - name: MIL_ADAPTER_ASYNC_RESPONSE_TIMEOUT + value: "{{ .Values.milAdapter.asyncResponseTimeout }}" + - name: MIL_ADAPTER_ENGINE_ACCOUNT_USER + valueFrom: + secretKeyRef: + name: {{ .Values.camundaWebUser.credentialsSecretName }} + key: {{ .Values.camundaWebUser.credentialsSecretKeys.username }} + - name: MIL_ADAPTER_ENGINE_ACCOUNT_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.camundaWebUser.credentialsSecretName }} + key: {{ .Values.camundaWebUser.credentialsSecretKeys.password }} + - name: MIL_ADAPTER_MIL_BASE_PATH + value: "{{ .Values.milAdapter.milBasePath }}" + - name: MIL_ADAPTER_MIL_AUTH_CLIENT_ID + valueFrom: + secretKeyRef: + name: {{ .Values.milAuth.credentialsSecretName }} + key: {{ .Values.milAuth.credentialsSecretKeys.clientId }} + - name: MIL_ADAPTER_MIL_AUTH_CLIENT_SECRET + valueFrom: + secretKeyRef: + name: {{ .Values.milAuth.credentialsSecretName }} + key: {{ .Values.milAuth.credentialsSecretKeys.clientSecret }} + - name: MIL_ADAPTER_ENGINE_DB_BASE_URL + value: "{{ .Values.database.url }}" + - name: MIL_ADAPTER_ENGINE_DB_NAME + value: "{{ .Values.database.db_name }}" + - name: MIL_ADAPTER_ENGINE_DB_SCHEMA + value: "{{ .Values.database.schema }}" + - name: MIL_ADAPTER_ENGINE_DB_USERNAME + valueFrom: + secretKeyRef: + name: {{ .Values.database.credentialsSecretName }} + key: {{ .Values.database.credentialsSecretKeys.username }} + - name: MIL_ADAPTER_ENGINE_DB_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.database.credentialsSecretName }} + key: {{ .Values.database.credentialsSecretKeys.password }} + - name: MIL_ADAPTER_ENGINE_DB_DRIVER + value: "{{ .Values.database.driver }}" + - name: MIL_ADAPTER_ENABLE_INTERCEPTOR_LOGGING + value: "{{ .Values.milAdapter.enableInterceptorLogging }}" + - name: MIL_ADAPTER_LOG_ENGINE_INPUT_VARIABLES + value: "{{ .Values.milAdapter.logEngineInputVariables }}" + - name: MIL_ADAPTER_REST_READ_TIMEOUT + value: "{{ .Values.milAdapter.restReadTimeout }}" + - name: MIL_ADAPTER_REST_CONNECTION_TIMEOUT + value: "{{ .Values.milAdapter.restConnectionTmieout }}" + - name: MIL_ADAPTER_MIL_AUTH_RELATIVE_PATH + value: "{{ .Values.milAdapter.milAuthRelativePath }}" + - name: MIL_ADAPTER_MIL_AUTH_CLIENT_CREDENTIALS + value: "{{ .Values.milAdapter.milAuthClientCredentials }}" + - name: MIL_ADAPTER_TOKEN_CACHE_NAME + value: "{{ .Values.milAdapter.tokenCacheName }}" + - name: MIL_ADAPTER_TOKEN_CACHE_MAX_ENTRIES + value: "{{ .Values.milAdapter.tokenCacheMaxEntries }}" + volumeMounts: + - name: secrets-store-inline-1 + mountPath: "/mnt/secrets-store" + readOnly: true + - name: secrets-store-inline-2 + mountPath: "/mnt/secrets-store" + readOnly: true + - name: secrets-store-inline-3 + mountPath: "/mnt/secrets-store" + readOnly: true + + strategy: + type: Recreate \ No newline at end of file diff --git a/helm-chart/templates/hpa.yaml b/helm-chart/templates/hpa.yaml new file mode 100644 index 00000000..d33609fe --- /dev/null +++ b/helm-chart/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "chart-1.fullname" . }} + labels: + {{- include "chart-1.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "chart-1.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/helm-chart/templates/ingress.yaml b/helm-chart/templates/ingress.yaml new file mode 100644 index 00000000..1a58de15 --- /dev/null +++ b/helm-chart/templates/ingress.yaml @@ -0,0 +1,22 @@ +{{- if .Values.ingress.enabled -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Values.ingress.name }} + annotations: + {{- toYaml .Values.ingress.annotations | nindent 4 }} +spec: + rules: + - {{- if .host }} + host: {{ .host }} + {{- end }} + http: + paths: + - path: {{ index .Values.ingress.hosts 0 "paths" 0 "path" }} + pathType: {{ index .Values.ingress.hosts 0 "paths" 0 "pathType" }} + backend: + service: + name: {{ .Values.ingress.name }} + port: + number: {{ .Values.service.port }} +{{- end }} \ No newline at end of file diff --git a/helm-chart/templates/secretproviderclass.yaml b/helm-chart/templates/secretproviderclass.yaml new file mode 100644 index 00000000..4147d454 --- /dev/null +++ b/helm-chart/templates/secretproviderclass.yaml @@ -0,0 +1,51 @@ +apiVersion: secrets-store.csi.x-k8s.io/v1alpha1 +kind: SecretProviderClass +metadata: + name: {{ .Values.secretProviderClass.name }} +spec: + provider: aws + parameters: + objects: | + - objectName: "pagopa-dev-atm-layer/rds/credentials" + objectType: "secretsmanager" + jmesPath: + - path: username + objectAlias: username + - path: password + objectAlias: password + - objectName: "pagopa-dev-atm-layer/camunda/credentials" + objectType: "secretsmanager" + jmesPath: + - path: WEB_USER + objectAlias: WEB_USER + - path: WEB_PASSWORD + objectAlias: WEB_PASSWORD + - objectName: "pagopa-dev-atm-layer/mil-auth/credentials" + objectType: "secretsmanager" + jmesPath: + - path: CLIENT_ID + objectAlias: CLIENT_ID + - path: CLIENT_SECRET + objectAlias: CLIENT_SECRET + secretObjects: + - secretName: {{ .Values.database.credentialsSecretName }} + type: Opaque + data: + - objectName: "username" # reference the corresponding parameter + key: DB_USERNAME + - objectName: "password" # reference the corresponding parameter + key: DB_PASSWORD + - secretName: {{ .Values.camundaWebUser.credentialsSecretName }} + type: Opaque + data: + - objectName: "WEB_USER" # reference the corresponding parameter + key: WEB_USER + - objectName: "WEB_PASSWORD" # reference the corresponding parameter + key: WEB_PASSWORD + - secretName: {{ .Values.milAuth.credentialsSecretName }} + type: Opaque + data: + - objectName: "CLIENT_ID" # reference the corresponding parameter + key: CLIENT_ID + - objectName: "CLIENT_SECRET" # reference the corresponding parameter + key: CLIENT_SECRET diff --git a/helm-chart/templates/service.yaml b/helm-chart/templates/service.yaml new file mode 100644 index 00000000..69aa025b --- /dev/null +++ b/helm-chart/templates/service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.service.name }} + namespace: {{ .Values.namespace }} +spec: + selector: + App: {{ .Values.service.name }} + ports: + - name: {{ .Values.service.name }} + port: {{ .Values.service.port }} + targetPort: {{ .Values.service.port }} + type: {{ .Values.service.type }} \ No newline at end of file diff --git a/helm-chart/templates/serviceaccount.yaml b/helm-chart/templates/serviceaccount.yaml new file mode 100644 index 00000000..b2e32226 --- /dev/null +++ b/helm-chart/templates/serviceaccount.yaml @@ -0,0 +1,8 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "chart-1.serviceAccountName" . }} + annotations: + {{- toYaml .Values.serviceAccount.annotations | nindent 4 }} +{{- end }} diff --git a/helm-chart/templates/tests/test-connection.yaml b/helm-chart/templates/tests/test-connection.yaml new file mode 100644 index 00000000..670bf9fb --- /dev/null +++ b/helm-chart/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "chart-1.fullname" . }}-test-connection" + labels: + {{- include "chart-1.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "chart-1.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never \ No newline at end of file