Skip to content

Commit

Permalink
Merge pull request #3 from pagopa/NOD-690-nodo-cfg-sync-microservizio
Browse files Browse the repository at this point in the history
feat: Nod 690 nodo cfg sync microservizio
  • Loading branch information
fparisitas authored Mar 5, 2024
2 parents a671c5c + dd2ea9c commit c9c59b1
Show file tree
Hide file tree
Showing 77 changed files with 2,479 additions and 181 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
40 changes: 40 additions & 0 deletions .github/workflows/05h_deploy_with_github_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,43 @@ jobs:
resource_group_name: ${{ vars.CONTAINER_APP_ENVIRONMENT_RESOURCE_GROUP_NAME }}
runner_name: ${{ needs.create_runner.outputs.runner_name }}
pat_token: ${{ secrets.BOT_TOKEN_GITHUB }}
update_openapi:
needs: [ deploy ]
runs-on: ubuntu-latest
name: Update OpenAPI
if: ${{ inputs.target == inputs.environment || inputs.target == 'all' }}
environment: ${{ inputs.environment }}
steps:
- name: Checkout
id: checkout
# from https://github.com/actions/checkout/commits/main
uses: actions/checkout@1f9a0c22da41e6ebfa534300ef656657ea2c6707
with:
persist-credentials: false

- name: Setup Terraform
# from https://github.com/hashicorp/setup-terraform/commits/main
uses: hashicorp/setup-terraform@8feba2b913ea459066180f9cb177f58a881cf146
with:
terraform_version: "1.3.6"

- name: Login
id: login
# from https://github.com/Azure/login/commits/master
uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2
with:
client-id: ${{ secrets.CD_CLIENT_ID }}
tenant-id: ${{ secrets.TENANT_ID }}
subscription-id: ${{ secrets.SUBSCRIPTION_ID }}

- name: Terraform Apply
shell: bash
run: |
cd ./infra
export ARM_CLIENT_ID="${{ secrets.CLIENT_ID }}"
export ARM_SUBSCRIPTION_ID=$(az account show --query id --output tsv)
export ARM_TENANT_ID=$(az account show --query tenantId --output tsv)
export ARM_USE_OIDC=true
export ARM_ACCESS_KEY=$(az storage account keys list --resource-group io-infra-rg --account-name pagopainfraterraform${{inputs.environment}} --query '[0].value' -o tsv)
bash ./terraform.sh init weu-${{ inputs.environment }}
bash ./terraform.sh apply weu-${{ inputs.environment }} -auto-approve
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ hs_err_pid*
# Helm
/helm/charts/*
**/.terraform/

