Skip to content

Commit

Permalink
feat: BDRS Service Deployment and BPN Mapping Seed (eclipse-tractusx#367
Browse files Browse the repository at this point in the history
)
  • Loading branch information
hemantxpatel authored Jul 4, 2024
1 parent e77b99e commit 0bb721e
Show file tree
Hide file tree
Showing 6 changed files with 327 additions and 4 deletions.
56 changes: 56 additions & 0 deletions mxd/bdrs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#################################################################################
#
# Copyright (c) 2024 SAP SE
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
#
# Contributors:
# SAP SE - initial API and implementation
#
#################################################################################

resource "helm_release" "bdrs-server" {
name = "bdrs-server"
force_update = true
dependency_update = true
reuse_values = true
cleanup_on_fail = true
replace = true

repository = "https://eclipse-tractusx.github.io/charts/dev"
chart = "bdrs-server"
version = "0.0.4"

values = [
yamlencode({
server : {
trustedIssuers : ["did:web:miw:${var.miw-bpn}"]
env : {
EDC_API_AUTH_KEY : "password"
EDC_DATASOURCE_DIDENTRY_USER : local.databases.bdrs.database-username
EDC_DATASOURCE_DIDENTRY_PASSWORD : local.databases.bdrs.database-password
}
}
postgresql : {
jdbcUrl : "jdbc:postgresql://${local.bdrs-postgres.database-url}/${local.databases.bdrs.database-name}"
}
})
]

set {
name = "install.postgresql"
value = false
}
}

