Skip to content

Commit

Permalink
update deployment for data-service-api
Browse files Browse the repository at this point in the history
  • Loading branch information
paullatzelsperger committed Oct 1, 2024
1 parent a0e5df2 commit 03c938a
Show file tree
Hide file tree
Showing 10 changed files with 169 additions and 164 deletions.
3 changes: 2 additions & 1 deletion mxd-runtimes/data-service-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ dependencies {

implementation(libs.edc.http)
implementation(libs.edc.http.lib)
runtimeOnly(libs.edc.core.connector)
implementation(libs.edc.boot)

runtimeOnly(libs.edc.core.connector)
runtimeOnly(libs.edc.api.observability)
runtimeOnly(libs.edc.sql.transactionlocal)

Expand Down
9 changes: 4 additions & 5 deletions mxd-runtimes/data-service-api/src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2024 SAP SE
# Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
Expand All @@ -8,7 +8,7 @@
# SPDX-License-Identifier: Apache-2.0
#
# Contributors:
# SAP SE - initial API and implementation
# Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
#
#

Expand All @@ -33,13 +33,12 @@ RUN adduser \
USER "$APP_USER"
WORKDIR /app

COPY ${JAR} backend-service.jar
COPY ${JAR} data-service.jar

# health check is handled by K8S
HEALTHCHECK NONE

CMD ["java", \
"-Djava.util.logging.config.file=/app/logging.properties", \
"-Djava.security.egd=file:/dev/urandom", \
"-jar", \
"backend-service.jar"]
"data-service.jar"]
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,21 @@
import org.eclipse.edc.web.spi.configuration.WebServiceConfigurer;
import org.eclipse.edc.web.spi.configuration.WebServiceSettings;
import org.eclipse.tractusx.mxd.dataservice.api.DataServiceApiController;
import org.eclipse.tractusx.mxd.dataservice.model.DataRecord;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.IntStream;

@Extension(DataServiceExtension.NAME)
public class DataServiceExtension implements ServiceExtension {

public static final String NAME = "MXD Demo Backend Services";
private final static int DEFAULT_PORT = 8080;
public static final String DEFAULT_PATH = "/";
public static final String DATA_API_CONTEXT_NAME = "data";
private final static int DEFAULT_PORT = 8080;
@SettingContext("Version API context setting key")
private static final String DATA_API_CONFIG_KEY = "web.http.data";


@Inject
private WebService webService;
@Inject
private WebServiceConfigurer configurer;
@Inject
private WebServer webServer;


public static final WebServiceSettings SETTINGS = WebServiceSettings.Builder.newInstance()
.apiConfigKey(DATA_API_CONFIG_KEY)
.contextAlias(DATA_API_CONTEXT_NAME)
Expand All @@ -55,6 +47,12 @@ public class DataServiceExtension implements ServiceExtension {
.useDefaultContext(false)
.name("Data Service API")
.build();
@Inject
private WebService webService;
@Inject
private WebServiceConfigurer configurer;
@Inject
private WebServer webServer;

@Override
public String name() {
Expand All @@ -65,7 +63,15 @@ public String name() {
public void initialize(ServiceExtensionContext context) {
var config = context.getConfig(DATA_API_CONFIG_KEY);
configurer.configure(config, webServer, SETTINGS);
webService.registerResource(DATA_API_CONTEXT_NAME, new DataServiceApiController(new ConcurrentHashMap<>()));
var database = new ConcurrentHashMap<String, DataRecord>();
populate(database);
webService.registerResource(DATA_API_CONTEXT_NAME, new DataServiceApiController(database));
}

private void populate(Map<String, DataRecord> database) {
IntStream.range(0, 10)
.mapToObj(i -> new DataRecord("id" + i, "Record Nr. " + i, "This record nr. " + i))
.forEach(dr -> database.put(dr.id(), dr));
}

}
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
#
# Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
#
# 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:
# Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
#
#

org.eclipse.tractusx.mxd.dataservice.DataServiceExtension
116 changes: 0 additions & 116 deletions mxd/backend-service.tf

This file was deleted.

126 changes: 126 additions & 0 deletions mxd/data-service-api.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
#
# Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
#
# 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:
# Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
#
#

resource "kubernetes_deployment" "data-service-api" {

metadata {
name = "data-service-api"
namespace = kubernetes_namespace.mxd-ns.metadata.0.name
labels = {
App = "data-service-api"
}
}

spec {
replicas = 1
selector {
match_labels = {
App = "data-service-api"
}
}
template {
metadata {
labels = {
App = "data-service-api"
}
}
spec {
container {
name = "data-service-api"
image = "data-service-api:latest"
image_pull_policy = "Never"

port {
container_port = 8080
name = "api-port"
}

env {
name = "web.http.data.port"
value = 8080
}
env {
name = "web.http.data.path"
value = "/"
}
env {
name = "web.http.port"
value = 8181
}
env {
name = "web.http.path"
value = "/api"
}
env {
name = "JAVA_TOOL_OPTIONS"
value = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044"
}
readiness_probe {
http_get {
path = "/api/check/readiness"
port = 8181
}
initial_delay_seconds = 5
period_seconds = 10
timeout_seconds = 5
failure_threshold = 3
success_threshold = 1
}
liveness_probe {
http_get {
path = "/api/check/liveness"
port = 8181
}
initial_delay_seconds = 5
period_seconds = 10
timeout_seconds = 5
failure_threshold = 3
success_threshold = 1
}

startup_probe {
http_get {
path = "/api/check/startup"
port = 8181
}
initial_delay_seconds = 5
period_seconds = 10
timeout_seconds = 5
failure_threshold = 3
success_threshold = 1
}
}
}
}
}
}


resource "kubernetes_service" "data-service-api" {
metadata {
name = "data-service-api"
namespace = var.namespace
}
spec {
type = "NodePort"
selector = {
App = kubernetes_deployment.data-service-api.spec.0.template.0.metadata[0].labels.App
}
port {
port = 8080
name = "api-port"
}
}
}

11 changes: 0 additions & 11 deletions mxd/modules/connector/ingress.tf
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,6 @@ resource "kubernetes_ingress_v1" "mxd-ingress" {
}
}

path {
path = "/backend-service(/|$)(.*)"
backend {
service {
name = "backend-service"
port {
number = 8080
}
}
}
}
}
}
}
Expand Down
Loading

0 comments on commit 03c938a

Please sign in to comment.