Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 5c44a01

Browse files
Feature/101 create clustered deployment (#105)
* added cosmos-based transfer process store * added barebones cosmos-db-based transferprocess store * fixed GH actions config error * fixed missing line breaks * fixed serialization problems with TransferProcesses * made DataEntry non-generic * fixed i-tests * added more tests for the CosmosDbStore * re-enabled terraform plan * re-enabled terraform plan * really reenabled... * disabled wronly enabled test * replaced nextForState with a transfaction-safe storedProcedure * removed explicit lock/unlock feature * only run test in CI * fixed terraform format, removed secret * same connector should be able to renew the lease * deploy the connector instance only after the storage account is ready * code cosmetics * try to run terraform after docker images are built * removed branch restriction * disabled azure vault tests * removed commented code * reenabled terraform * re-enabled taint and apply steps on pushes on main * added lease/break-lease behaviour to all modifying calls * code cleanup. added a retry policy that retries after request throttling * added unique connectorId to the lease mechanism * fixed CI switch * PR updates * created a simple kubernetes yaml to deploy the connector * create AKS cluster for the connector * deploy the connector using a load balancer * deploy app and ingress controller via K8s manifest * ingress is now provisioned with TF * deploy connector app via TF * replaced single-instance connector deployment with clustered deployment * moved config for the certificate storage to variables Co-authored-by: Paul Latzelsperger <[email protected]>
1 parent 9558471 commit 5c44a01

File tree

9 files changed

+360
-55
lines changed

9 files changed

+360
-55
lines changed

integration/integration-core/src/test/java/ClientRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
@ExtendWith(DagxExtension.class)
4040
@Disabled
4141
public class ClientRunner {
42-
private static final String PROVIDER_CONNECTOR = "http://dev-dagx.westeurope.azurecontainer.io:8181";
42+
private static final String PROVIDER_CONNECTOR = "http://dev-connector.westeurope.cloudapp.azure.com/";
4343
private static final TokenResult US_TOKEN = TokenResult.Builder.newInstance().token("mock-us").build();
4444
private static final TokenResult EU_TOKEN = TokenResult.Builder.newInstance().token("mock-eu").build();
4545
private static final DataEntry EU_ARTIFACT = DataEntry.Builder.newInstance().id("test123").build();

scripts/aks-cluster/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ resource "azurerm_resource_group" "clusterrg" {
2121
resource "azurerm_public_ip" "aks-cluster-public-ip" {
2222
resource_group_name = azurerm_kubernetes_cluster.default.node_resource_group
2323
location = azurerm_resource_group.clusterrg.location
24-
domain_name_label = var.dns
24+
domain_name_label = var.dnsPrefix
2525
allocation_method = "Static"
2626
name = "dagxPublicIp"
2727
sku = "Standard"

scripts/aks-cluster/variables.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
variable "kubernetes_version" {
32
default = "1.19"
43
}
@@ -11,6 +10,6 @@ variable "location" {
1110
type = string
1211
}
1312

14-
variable "dns" {
15-
type=string
13+
variable "dnsPrefix" {
14+
type = string
1615
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
//resource "tls_private_key" "connector-ingress-pk" {
2+
// algorithm = "ECDSA"
3+
//}
4+
//
5+
//resource "tls_self_signed_cert" "connector-ingress-cert" {
6+
// allowed_uses = [
7+
// "server_auth",
8+
// "digital_signature"
9+
// ]
10+
// key_algorithm = tls_private_key.connector-ingress-pk.algorithm
11+
// private_key_pem = tls_private_key.connector-ingress-pk.private_key_pem
12+
// validity_period_hours = 72
13+
// early_renewal_hours = 12
14+
// subject {
15+
// common_name = var.public-ip.fqdn
16+
// organization = "Gaia-X Data Appliance"
17+
// }
18+
// dns_names = [
19+
// var.public-ip.fqdn]
20+
//}
21+
//
22+
//resource "kubernetes_secret" "connector-ingress-secret" {
23+
// metadata {
24+
// namespace = kubernetes_namespace.connector.metadata[0].name
25+
// name = var.connector_ingress_cert_name
26+
// }
27+
// data = {
28+
// "tls.crt" = tls_private_key.connector-ingress-pk.public_key_pem
29+
// "tls.key" = tls_private_key.connector-ingress-pk.private_key_pem
30+
// }
31+
//}
32+
//
33+
resource "kubernetes_ingress" "connector-ingress-route" {
34+
metadata {
35+
name = "connector-ingress"
36+
namespace = kubernetes_namespace.connector.metadata[0].name
37+
annotations = {
38+
"kubernetes.io/ingress.class": "nginx"
39+
"nginx.ingress.kubernetes.io/ssl-redirect" : "false"
40+
"nginx.ingress.kubernetes.io/use-regex" : "true"
41+
"nginx.ingress.kubernetes.io/rewrite-target" : "/$1"
42+
}
43+
}
44+
spec {
45+
rule {
46+
http {
47+
path {
48+
path = "/(.*)"
49+
backend {
50+
service_name = var.connector_service_name
51+
service_port = 8181
52+
}
53+
}
54+
}
55+
}
56+
// tls {
57+
// hosts = [var.public-ip.fqdn]
58+
// secret_name = kubernetes_secret.connector-ingress-secret.metadata[0].name
59+
// }
60+
}
61+
}
62+
63+
resource "helm_release" "ingress-controller" {
64+
chart = "ingress-nginx"
65+
name = "connector-ingress-controller"
66+
namespace = kubernetes_namespace.connector.metadata[0].name
67+
repository = "https://kubernetes.github.io/ingress-nginx"
68+
69+
set {
70+
name = "controller.replicaCount"
71+
value = "1"
72+
}
73+
set {
74+
name = "controller.service.loadBalancerIP"
75+
value = var.public-ip.ip_address
76+
}
77+
set {
78+
name = "controller.service.annotations.service.beta.kubernetes.io/azure-dns-label-name"
79+
value = var.public-ip.domain_name_label
80+
}
81+
}
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
terraform {
2+
required_providers {
3+
azurerm = {
4+
source = "hashicorp/azurerm"
5+
version = ">= 2.62.1"
6+
}
7+
kubernetes = {
8+
source = "hashicorp/kubernetes"
9+
version = ">= 2.0.3"
10+
}
11+
helm = {
12+
source = "hashicorp/helm"
13+
version = ">= 2.1.0"
14+
}
15+
tls = {
16+
17+
}
18+
}
19+
}
20+
21+
resource "tls_private_key" "connector-ingress-key" {
22+
algorithm = "ECDSA"
23+
}
24+
25+
resource "kubernetes_namespace" "connector" {
26+
metadata {
27+
name = "${var.resourcesuffix}-cons"
28+
}
29+
}
30+
31+
resource "local_file" "kubeconfig" {
32+
content = var.kubeconfig
33+
filename = "${path.root}/kubeconfig"
34+
}
35+
36+
resource "kubernetes_secret" "connector-cert-secret" {
37+
metadata {
38+
name = "blobstore-key"
39+
namespace = kubernetes_namespace.connector.metadata[0].name
40+
}
41+
type = "Opaque"
42+
data = {
43+
azurestorageaccountname = var.certificate_mount_config.accountName
44+
azurestorageaccountkey = var.certificate_mount_config.accountKey
45+
}
46+
}
47+
48+
resource "kubernetes_deployment" "connector-deployment" {
49+
metadata {
50+
name = var.connector_service_name
51+
namespace = kubernetes_namespace.connector.id
52+
}
53+
spec {
54+
replicas = 2
55+
selector {
56+
match_labels = {
57+
app: var.connector_service_name
58+
}
59+
}
60+
template {
61+
metadata {
62+
labels = {
63+
app: var.connector_service_name
64+
}
65+
}
66+
spec {
67+
container {
68+
name = "connector"
69+
image = "ghcr.io/microsoft/data-appliance-gx/dagx-demo:latest"
70+
image_pull_policy = "Always"
71+
env {
72+
name = "CLIENTID"
73+
value = var.container_environment.clientId
74+
}
75+
env {
76+
name = "TENANTID"
77+
value = var.container_environment.tenantId
78+
}
79+
env {
80+
name = "VAULTNAME"
81+
value = var.container_environment.vaultName
82+
}
83+
env {
84+
name = "ATLAS_URL"
85+
value = var.container_environment.atlasUrl
86+
}
87+
env {
88+
name = "NIFI_URL"
89+
value = var.container_environment.nifiUrl
90+
}
91+
env {
92+
name = "NIFI_FLOW_URL"
93+
value = var.container_environment.nifiFlowUrl
94+
}
95+
env {
96+
name = "COSMOS_ACCOUNT"
97+
value = var.container_environment.cosmosAccount
98+
}
99+
env {
100+
name = "COSMOS_DB"
101+
value = var.container_environment.cosmosDb
102+
}
103+
port {
104+
container_port = 8181
105+
host_port = 8181
106+
protocol = "TCP"
107+
}
108+
volume_mount {
109+
mount_path = "/cert"
110+
name = "certificates"
111+
read_only = true
112+
}
113+
}
114+
volume {
115+
name = "certificates"
116+
azure_file {
117+
secret_name = kubernetes_secret.connector-cert-secret.metadata[0].name
118+
share_name = "certificates"
119+
}
120+
}
121+
}
122+
}
123+
}
124+
}
125+
126+
resource "kubernetes_service" "connector-cluster-ip" {
127+
metadata {
128+
name = var.connector_service_name
129+
namespace = kubernetes_namespace.connector.id
130+
}
131+
spec {
132+
type = "ClusterIP"
133+
port {
134+
port = 8181
135+
}
136+
selector = {
137+
app: var.connector_service_name
138+
}
139+
}
140+
}
141+
142+
output "connector-cluster-namespace" {
143+
value = kubernetes_namespace.connector.metadata[0].name
144+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
variable "kubernetes-namespace" {
2+
description = "The namespace for the kubernetes deployment"
3+
default = "dagx"
4+
}
5+
6+
variable "cluster_name" {
7+
type = string
8+
}
9+
10+
variable "kubeconfig" {
11+
type = string
12+
}
13+
14+
variable "resourcesuffix" {
15+
type = string
16+
}
17+
18+
variable "location" {
19+
type = string
20+
default = "westeurope"
21+
}
22+
23+
variable "tenant_id" {
24+
type = string
25+
}
26+
27+
variable "connector_service_name" {
28+
type = string
29+
default = "connector-demo"
30+
}
31+
32+
variable "connector_ingress_cert_name" {
33+
default = "connector-ingress-tls"
34+
}
35+
variable "container_environment" {
36+
type = object({
37+
clientId = string
38+
tenantId = string
39+
vaultName = string
40+
atlasUrl = string
41+
nifiUrl = string
42+
nifiFlowUrl = string
43+
cosmosAccount = string
44+
cosmosDb = string
45+
})
46+
}
47+
48+
variable "certificate_mount_config"{
49+
type = object({
50+
accountName = string
51+
accountKey = string
52+
})
53+
54+
}
55+
56+
variable "public-ip" {
57+
type = object({
58+
ip_address = string
59+
fqdn = string
60+
domain_name_label = string
61+
})
62+
}

0 commit comments

Comments
 (0)