Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 29 additions & 12 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
resource "kubernetes_secret_v1" "altinitycloud_cloud_connect" {
# https://www.terraform.io/language/state/sensitive-data
count = var.pem != "" ? 1 : 0
metadata {
name = "cloud-connect"
namespace = kubernetes_namespace_v1.altinitycloud_system.metadata[0].name
labels = {
app = "cloud-connect"
}
}
data = {

data = var.pem != "" ? {
"cloud-connect.pem" = var.pem
}
"ca.crt" = var.ca_crt
} : {}
}

resource "kubernetes_deployment_v1" "altinitycloud_cloud_connect" {
Expand Down Expand Up @@ -41,6 +41,14 @@ resource "kubernetes_deployment_v1" "altinitycloud_cloud_connect" {
}
spec {
service_account_name = "cloud-connect"
dynamic "host_aliases" {
for_each = var.host_alias_ip != "" ? [1] : []
content {
ip = var.host_alias_ip
hostnames = [var.host_alias_name]
}
}

volume {
name = "secret"
secret {
Expand All @@ -51,14 +59,23 @@ resource "kubernetes_deployment_v1" "altinitycloud_cloud_connect" {
name = "cloud-connect"
image = var.image != "" ? var.image : "altinity/cloud-connect:${local.version}"
image_pull_policy = var.image_pull_policy != "" ? var.image_pull_policy : local.version == "latest-master" ? "Always" : "IfNotPresent"
args = [
"-u",
var.url,
"-i",
"/etc/cloud-connect/cloud-connect.pem",
"--debug-addr",
":7777"
]

args = concat(
[
"-u",
var.url,
"-i",
"/etc/cloud-connect/cloud-connect.pem",
"--debug-addr",
":7777",
"--dual-tcp-udp",
"--ca-crt",
"/etc/cloud-connect/ca.crt"
],
var.ca_crt != "" ? ["--ca-crt", "/etc/cloud-connect/ca.crt"] : [],
var.dual_tcp_udp ? ["--dual-tcp-udp"] : []
)

volume_mount {
name = "secret"
mount_path = "/etc/cloud-connect"
Expand Down
26 changes: 26 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,29 @@ variable "namespace_labels" {
description = "Map of labels for `altinity-cloud-*` namespaces"
default = {}
}

variable "ca_crt" {
type = string
description = <<EOT
The certificate authority of dev environment. This is only mean for local development, should be omitted in production.
EOT
default = ""
}

variable "host_alias_ip" {
type = string
description = "The IP address of the host alias. This is only mean for local development, should be omitted in production."
default = ""
}

variable "host_alias_name" {
type = string
description = "The hostname of the host alias. This is only mean for local development, should be omitted in production."
default = ""
}

variable "dual_tcp_udp" {
type = bool
description = "Enable dual TCP/UDP mode. This is only mean for local development, should be omitted in production."
default = false
}