Skip to content
Snippets Groups Projects
Verified Commit 50d6fb89 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

ENH: Add linkahead

parent 298d734f
No related branches found
No related tags found
No related merge requests found
Pipeline #58211 failed
......@@ -860,3 +860,26 @@ query for `DataProcessorCredentials` in the database.
The MVD uses the default `EdcScopeToCriterionTransformer` to achieve this. It is recommended to implement a custom
`ScopeToCriterionTransformer` for an actual production scenario.
## Use Minikube as Alternative to KinD
Build the docker images as described above (section 5.1). Then, instead of
moving on to section 5.2, do the following:
0. `alias minikube='minikube -p mvd'`
1. `alias kubectl='minikube kubectl --'`
2. `minikube start`
3. `minikube addons enable ingress`
4. Wait for the ingress controller to become available:
```
kubectl wait --namespace ingress-nginx \
--for=condition=ready pod \
--selector=app.kubernetes.io/component=controller \
--timeout=90s
```
5. Forward the local port 80 to the ingress controller:
`sudo ssh -i $(minikube ssh-key) docker@$(minikube ip) -L 80:localhost:80`
6. Load the images:
`minikube image load controlplane:latest dataplane:latest identity-hub:latest catalog-server:latest sts:latest`
Now you can go on with starting the pods with `terraform init`, `terraform apply` etc. (see above, section 5.2).
resource "kubernetes_ingress_v1" "linkahead-ingress" {
metadata {
name = "${var.instance-name}-ingress"
namespace = var.namespace
annotations = {
#"nginx.ingress.kubernetes.io/rewrite-target" = "/$2"
"nginx.ingress.kubernetes.io/use-regex" = "true"
#"nginx.ingress.kubernetes.io/ssl-passthrough" = "true"
}
}
spec {
ingress_class_name = "nginx"
rule {
http {
path {
path = "/${var.instance-name}/linkahead(/|$)(.*)"
backend {
service {
name = kubernetes_service.linkahead-service.metadata.0.name
port {
number = var.linkahead-port
}
}
}
}
}
}
}
}
resource "kubernetes_deployment" "linkahead" {
metadata {
name = local.app-name
namespace = var.namespace
labels = {
App = local.app-name
}
}
spec {
replicas = 1
selector {
match_labels = {
App = local.app-name
}
}
template {
metadata {
labels = {
App = local.app-name
}
}
spec {
container {
image = local.linkahead-image
name = local.app-name
env_from {
config_map_ref {
name = kubernetes_config_map.linkahead-env.metadata[0].name
}
}
port {
container_port = 10080
name = "linkahead-port"
}
# dynamic "volume_mount" {
# for_each = toset(var.init-sql-configs)
# content {
# mount_path = "/docker-entrypoint-initdb.d/${volume_mount.value}.sql"
# name = volume_mount.value
# sub_path = "${volume_mount.value}.sql"
# read_only = true
# }
# }
# Uncomment this to assign (more) resources
# resources {
# limits = {
# cpu = "2"
# memory = "512Mi"
# }
# requests = {
# cpu = "250m"
# memory = "50Mi"
# }
# }
liveness_probe {
tcp_socket {
port = var.linkahead-port
}
failure_threshold = 10
period_seconds = 5
timeout_seconds = 30
}
}
# dynamic "volume" {
# for_each = toset(var.init-sql-configs)
# content {
# name = volume.value
# config_map {
# name = volume.value
# }
# }
# }
}
}
}
}
resource "kubernetes_config_map" "linkahead-env" {
metadata {
name = "${local.app-name}-env"
namespace = var.namespace
}
data = {
CAOSDB_CONFIG_AUTH_OPTIONAL = "TRUE"
CAOSDB_CONFIG_MYSQL_HOST = local.mariadb-host
CAOSDB_CONFIG_MYSQL_PORT = local.mariadb-port
CAOSDB_CONFIG_CONTEXT_ROOT = "/${var.instance-name}/linkahead"
NO_TLS = "1"
DEBUG = "1"
}
}
resource "kubernetes_service" "linkahead-service" {
metadata {
name = "${local.app-name}-service"
namespace = var.namespace
}
spec {
selector = {
App = kubernetes_deployment.linkahead.spec.0.template.0.metadata[0].labels.App
}
port {
name = "linkahead-port"
port = var.linkahead-port
target_port = 10080
}
}
}
locals {
mariadb-host = "${var.instance-name}-mariadb-service"
mariadb-port = 3306
app-name = "${var.instance-name}-linkahead"
linkahead-image = "indiscale/linkahead:dev"
}
#
# Copyright (c) 2024 Metaform Systems, Inc.
#
# 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:
# Metaform Systems, Inc. - initial API and implementation
#
variable "instance-name" {
description = "Unique name for the LinkAhead instance"
}
variable "namespace" {
description = "kubernetes namespace where the LinkAhead instance is deployed"
}
variable "linkahead-port" {
description = "Linkahead http port"
default = 10080
}
resource "kubernetes_deployment" "mariadb" {
metadata {
name = local.app-name
namespace = var.namespace
labels = {
App = local.app-name
}
}
spec {
replicas = 1
selector {
match_labels = {
App = local.app-name
}
}
template {
metadata {
labels = {
App = local.app-name
}
}
spec {
container {
image = local.mariadb-image
name = local.app-name
env_from {
config_map_ref {
name = kubernetes_config_map.mariadb-env.metadata[0].name
}
}
port {
container_port = 3306
name = "mariadb-port"
}
# dynamic "volume_mount" {
# for_each = toset(var.init-sql-configs)
# content {
# mount_path = "/docker-entrypoint-initdb.d/${volume_mount.value}.sql"
# name = volume_mount.value
# sub_path = "${volume_mount.value}.sql"
# read_only = true
# }
# }
# Uncomment this to assign (more) resources
# resources {
# limits = {
# cpu = "2"
# memory = "512Mi"
# }
# requests = {
# cpu = "250m"
# memory = "50Mi"
# }
# }
liveness_probe {
tcp_socket {
port = 3306
}
failure_threshold = 10
period_seconds = 5
timeout_seconds = 30
}
}
# dynamic "volume" {
# for_each = toset(var.init-sql-configs)
# content {
# name = volume.value
# config_map {
# name = volume.value
# }
# }
# }
}
}
}
}
resource "kubernetes_config_map" "mariadb-env" {
metadata {
name = "${local.app-name}-env"
namespace = var.namespace
}
data = {
MYSQL_ROOT_PASSWORD = "caosdb1234"
}
}
resource "kubernetes_service" "mariadb-service" {
metadata {
name = "${local.app-name}-service"
namespace = var.namespace
}
spec {
selector = {
App = kubernetes_deployment.mariadb.spec.0.template.0.metadata[0].labels.App
}
port {
name = "mariadb-port"
port = var.database-port
target_port = var.database-port
}
}
}
locals {
app-name = "${var.instance-name}-mariadb"
mariadb-image = "mariadb:10.11"
db-ip = kubernetes_service.mariadb-service.spec.0.cluster_ip
db-url = "${kubernetes_service.mariadb-service.metadata[0].name}:${var.database-port}"
db-host = kubernetes_service.mariadb-service.metadata[0].name
}
#
# Copyright (c) 2024 Metaform Systems, Inc.
#
# 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:
# Metaform Systems, Inc. - initial API and implementation
#
output "instance-name" {
value = var.instance-name
}
output "database-port" {
value = var.database-port
}
output "database-url" {
value = local.db-url
}
output "database-host" {
value = local.db-host
}
output "database-ip" {
value = local.db-ip
}
#
# Copyright (c) 2024 Metaform Systems, Inc.
#
# 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:
# Metaform Systems, Inc. - initial API and implementation
#
variable "instance-name" {
description = "Unique name for the Mariadb instance"
}
variable "database-port" {
default = 3306
}
variable "init-sql-configs" {
description = "Name of config maps with init sql scripts"
default = []
}
variable "namespace" {
description = "kubernetes namespace where the Mariadb instance is deployed"
}
......@@ -29,3 +29,11 @@ output "provider-jdbc-url" {
provider-manufacturing = "jdbc:postgresql://${module.provider-postgres.database-url}/provider_manufacturing"
}
}
output "provider-mariadb" {
value = {
host = module.provider-mariadb.database-host
port = module.provider-mariadb.database-port
ip = module.provider-mariadb.database-ip
}
}
......@@ -99,7 +99,20 @@ module "provider-vault" {
namespace = kubernetes_namespace.ns.metadata.0.name
}
# Postgres database for the consumer
# Mariadb database for provider linkahead
module "provider-mariadb" {
source = "./modules/mariadb"
instance-name = "provider"
namespace = kubernetes_namespace.ns.metadata.0.name
}
module "provider-linkahead" {
source = "./modules/linkahead"
instance-name = "provider"
namespace = kubernetes_namespace.ns.metadata.0.name
}
# Postgres database for the provider
module "provider-postgres" {
depends_on = [kubernetes_config_map.postgres-initdb-config-cs]
source = "./modules/postgres"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment