diff --git a/terraform/ovh/network/main.tf b/terraform/ovh/network/main.tf new file mode 100644 index 0000000..4dcf11a --- /dev/null +++ b/terraform/ovh/network/main.tf @@ -0,0 +1,19 @@ +# Copyright 2025 Dynamic Solutions Sp. z o.o. sp.k. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +module "tf_network" { + source ="/Users/andrzej/repo/terraform-ovh-platform/modules/network" + service_name = var.service_name +} diff --git a/terraform/ovh/network/outputs.tf b/terraform/ovh/network/outputs.tf new file mode 100644 index 0000000..003ebfb --- /dev/null +++ b/terraform/ovh/network/outputs.tf @@ -0,0 +1,31 @@ +# Copyright 2025 Dynamic Solutions Sp. z o.o. sp.k. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +output "floatingip" { + description = "Allocated floating IP for future usage" + value = module.tf_network.floatingip +} + +output "nodes_subnet_id" { + description = "Nodes subnet ID" + value = module.tf_network.nodes_subnet_id +} + +output "network_id" { + description = "Network id to attach cluster" + value = module.tf_network.network_id +} + diff --git a/terraform/ovh/network/providers.tf b/terraform/ovh/network/providers.tf new file mode 100644 index 0000000..1ea4f5a --- /dev/null +++ b/terraform/ovh/network/providers.tf @@ -0,0 +1,20 @@ +# Copyright 2025 Dynamic Solutions Sp. z o.o. sp.k. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +provider "ovh" { + +# TODO ADD you OVH credentials +} diff --git a/terraform/ovh/network/variables.tf b/terraform/ovh/network/variables.tf new file mode 100644 index 0000000..353c08c --- /dev/null +++ b/terraform/ovh/network/variables.tf @@ -0,0 +1,20 @@ +# Copyright 2025 Dynamic Solutions Sp. z o.o. sp.k. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +variable "service_name" { + description = "The id of the public OVH cloud project" + type = string +} \ No newline at end of file diff --git a/terraform/ovh/network/versions.tf b/terraform/ovh/network/versions.tf new file mode 100644 index 0000000..8c813cc --- /dev/null +++ b/terraform/ovh/network/versions.tf @@ -0,0 +1,29 @@ +# Copyright 2025 Dynamic Solutions Sp. z o.o. sp.k. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +terraform { + required_version = ">= 1.0.0" + required_providers { + ovh = { + source = "ovh/ovh" + version = "~> 2.0.0" + } + openstack = { + source = "terraform-provider-openstack/openstack" + version = "~> 1.43.0" + } + } +} \ No newline at end of file diff --git a/terraform/ovh/platform/config/pulsar-kaap/values.yaml b/terraform/ovh/platform/config/pulsar-kaap/values.yaml new file mode 100644 index 0000000..8451b85 --- /dev/null +++ b/terraform/ovh/platform/config/pulsar-kaap/values.yaml @@ -0,0 +1,46 @@ +cluster: + create: true + spec: + global: + name: pulsar + image: apachepulsar/pulsar:4.0.0 + restartOnConfigMapChange: true + zookeeper: + replicas: 1 + dataVolume: + name: data + size: 100M + resources: + requests: + cpu: "0.1" + memory: "256Mi" + bookkeeper: + replicas: 1 + volumes: + journal: + size: 5Gi + ledgers: + size: 20Gi + resources: + requests: + cpu: "0.4" + memory: "2Gi" + broker: + replicas: 1 + config: + managedLedgerDefaultEnsembleSize: "1" + managedLedgerDefaultWriteQuorum: "1" + managedLedgerDefaultAckQuorum: "1" + compactionServiceFactoryClassName: "org.apache.pulsar.compaction.EventTimeCompactionServiceFactory" + resources: + requests: + cpu: "0.4" + memory: "1Gi" + proxy: + replicas: 0 + autorecovery: + replicas: 0 + bastion: + replicas: 0 + functionsWorker: + replicas: 0 diff --git a/terraform/ovh/platform/main.tf b/terraform/ovh/platform/main.tf new file mode 100644 index 0000000..0f32691 --- /dev/null +++ b/terraform/ovh/platform/main.tf @@ -0,0 +1,56 @@ +# Copyright 2025 Dynamic Solutions Sp. z o.o. sp.k. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +module "cluster" { + source = "/Users/andrzej/repo/terraform-ovh-platform/modules/cluster" + service_name = var.service_name + kubeconfig_path = "${path.module}/.env/kubeconfig" + network_id = var.public_ip_address == null || var.public_ip_address == "" ? null: var.network_id + nodes_subnet_id = var.public_ip_address == null || var.public_ip_address == "" ? null: var.nodes_subnet_id + region = var.region +} + +locals { + ingress_controller_nginx_settings_without_static_ip = { + "controller.replicaCount" : 1 + "controller.service.annotations.loadbalancer\\.ovhcloud\\.com/class" : "octavia" + } + ingress_controller_nginx_settings_with_static_ip = { + "controller.service.loadBalancerIP" : var.public_ip_address + "controller.replicaCount" : 1 + "controller.service.annotations.loadbalancer\\.ovhcloud\\.com/class" : "octavia" + } +} + +module "streamx" { + source = "streamx-dev/charts/helm" + version = "0.0.4" + + cert_manager_lets_encrypt_issuer_acme_email = var.cert_manager_lets_encrypt_issuer_acme_email + ingress_controller_nginx_settings = var.public_ip_address == null || var.public_ip_address == "" ? local.ingress_controller_nginx_settings_without_static_ip : local.ingress_controller_nginx_settings_with_static_ip + pulsar_kaap_values = [ + file("${path.module}/config/pulsar-kaap/values.yaml") + ] + streamx_operator_image_pull_secret_registry_email = var.streamx_operator_image_pull_secret_registry_email + streamx_operator_image_pull_secret_registry_password = var.streamx_operator_image_pull_secret_registry_password + streamx_operator_chart_repository_username = "_json_key_base64" + streamx_operator_chart_repository_password = var.streamx_operator_image_pull_secret_registry_password + ingress_controller_nginx_timeout = 300 + cert_manager_timeout = 300 + pulsar_kaap_timeout = 300 + streamx_operator_timeout = 300 + depends_on = [module.cluster] +} \ No newline at end of file diff --git a/terraform/ovh/platform/outputs.tf b/terraform/ovh/platform/outputs.tf new file mode 100644 index 0000000..9f81c43 --- /dev/null +++ b/terraform/ovh/platform/outputs.tf @@ -0,0 +1,31 @@ +# Copyright 2025 Dynamic Solutions Sp. z o.o. sp.k. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +output "kubeconfig_path" { + description = "K8s cluster kubeconfig file path" + value = module.cluster.kubeconfig_path +} + +output "kubeconfig" { + description = "K8s cluster kubeconfig" + value = module.cluster.kubeconfig + sensitive = true +} + +output "loadbalancer_ip" { + description = "K8s cluster Load Balancer IP" + value = module.streamx.loadbalancer_ip +} \ No newline at end of file diff --git a/terraform/ovh/platform/providers.tf b/terraform/ovh/platform/providers.tf new file mode 100644 index 0000000..56138c3 --- /dev/null +++ b/terraform/ovh/platform/providers.tf @@ -0,0 +1,44 @@ +# Copyright 2025 Dynamic Solutions Sp. z o.o. sp.k. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +provider "ovh" { + # TODO ADD you OVH credentials +} + + +provider "kubernetes" { + host = module.cluster.host + client_certificate = module.cluster.client_certificate + client_key = module.cluster.client_key + cluster_ca_certificate = module.cluster.cluster_ca_certificate +} + +provider "helm" { + kubernetes { + host = module.cluster.host + client_certificate = module.cluster.client_certificate + client_key = module.cluster.client_key + cluster_ca_certificate = module.cluster.cluster_ca_certificate + } +} + +provider "kubectl" { + load_config_file = false + host = module.cluster.host + client_certificate = module.cluster.client_certificate + client_key = module.cluster.client_key + cluster_ca_certificate = module.cluster.cluster_ca_certificate +} diff --git a/terraform/ovh/platform/variables.tf b/terraform/ovh/platform/variables.tf new file mode 100644 index 0000000..50bae09 --- /dev/null +++ b/terraform/ovh/platform/variables.tf @@ -0,0 +1,64 @@ +# Copyright 2025 Dynamic Solutions Sp. z o.o. sp.k. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +variable "service_name" { + description = "The id of the public OVH cloud project" + type = string +} + +variable "cluster_name" { + default = "streamx" + description = "The name of the kubernetes cluster." + type = string +} + +variable "region" { + default = "waw1" + description = "Region of cloud deployment" + type = string +} + +variable "network_id" { + description = "Network id to attach cluster" + type = string +} + +variable "nodes_subnet_id" { + description = "Nodes subnet ID" + type = string +} + +variable "cert_manager_lets_encrypt_issuer_acme_email" { + description = "Email passed to acme server." + type = string +} + +variable "streamx_operator_image_pull_secret_registry_email" { + description = "StreamX Operator container image registry user email." + type = string +} + +variable "streamx_operator_image_pull_secret_registry_password" { + description = "StreamX Operator container image registry user password." + type = string + sensitive = true +} + +variable "public_ip_address" { + default = null + description = "Public IP address" + type = string +} diff --git a/terraform/ovh/platform/versions.tf b/terraform/ovh/platform/versions.tf new file mode 100644 index 0000000..e97b7e2 --- /dev/null +++ b/terraform/ovh/platform/versions.tf @@ -0,0 +1,29 @@ +# Copyright 2025 Dynamic Solutions Sp. z o.o. sp.k. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +terraform { + required_version = ">= 1.0.0" + required_providers { + kubectl = { + source = "gavinbunney/kubectl" + version = "~> 1.14.0" + } + ovh = { + source = "ovh/ovh" + version = "~> 2.0.0" + } + } +} \ No newline at end of file diff --git a/terraform/ovh/state-backend/main.tf b/terraform/ovh/state-backend/main.tf new file mode 100644 index 0000000..e265c0d --- /dev/null +++ b/terraform/ovh/state-backend/main.tf @@ -0,0 +1,27 @@ +# Copyright 2025 Dynamic Solutions Sp. z o.o. sp.k. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +module "tf_state_backend" { + source ="/Users/andrzej/repo/terraform-ovh-platform/modules/state-backend" + ovh_public_cloud_project_id = var.service_name + region = var.region + bucket_name=var.bucket_name + s3_endpoint=var.s3_endpoint + tf_backends = { + "platform.tfstate" : "${path.module}/../platform/backend.tf" + "network.tfstate" : "${path.module}/../network/backend.tf" + } +} diff --git a/terraform/ovh/state-backend/outputs.tf b/terraform/ovh/state-backend/outputs.tf new file mode 100644 index 0000000..d9f8a1b --- /dev/null +++ b/terraform/ovh/state-backend/outputs.tf @@ -0,0 +1,30 @@ +# Copyright 2025 Dynamic Solutions Sp. z o.o. sp.k. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +output "access_key" { + description = "The access key created by the terraform script. To be used as `AWS_ACCESS_KEY_ID` ENV variable for Terraform S3 backend configuration." + value = module.tf_state_backend.access_key +} + +output "secret_key" { + description = "The secret key created by the terraform script. To be used as `AWS_SECRET_ACCESS_KEY` ENV variable for Terraform S3 backend configuration." + value = module.tf_state_backend.secret_key + sensitive = true +} + +output "tf_state_backend_config" { + description = "The Terraform state backend configuration that is set up to utilize a bucket created by this module." + value = module.tf_state_backend.tf_state_backend_config +} \ No newline at end of file diff --git a/terraform/ovh/state-backend/providers.tf b/terraform/ovh/state-backend/providers.tf new file mode 100644 index 0000000..f2d984a --- /dev/null +++ b/terraform/ovh/state-backend/providers.tf @@ -0,0 +1,19 @@ +# Copyright 2025 Dynamic Solutions Sp. z o.o. sp.k. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +provider "ovh" { + # TODO ADD you OVH credentials +} diff --git a/terraform/ovh/state-backend/variables.tf b/terraform/ovh/state-backend/variables.tf new file mode 100644 index 0000000..d0379d2 --- /dev/null +++ b/terraform/ovh/state-backend/variables.tf @@ -0,0 +1,38 @@ +# Copyright 2025 Dynamic Solutions Sp. z o.o. sp.k. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +variable "service_name" { + description = "The id of the public OVH cloud project" + type = string +} + +variable "region" { + default = "waw" + description = "S3 bucket location from [list](https://help.ovhcloud.com/csm/en-ie-public-cloud-storage-s3-location?id=kb_article_view&sysparm_article=KB0047393)" + type = string +} + +variable "s3_endpoint" { + default = "https://s3.waw.io.cloud.ovh.net/" + description = "OVH S3 endpoint from from [list](https://help.ovhcloud.com/csm/en-ie-public-cloud-storage-s3-location?id=kb_article_view&sysparm_article=KB0047393)" + type = string +} + +variable "bucket_name" { + default = "streamx-commerce-accelerator-bucket" + description = "S3 bucket name" + type = string +} diff --git a/terraform/ovh/state-backend/versions.tf b/terraform/ovh/state-backend/versions.tf new file mode 100644 index 0000000..4f419ec --- /dev/null +++ b/terraform/ovh/state-backend/versions.tf @@ -0,0 +1,28 @@ +# Copyright 2025 Dynamic Solutions Sp. z o.o. sp.k. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +terraform { + required_version = ">= 1.8.1" + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5.89.0" + } + ovh = { + source = "ovh/ovh" + version = "~> 2.0.0" + } + } +} \ No newline at end of file