locals {
bdrs-service = "bdrs-server"
bdrs-mgmt-port = 8081
bdrs-directory-port = 8082
bdrs-mgmt-url = "http://${local.bdrs-service}:${local.bdrs-mgmt-port}/api/management"
bdrs-directory-url = "http://${local.bdrs-service}:${local.bdrs-directory-port}/api/directory"
}
22 changes: 22 additions & 0 deletions mxd/ingress.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,28 @@ resource "kubernetes_ingress_v1" "mxd-ingress" {
}
}
}
path {
path = "/bdrs-mgmt(/|$)(.*)"
backend {
service {
name = local.bdrs-service
port {
number = local.bdrs-mgmt-port
}
}
}
}
path {
path = "/bdrs-dir(/|$)(.*)"
backend {
service {
name = local.bdrs-service
port {
number = local.bdrs-directory-port
}
}
}
}
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions mxd/postgres-init.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ resource "kubernetes_config_map" "postgres-initdb-config" {
locals {
keycloak-postgres = var.common-postgres-instance ? module.common-postgres[0] : module.postgres["keycloak"]
miw-postgres = var.common-postgres-instance ? module.common-postgres[0] : module.postgres["miw"]
bdrs-postgres = var.common-postgres-instance ? module.common-postgres[0] : module.postgres["bdrs"]
alice-postgres = var.common-postgres-instance ? module.common-postgres[0] : module.postgres["alice"]
bob-postgres = var.common-postgres-instance ? module.common-postgres[0] : module.postgres["bob"]
trudy-postgres = var.common-postgres-instance ? module.common-postgres[0] : module.postgres["trudy"]
Expand All @@ -76,6 +77,12 @@ locals {
database-password = "miw"
}

bdrs = {
database-name = "bdrs",
database-username = "bdrs"
database-password = "bdrs"
}

alice = {
database-name = "alice",
database-username = "alice"
Expand Down
46 changes: 44 additions & 2 deletions mxd/postman/mxd-management-apis.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"info": {
"_postman_id": "2331eb24-a4fe-4841-b2c0-4333e3fd47e3",
"_postman_id": "3636c0ce-40f8-4a9e-a868-03841ed765f0",
"name": "tractusx-edc-mgmt-api",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "252261",
"_collection_link": "https://winter-rocket-884715.postman.co/workspace/SAP~ff4cf631-05f4-48ab-a1e0-f716cf2efc25/collection/252261-2331eb24-a4fe-4841-b2c0-4333e3fd47e3?action=share&source=collection_link&creator=252261"
"_collection_link": "https://winter-rocket-884715.postman.co/workspace/SAP~ff4cf631-05f4-48ab-a1e0-f716cf2efc25/collection/252261-3636c0ce-40f8-4a9e-a868-03841ed765f0?action=share&source=collection_link&creator=252261"
},
"item": [
{
Expand Down Expand Up @@ -75,6 +75,48 @@
},
"response": []
},
{
"name": "Get BPN Mapping",
"event": [
{
"listen": "test",
"script": {
"exec": [
""
],
"type": "text/javascript",
"packages": {}
}
},
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "localhost/bdrs-mgmt/api/management/bpn-directory",
"host": [
"localhost"
],
"path": [
"bdrs-mgmt",
"api",
"management",
"bpn-directory"
]
}
},
"response": []
},
{
"name": "Create Asset",
"event": [
Expand Down
179 changes: 177 additions & 2 deletions mxd/postman/mxd-seed.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"info": {
"_postman_id": "d2bed995-c23f-43fa-a5ae-6aa49b24f0d9",
"_postman_id": "456f5db9-6973-4259-a8a9-381408e48c6a",
"name": "MXD Management API Seed",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "252261",
"_collection_link": "https://winter-rocket-884715.postman.co/workspace/SAP~ff4cf631-05f4-48ab-a1e0-f716cf2efc25/collection/252261-d2bed995-c23f-43fa-a5ae-6aa49b24f0d9?action=share&source=collection_link&creator=252261"
"_collection_link": "https://winter-rocket-884715.postman.co/workspace/SAP~ff4cf631-05f4-48ab-a1e0-f716cf2efc25/collection/252261-456f5db9-6973-4259-a8a9-381408e48c6a?action=share&source=collection_link&creator=252261"
},
"item": [
{
Expand Down Expand Up @@ -487,6 +487,161 @@
}
}
]
},
{
"name": "SeedBDRS",
"item": [
{
"name": "Create Alice BPN Mapping",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 204\", function () {",
" pm.response.to.have.status(204);",
"});"
],
"type": "text/javascript",
"packages": {}
}
},
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"bpn\": \"{{ALICE_BPN}}\",\n \"did\": \"{{ALICE_DID}}\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{BDRS_MGMT_URL}}/bpn-directory",
"host": [
"{{BDRS_MGMT_URL}}"
],
"path": [
"bpn-directory"
]
}
},
"response": []
},
{
"name": "Create Bob BPN Mapping",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 204\", function () {",
" pm.response.to.have.status(204);",
"});"
],
"type": "text/javascript",
"packages": {}
}
},
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"bpn\": \"{{BOB_BPN}}\",\n \"did\": \"{{BOB_DID}}\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{BDRS_MGMT_URL}}/bpn-directory",
"host": [
"{{BDRS_MGMT_URL}}"
],
"path": [
"bpn-directory"
]
}
},
"response": []
},
{
"name": "Create Trudy BPN Mapping",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 204\", function () {",
" pm.response.to.have.status(204);",
"});"
],
"type": "text/javascript",
"packages": {}
}
},
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"bpn\": \"{{TRUDY_BPN}}\",\n \"did\": \"{{TRUDY_DID}}\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{BDRS_MGMT_URL}}/bpn-directory",
"host": [
"{{BDRS_MGMT_URL}}"
],
"path": [
"bpn-directory"
]
}
},
"response": []
}
]
}
],
"auth": {
Expand Down Expand Up @@ -579,6 +734,26 @@
"value": "BPNL000000000003",
"type": "string"
},
{
"key": "ALICE_DID",
"value": "did:web:miw%3A8000:BPNL000000000001",
"type": "string"
},
{
"key": "BOB_DID",
"value": "did:web:miw%3A8000:BPNL000000000002",
"type": "string"
},
{
"key": "TRUDY_DID",
"value": "did:web:miw%3A8000:BPNL000000000003",
"type": "string"
},
{
"key": "BDRS_MGMT_URL",
"value": "localhost/bdrs-mgmt/api/management",
"type": "string"
},
{
"key": "BUSINESS_PARTNER_GROUP",
"value": "gold-partners",
Expand Down
21 changes: 21 additions & 0 deletions mxd/seed_data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,27 @@ resource "kubernetes_job" "seed_connectors_via_mgmt_api" {
name = "seed-collection"
}
}

container {
name = "newman-bdrs"
image = "postman/newman:ubuntu"
command = [
"newman", "run",
"--folder", "SeedBDRS",
"--env-var", "BDRS_MGMT_URL=${local.bdrs-mgmt-url}",
"--env-var", "ALICE_DID=did:web:miw%3A${var.miw-api-port}:${var.alice-bpn}",
"--env-var", "BOB_DID=did:web:miw:${var.miw-api-port}:${var.bob-bpn}",
"--env-var", "TRUDY_DID=did:web:miw:${var.miw-api-port}:${var.trudy-bpn}",
"--env-var", "ALICE_BPN=${var.alice-bpn}",
"--env-var", "BOB_BPN=${var.bob-bpn}",
"--env-var", "TRUDY_BPN=${var.trudy-bpn}",
"/opt/collection/${local.newman_collection_name}"
]
volume_mount {
mount_path = "/opt/collection"
name = "seed-collection"
}
}
volume {
name = "seed-collection"
config_map {
Expand Down

0 comments on commit 0bb721e

Please sign in to comment.