From ac873297313d8ea0c824ad9dced4b073d8173dfb Mon Sep 17 00:00:00 2001 From: Guillaume Allee Date: Thu, 31 Oct 2024 13:53:39 +0100 Subject: [PATCH] * bump ovh provider to 1.0.0 * replace terraform by opentofu in CLI examples * update instance default flavor to gen 3 --- .../wordpress-k8s-mysql/01-kube/network.tf | 29 ------------------- .../wordpress-k8s-mysql/01-kube/provider.tf | 2 +- .../wordpress-k8s-mysql/01-kube/variables.tf | 4 +-- .../02-db-wordpress/provider.tf | 2 +- use-cases/wordpress-k8s-mysql/README.md | 23 ++++++++------- 5 files changed, 16 insertions(+), 44 deletions(-) diff --git a/use-cases/wordpress-k8s-mysql/01-kube/network.tf b/use-cases/wordpress-k8s-mysql/01-kube/network.tf index 161bef0..3d38fc0 100644 --- a/use-cases/wordpress-k8s-mysql/01-kube/network.tf +++ b/use-cases/wordpress-k8s-mysql/01-kube/network.tf @@ -20,32 +20,3 @@ resource "ovh_cloud_project_gateway" "gateway" { network_id = tolist(ovh_cloud_project_network_private.private_network.regions_attributes[*].openstackid)[0] subnet_id = ovh_cloud_project_network_private_subnet.subnet.id } - - -/*data "openstack_networking_network_v2" "ext_net" { - name = "Ext-Net" - external = true -} -resource "openstack_networking_network_v2" "network" { - name = "private_network" -} - - -resource "openstack_networking_subnet_v2" "subnet" { - name = "subnet" - network_id = openstack_networking_network_v2.network.id - cidr = "10.0.0.0/24" - gateway_ip = "10.0.0.254" - dns_nameservers = ["213.186.33.99"] - ip_version = 4 -} - -resource "openstack_networking_router_v2" "router" { - name = "router" - external_network_id = data.openstack_networking_network_v2.ext_net.id -} - -resource "openstack_networking_router_interface_v2" "router_itf_priv" { - router_id = openstack_networking_router_v2.router.id - subnet_id = openstack_networking_subnet_v2.subnet.id -}*/ \ No newline at end of file diff --git a/use-cases/wordpress-k8s-mysql/01-kube/provider.tf b/use-cases/wordpress-k8s-mysql/01-kube/provider.tf index e32a607..f8014be 100644 --- a/use-cases/wordpress-k8s-mysql/01-kube/provider.tf +++ b/use-cases/wordpress-k8s-mysql/01-kube/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { ovh = { source = "ovh/ovh" - version = "~> 0.43.1" + version = "~> 1.0.0" } } } diff --git a/use-cases/wordpress-k8s-mysql/01-kube/variables.tf b/use-cases/wordpress-k8s-mysql/01-kube/variables.tf index 2a3cd6b..471e001 100644 --- a/use-cases/wordpress-k8s-mysql/01-kube/variables.tf +++ b/use-cases/wordpress-k8s-mysql/01-kube/variables.tf @@ -8,10 +8,10 @@ variable "kubernetes" { variable "resource_prefix" { type = string - default = "tf-public-cloud-examples-workpress-on-mks-with-mysql-" + default = "tf-public-cloud-examples-wordpress-on-mks-with-mysql-" } variable "node_pool_flavor_name" { type = string - default = "b2-7" + default = "b3-8" } diff --git a/use-cases/wordpress-k8s-mysql/02-db-wordpress/provider.tf b/use-cases/wordpress-k8s-mysql/02-db-wordpress/provider.tf index e5f3a06..73de53f 100644 --- a/use-cases/wordpress-k8s-mysql/02-db-wordpress/provider.tf +++ b/use-cases/wordpress-k8s-mysql/02-db-wordpress/provider.tf @@ -2,7 +2,7 @@ terraform { required_providers { ovh = { source = "ovh/ovh" - version = "~> 0.43.1" + version = "~> 1.0.0" } helm = { diff --git a/use-cases/wordpress-k8s-mysql/README.md b/use-cases/wordpress-k8s-mysql/README.md index 659410e..d37f293 100644 --- a/use-cases/wordpress-k8s-mysql/README.md +++ b/use-cases/wordpress-k8s-mysql/README.md @@ -1,4 +1,4 @@ -# Deploy a Wordpress website and MySQL DB with Terraform +# Deploy a Wordpress website and MySQL DB with Terraform / OpenTofu The purpose of this tutorial is to create a Mysql database and a Wordpress website and link them together in a Kubernetes cluster. @@ -11,11 +11,12 @@ We will divide the project into two layers. The first layer is used to deploy th ## Requirements You need the following: -* [Terraform](https://www.terraform.io/) installed +* [Terraform](https://www.terraform.io/) or [OpenTofu](https://opentofu.org/) installed * an [OVHcloud Public cloud project](https://www.ovhcloud.com/en/public-cloud/) * OVHcloud API credentials * [EU](https://www.ovh.com/auth/?onsuccess=https%3A%2F%2Fwww.ovh.com%2Fauth%2FcreateToken%2F%3F) * [CA](https://ca.ovh.com/auth/?onsuccess=https%3A//ca.ovh.com%2Fauth%2FcreateToken%2F%3F) + ## Set the environment variables ```bash @@ -60,7 +61,7 @@ export OVH_CLOUD_PROJECT_SERVICE="xxx" ## Build and run -### Create the Terraform variables file (configuration) +### Create the Terraform / OpenTofu variables file (configuration) Two Terraform variables configuration files have been already created. Edit them to modify the needed information. @@ -94,28 +95,28 @@ Customize the values if needed. ```bash cd 01-kube -terraform init -terraform plan -var-file=../variables_01.tfvars +tofu init +tofu plan -var-file=../variables_01.tfvars ``` ### Create the cluster and the nodes-pool - 01-kube ```bash -terraform apply -var-file=../variables_01.tfvars -auto-approve +tofu apply -var-file=../variables_01.tfvars -auto-approve ``` ### Validate the configuration - 02-db-wordpress ```bash cd ../02-db-wordpress -terraform init -terraform plan -var-file=../variables_02.tfvars +tofu init +tofu plan -var-file=../variables_02.tfvars ``` ### Create the DB, website - 02-db-wordpress ```bash -terraform apply -var-file=../variables_02.tfvars -auto-approve +tofu apply -var-file=../variables_02.tfvars -auto-approve ``` ### Login into Wordpress @@ -136,7 +137,7 @@ kubectl --kubeconfig=./kubeconfig.yml get secret -n default wordpress -o jsonpat ```bash cd 02-db-wordpress -terraform destroy -var-file=../variables_02.tfvars -auto-approve +tofu destroy -var-file=../variables_02.tfvars -auto-approve cd ../01-kube -terraform destroy -var-file=../variables_01.tfvars -auto-approve +tofu destroy -var-file=../variables_01.tfvars -auto-approve ```