# Others
**/.DS_Store
/docker/local-dbs/postgres-data/
/Application.run/*.run.xml
15 changes: 8 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@
FROM maven:3.9.5-amazoncorretto-17-al2023@sha256:eeaa7ab572d931f7273fc5cf31429923f172091ae388969e11f42ec6dd817d74 as buildtime
WORKDIR /build
COPY . .
RUN mvn clean package
RUN mvn clean package -DskipTests


FROM amazoncorretto:17.0.9-alpine3.18@sha256:df48bf2e183230040890460ddb4359a10aa6c7aad24bd88899482c52053c7e17 as builder
COPY --from=buildtime /build/target/*.jar application.jar
WORKDIR /app
COPY --from=buildtime /build/target/*.jar /app/application.jar
RUN java -Djarmode=layertools -jar application.jar extract


FROM ghcr.io/pagopa/docker-base-springboot-openjdk17:v1.1.0@sha256:6fa320d452fa22066441f1ef292d15eb06f944bc8bca293e1a91ea460d30a613
WORKDIR /app
ADD --chown=spring:spring https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.25.1/opentelemetry-javaagent.jar .

COPY --chown=spring:spring --from=builder dependencies/ ./
COPY --chown=spring:spring --from=builder snapshot-dependencies/ ./
COPY --chown=spring:spring --from=builder /app/dependencies/ ./
COPY --chown=spring:spring --from=builder /app/snapshot-dependencies/ ./
# https://github.com/moby/moby/issues/37965#issuecomment-426853382
RUN true
COPY --chown=spring:spring --from=builder spring-boot-loader/ ./
COPY --chown=spring:spring --from=builder application/ ./
COPY --chown=spring:spring --from=builder /app/spring-boot-loader/ ./
COPY --chown=spring:spring --from=builder /app/application/ ./

EXPOSE 8080

Expand Down
14 changes: 14 additions & 0 deletions docker/local-dbs/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.9'
services:
postgres:
image: postgres:14
container_name: postgres_nexi
ports:
- 5432:5432
volumes:
- ./postgres-data:/var/lib/postgresql/data
- ./postgres:/docker-entrypoint-initdb.d
environment:
- POSTGRES_DB=nodo
- POSTGRES_USER=cfg
- POSTGRES_PASSWORD=password
6 changes: 6 additions & 0 deletions docker/local-dbs/postgres/create_tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE TABLE "cache" (
id varchar(20) NOT NULL,
"time" timestamp NOT NULL,
"cache" bytea NOT NULL,
"version" varchar(32) NULL
);
4 changes: 4 additions & 0 deletions docker/local-dbs/run_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

rm -rf postgres-data
docker-compose up -d --remove-orphans --force-recreate
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: pagopa-afm-calculator
description: Microservice that handles calculation for pagoPA Advanced Fees Management
type: application
version: 0.0.0
appVersion: 0.0.0
version: 0.34.0
appVersion: 0.0.0-34-NOD-690-nodo-cfg-sync-microservizio
dependencies:
- name: microservice-chart
version: 2.8.0
Expand Down
57 changes: 39 additions & 18 deletions helm/values-dev.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
microservice-chart:
namespace: "node-cfg-sync"
namespace: "nodo"
nameOverride: ""
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-node-cfg-sync
tag: "0.0.0"
tag: "0.0.0-34-NOD-690-nodo-cfg-sync-microservizio"
pullPolicy: Always
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8080
initialDelaySeconds: 90
initialDelaySeconds: 30
failureThreshold: 6
periodSeconds: 10
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8080
initialDelaySeconds: 90
initialDelaySeconds: 30
failureThreshold: 6
periodSeconds: 10
deployment:
Expand All @@ -34,9 +34,9 @@ microservice-chart:
servicePort: 8080
serviceAccount:
create: false
annotations: { }
annotations: {}
name: ""
podAnnotations: { }
podAnnotations: {}
podSecurityContext:
seccompProfile:
type: RuntimeDefault
Expand All @@ -47,8 +47,8 @@ microservice-chart:
memory: "512Mi"
cpu: "0.25"
limits:
memory: "512Mi"
cpu: "0.5"
memory: "1G"
cpu: "1.0"
autoscaling:
enable: true
minReplica: 1
Expand All @@ -62,13 +62,26 @@ microservice-chart:
type: Utilization # Allowed types are 'Utilization' or 'AverageValue'
value: "75"
envConfig:
WEBSITE_SITE_NAME: 'pagopa-node-cfg-sync' # required to show cloud role name in application insights
WEBSITE_SITE_NAME: 'pagopa-node-cfg-sync'
ENV: 'azure-dev'
APP_LOGGING_LEVEL: 'DEBUG'
DEFAULT_LOGGING_LEVEL: 'INFO'
CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}'

OTEL_SERVICE_NAME: "pagopa-node-cfg-sync"
DB_NEXI_POSTGRES_URL: "jdbc:postgresql://db-postgres-ndp.d.db-nodo-pagamenti.com:5444/ndpspct?prepareThreshold=0&currentSchema=NODO4_CFG"
DB_NEXI_POSTGRES_USER: "pp_nodo4_cfg"
DB_NEXI_POSTGRES_ENABLED: "true"
DB_NEXI_POSTGRES_SERVICE_IDENTIFIER: "NDP004DEV"
DB_NEXI_ORACLE_URL: "jdbc:oracle:thin:@(DESCRIPTION=(ENABLE=BROKEN)(ADDRESS=(PROTOCOL=tcp)(PORT=1522)(HOST=db-nodo-pagamenti.d.db-nodo-pagamenti.com))(CONNECT_DATA=(SERVICE_NAME=NDPSPCT_PP_NODO4_CFG))(SO_KEEPALIVE=true)(TCP_KEEPIDLE=60)(TCP_KEEPINTVL=30)(TCP_KEEPCNT=15))"
DB_NEXI_ORACLE_USER: "NODO4_CFG"
DB_NEXI_ORACLE_ENABLED: "true"
DB_NEXI_ORACLE_SERVICE_IDENTIFIER: "NDP003DEV"
DB_PAGOPA_POSTGRES_URL: "jdbc:postgresql://ndp.d.db-nodo-pagamenti.com:6432/nodo?sslmode=require&prepareThreshold=0&currentSchema=cfg"
DB_PAGOPA_POSTGRES_USER: "cfg"
DB_PAGOPA_POSTGRES_ENABLED: "true"
DB_PAGOPA_POSTGRES_SERVICE_IDENTIFIER: "NDP001DEV"
API_CONFIG_CACHE_URL: "https://api.dev.platform.pagopa.it/api-config-cache/p/v1/stakeholders/node/cache/schemas/v1"
STAND_IN_MANAGER_URL: "https://api.dev.platform.pagopa.it/stand-in-manager/api/v1"
OTEL_SERVICE_NAME: "pagopanodecfgsync"
OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=dev"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317"
OTEL_TRACES_EXPORTER: otlp
Expand All @@ -78,12 +91,21 @@ microservice-chart:
envSecret:
# required
APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-d-connection-string'
OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token
DB_PAGOPA_POSTGRES_PASSWORD: "db-cfg-password"
DB_NEXI_POSTGRES_PASSWORD: "db-nexi-cfg-password"
DB_NEXI_ORACLE_PASSWORD: "oracle-db-cfg-password"
API_CONFIG_CACHE_RX_CONNECTION_STRING: "nodo-dei-pagamenti-cache-sync-rx-connection-string-key"
API_CONFIG_CACHE_SA_CONNECTION_STRING: "nodo-dei-pagamenti-cache-sync-sa-connection-string-key"
STAND_IN_MANAGER_RX_CONNECTION_STRING: "nodo-dei-pagamenti-stand-in-sync-rx-connection-string-key"
STAND_IN_MANAGER_SA_CONNECTION_STRING: "nodo-dei-pagamenti-stand-in-sync-sa-connection-string-key"
API_CONFIG_CACHE_SUBSCRIPTION_KEY: "cfg-for-node-subscription-key"
STAND_IN_MANAGER_SUBSCRIPTION_KEY: "cfg-for-node-subscription-key"
OTEL_EXPORTER_OTLP_HEADERS: "elastic-apm-secret-token"
keyvault:
name: "pagopa-d-nodo-kv"
tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d"
nodeSelector: { }
tolerations: [ ]
nodeSelector: {}
tolerations: []
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
Expand All @@ -94,7 +116,7 @@ microservice-chart:
values:
- user
canaryDelivery:
create: true
create: false
ingress:
create: true
canary:
Expand All @@ -110,6 +132,5 @@ microservice-chart:
repository: ghcr.io/pagopa/pagopa-node-cfg-sync
tag: "0.0.0"
pullPolicy: Always
envConfig: { }
envSecret: { }

envConfig: {}
envSecret: {}
28 changes: 15 additions & 13 deletions helm/values-prod.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
microservice-chart:
namespace: "node-cfg-sync"
namespace: "nodo"
nameOverride: ""
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-node-cfg-sync
tag: "0.0.0"
tag: "0.0.0-34-NOD-690-nodo-cfg-sync-microservizio"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -34,9 +34,9 @@ microservice-chart:
servicePort: 8080
serviceAccount:
create: false
annotations: { }
annotations: {}
name: ""
podAnnotations: { }
podAnnotations: {}
podSecurityContext:
seccompProfile:
type: RuntimeDefault
Expand Down Expand Up @@ -67,8 +67,8 @@ microservice-chart:
APP_LOGGING_LEVEL: 'DEBUG'
DEFAULT_LOGGING_LEVEL: 'INFO'
CORS_CONFIGURATION: '{"origins": ["*"], "methods": ["*"]}'

OTEL_SERVICE_NAME: "pagopa-node-cfg-sync"
CACHET_TX_NAME: "nodo-dei-pagamenti-cache"
OTEL_SERVICE_NAME: "pagopanodecfgsync"
OTEL_RESOURCE_ATTRIBUTES: "deployment.environment=prod"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector.elastic-system.svc:4317"
OTEL_TRACES_EXPORTER: otlp
Expand All @@ -78,12 +78,15 @@ microservice-chart:
envSecret:
# required
APPLICATIONINSIGHTS_CONNECTION_STRING: 'ai-p-connection-string'
CACHE_TX_CONNECTION_STRING: "nodo-dei-pagamenti-cache-tx-connection-string-key"
OTEL_EXPORTER_OTLP_HEADERS: elastic-apm-secret-token
API_CONFIG_CACHE_SUBSCRIPTION_KEY: "cfg-for-node-subscription-key"
STAND_IN_MANAGER_SUBSCRIPTION_KEY: "cfg-for-node-subscription-key"
keyvault:
name: "pagopa-d-nodo-kv"
tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d"
nodeSelector: { }
tolerations: [ ]
nodeSelector: {}
tolerations: []
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
Expand All @@ -100,10 +103,10 @@ microservice-chart:
labelSelector:
matchLabels:
app.kubernetes.io/instance: "pagopa-node-cfg-sync"
namespaces: [ "nodo" ]
namespaces: ["nodo"]
topologyKey: topology.kubernetes.io/zone
canaryDelivery:
create: true
create: false
ingress:
create: true
canary:
Expand All @@ -119,6 +122,5 @@ microservice-chart:
repository: ghcr.io/pagopa/yourname # TODO
tag: "0.0.0"
pullPolicy: Always
envConfig: { }
envSecret: { }

envConfig: {}
envSecret: {}
Loading

0 comments on commit c9c59b1

Please sign in to comment.