diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index acc4e45..01f0c19 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -9,7 +9,9 @@ env: PALETTE_VERSION: 4.0.2 PALETTE_CLI_VERSION: 4.0.1 PALETTE_EDGE_VERSION: 3.4.3 - + PACKER_VERSION: 1.9.4 + ORAS_VERSION: 1.0.0 + TERRAFORM_VERSION: 1.6.5 jobs: @@ -66,6 +68,9 @@ jobs: PALETTE_VERSION=${{env.PALETTE_VERSION}} PALETTE_CLI_VERSION=${{env.PALETTE_CLI_VERSION}} PALETTE_EDGE_VERSION=${{env.PALETTE_EDGE_VERSION}} + PACKER_VERSION=${{env.PACKER_VERSION}} + ORAS_VERSION=${{env.ORAS_VERSION}} + TERRAFORM_VERSION=${{env.TERRAFORM_VERSION}} platforms: linux/amd64,linux/arm64 push: true tags: ghcr.io/${{ github.repository }}:${{steps.dependencies.outputs.VERSION}} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 96624d4..ad2bd0f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,6 +9,9 @@ env: PALETTE_VERSION: 4.0.2 PALETTE_CLI_VERSION: 4.0.1 PALETTE_EDGE_VERSION: 3.4.3 + PACKER_VERSION: 1.9.4 + ORAS_VERSION: 1.0.0 + TERRAFORM_VERSION: 1.6.5 concurrency: group: docker-${{ github.ref }} @@ -73,5 +76,8 @@ jobs: PALETTE_VERSION=${{env.PALETTE_VERSION}} PALETTE_CLI_VERSION=${{env.PALETTE_CLI_VERSION}} PALETTE_EDGE_VERSION=${{env.PALETTE_EDGE_VERSION}} - + PACKER_VERSION=${{env.PACKER_VERSION}} + ORAS_VERSION=${{env.ORAS_VERSION}} + TERRAFORM_VERSION=${{env.TERRAFORM_VERSION}} + diff --git a/.gitignore b/.gitignore index ef72966..9235d96 100644 --- a/.gitignore +++ b/.gitignore @@ -37,5 +37,5 @@ override.tf.json my.*.tfvars .terraform.lock.hcl *.env - +*.kubeconfig diff --git a/Dockerfile b/Dockerfile index e4d08f0..a1bb763 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,8 +17,9 @@ ADD static/defaults/registry-config.yml etc/spectro/config.yml ARG PALETTE_CLI_VERSION ARG PALETTE_EDGE_VERSION -ARG PACKER_VERSION=1.9.4 -ARG ORAS_VERSION=1.0.0 +ARG PACKER_VERSION +ARG ORAS_VERSION +ARG TERRAFORM_VERSION ENV REGISTRY_LOG_LEVEL=info ENV REGISTRY_AUTH=htpasswd @@ -30,7 +31,7 @@ COPY --from=server /etc/spectro/config.yml /etc/spectro/config.yml RUN adduser -H -u 1002 -D appuser appuser && \ apk update && \ - apk add --no-cache bash curl git terraform openssl jq bind-tools wget ca-certificates nano aws-cli xorriso govc + apk add --no-cache bash curl git openssl jq bind-tools wget ca-certificates nano aws-cli xorriso govc podman RUN wget https://software.spectrocloud.com/spectro-registry/cli/v$PALETTE_CLI_VERSION/linux/spectro && \ mv spectro /usr/local/bin/spectro && \ @@ -57,7 +58,10 @@ RUN wget https://software.spectrocloud.com/spectro-registry/cli/v$PALETTE_CLI_V mv oras-install/oras /usr/local/bin/ && \ rm -rf oras_${ORAS_VERSION}_*.tar.gz oras-install/ && \ git clone https://github.com/spectrocloud/CanvOS.git && \ - rm -rf /var/cache/apk/* + rm -rf /var/cache/apk/* && \ + wget https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip && \ + unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip -d /usr/local/bin && \ + rm -rf terraform_${TERRAFORM_VERSION}_linux_amd64.zip ADD https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip /usr/local/sbin/ RUN unzip /usr/local/sbin/packer_${PACKER_VERSION}_linux_amd64.zip -d /usr/local/sbin && \ diff --git a/Makefile b/Makefile index 01ce314..e30f8de 100644 --- a/Makefile +++ b/Makefile @@ -11,4 +11,10 @@ help: ## Display this help build-docker: ## Build docker image @echo "Building docker image" - docker build --build-arg PALETTE_VERSION=$(VERSION) --build-arg PALETTE_CLI_VERSION=$(VERSION) --build-arg PALETTE_EDGE_VERSION=$(EDGE) --build-arg PACKER_VERSION=1.8.7 -t tutorials . \ No newline at end of file + docker build --build-arg PALETTE_VERSION=$(PALETTE_VERSION) \ + --build-arg PALETTE_CLI_VERSION=$(PALETTE_CLI_VERION) \ + --build-arg PALETTE_EDGE_VERSION=$(PALETTE_EDGE_VERSION) \ + --build-arg PACKER_VERSION=$(PACKER_VERSION) \ + --build-arg ORAS_VERSION=$(PACKER_VERSION) \ + --build-arg TERRAFORM_VERSION=$(TERRAFORM_VERSION) \ + -t tutorials . \ No newline at end of file diff --git a/README.md b/README.md index 84625f1..9497867 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ The following tutorial code is available: - [terraform-cluster-deployment-tf](./terraform/iaas-cluster-deployment-tf/README.md) - Learn how to deploy a cluster to a cloud provider with Palette. [Link](https://docs.spectrocloud.com/clusters/public-cloud/deploy-k8s-cluster) +- [terraform-cluster-update-tf](./terraform/iaas-cluster-update-tf/README.md) - Learn how to update a cluster deployed to a cloud provider with Palette. [Link](https://docs.spectrocloud.com/clusters/cluster-management/update-k8s-cluster) + - [Deploy an Edge cluster on VMware](./edge/vmware/README.md) - Learn how to deploy an Edge cluster on VMware. [Link](https://docs.spectrocloud.com/clusters/edge/site-deployment/deploy-cluster) ## Docker diff --git a/docs/docker.md b/docs/docker.md index 77277e7..843e30f 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -3,13 +3,13 @@ To download the image issue the following commnad. Change the version tag as needed. ```shell -docker pull ghcr.io/spectrocloud/tutorials:1.0.2 +docker pull ghcr.io/spectrocloud/tutorials:1.0.12 ``` You can start the container using the following command. ```shell -docker run -p 5000:5000 --rm -it ghcr.io/spectrocloud/tutorials:1.0.2 bash +docker run -p 5000:5000 --rm -it ghcr.io/spectrocloud/tutorials:1.0.12 bash ``` @@ -42,6 +42,7 @@ The Docker image includes the following tools. | `GOVC` | Tool for interracting with VMware Vsphere via API | | `aws-cli` | AWS command-line interface | | `oras` | Tool for pushing and pulling OCI artifacts to and from OCI registries| +| `podman` | Tool for building and deploying OCI images | ### Spectro Cloud Pack Registry Server @@ -61,9 +62,9 @@ registry serve /etc/spectro/config.yml > /var/log/registry.log 2>&1 & # Local Builds -If you are wanting to build the docker image locally you must provide the the build arguments for `PALETTE_VERSION` and `PALETTE_CLI_VERSION`, `PALETTE_EDGE_VERSION`. Use the following command to build a local image. Replace the versions as needed. +If you are wanting to build the docker image locally you must provide the the build arguments for `PALETTE_VERSION`, `PALETTE_CLI_VERSION`, `PALETTE_EDGE_VERSION`, `PACKER_VERSION`, `ORAS_VERSION` and `TERRAFORM_VERSION`. Use the following command to build a local image. Replace the versions as needed. ```shell -docker build --build-arg PALETTE_VERSION=4.0.2 --build-arg PALETTE_CLI_VERSION=4.0.1 --build-arg PALETTE_EDGE_VERSION=3.4.3 --build-arg PACKER_VERSION=1.9.4 -t tutorials . +docker build --build-arg PALETTE_VERSION=4.0.2 --build-arg PALETTE_CLI_VERSION=4.0.1 --build-arg PALETTE_EDGE_VERSION=3.4.3 --build-arg PACKER_VERSION=1.9.4 --build-arg ORAS_VERSION=1.0.0 --build-arg TERRAFORM_VERSION=1.6.5 -t tutorials . ``` \ No newline at end of file diff --git a/terraform/iaas-cluster-deployment-tf/README.md b/terraform/iaas-cluster-deployment-tf/README.md index 6d52a14..f6fbb12 100644 --- a/terraform/iaas-cluster-deployment-tf/README.md +++ b/terraform/iaas-cluster-deployment-tf/README.md @@ -27,7 +27,7 @@ To get started, open up the file **terraform.tfvars**. Toggle the provider varia | Name | Version | |------|---------| -| [spectrocloud](#provider\_spectrocloud) | 0.13.1 | +| [spectrocloud](#provider\_spectrocloud) | 0.16.1 | | [tls](#provider\_tls) | 4.0.4 | ## Modules @@ -39,7 +39,7 @@ No modules. | Name | Type | |------|------| | [spectrocloud_cluster_aws.aws-cluster](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_aws) | resource | -| [spectrocloud_cluster_azure.cluster](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_azure) | resource | +| [spectrocloud_cluster_azure.azure-cluster](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_azure) | resource | | [spectrocloud_cluster_gcp.gcp-cluster](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_gcp) | resource | | [spectrocloud_cluster_profile.aws-profile](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_profile) | resource | | [spectrocloud_cluster_profile.azure-profile](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_profile) | resource | @@ -68,11 +68,12 @@ No modules. |------|-------------|------|---------|:--------:| | [aws-cloud-account-name](#input\_aws-cloud-account-name) | The name of your AWS account as assigned in Palette | `string` | `""` | no | | [aws-key-pair-name](#input\_aws-key-pair-name) | The name of the AWS key pair to use for SSH access to the cluster. Refer to [EC2 Key Pairs](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html) to learn more. | `string` | `""` | no | -| [aws-region](#input\_aws-region) | AWS region | `string` | n/a | yes | +| [aws-region](#input\_aws-region) | AWS region | `string` | `"us-east-1"` | yes | | [aws\_master\_nodes](#input\_aws\_master\_nodes) | AWS master nodes configuration. |
object({|
count = string
control_plane = bool
instance_type = string
disk_size_gb = string
availability_zones = list(string)
})
{| no | | [aws\_worker\_nodes](#input\_aws\_worker\_nodes) | AWS worker nodes configuration. |
"availability_zones": [
"us-east-1a"
],
"control_plane": true,
"count": "1",
"disk_size_gb": "60",
"instance_type": "m4.2xlarge"
}
object({|
count = string
control_plane = bool
instance_type = string
disk_size_gb = string
availability_zones = list(string)
})
{| no | | [azure-cloud-account-name](#input\_azure-cloud-account-name) | The name of your Azure account as assigned in Palette | `string` | `""` | no | | [azure-region](#input\_azure-region) | Azure region | `string` | `"eastus"` | no | +| [azure-use-azs](#input\_azure-use-azs) | A flag for configuring whether to use Azure Availability Zones. Check if your Azure region supports availability zones by reviewing the [Azure Regions and Availability Zones](https://learn.microsoft.com/en-us/azure/reliability/availability-zones-service-support#azure-regions-with-availability-zone-support) resource. | `bool` | `true` | no | | [azure\_master\_nodes](#input\_azure\_master\_nodes) | Azure master nodes configuration. |
"availability_zones": [
"us-east-1a"
],
"control_plane": false,
"count": "1",
"disk_size_gb": "60",
"instance_type": "m4.2xlarge"
}
object({|
count = string
control_plane = bool
instance_type = string
disk_size_gb = string
azs = list(string)
is_system_node_pool = bool
})
{| no | | [azure\_resource\_group](#input\_azure\_resource\_group) | Azure resource group | `string` | `""` | no | | [azure\_subscription\_id](#input\_azure\_subscription\_id) | Azure subscription ID | `string` | `""` | no | diff --git a/terraform/iaas-cluster-deployment-tf/clusters.tf b/terraform/iaas-cluster-deployment-tf/clusters.tf index 371b487..a68cf78 100644 --- a/terraform/iaas-cluster-deployment-tf/clusters.tf +++ b/terraform/iaas-cluster-deployment-tf/clusters.tf @@ -43,7 +43,7 @@ resource "spectrocloud_cluster_aws" "aws-cluster" { ######################### # Azure Cluster Profile ######################### -resource "spectrocloud_cluster_azure" "cluster" { +resource "spectrocloud_cluster_azure" "azure-cluster" { count = var.deploy-azure ? 1 : 0 name = "azure-cluster" diff --git a/terraform/iaas-cluster-deployment-tf/data.tf b/terraform/iaas-cluster-deployment-tf/data.tf index 7c6c47e..382502c 100644 --- a/terraform/iaas-cluster-deployment-tf/data.tf +++ b/terraform/iaas-cluster-deployment-tf/data.tf @@ -1,3 +1,10 @@ +#################################### +# Data resources for the profile +#################################### +data "spectrocloud_registry" "public_registry" { + name = "Public Repo" +} + ############# # AWS ############# @@ -7,20 +14,27 @@ data "spectrocloud_cloudaccount_aws" "account" { } data "spectrocloud_pack" "aws_csi" { - name = "csi-aws-ebs" - version = "1.16.0" + name = "csi-aws-ebs" + version = "1.22.0" + registry_uid = data.spectrocloud_registry.public_registry.id } + data "spectrocloud_pack" "aws_cni" { - name = "cni-calico" - version = "3.24.5" + name = "cni-calico" + version = "3.26.1" + registry_uid = data.spectrocloud_registry.public_registry.id } + data "spectrocloud_pack" "aws_k8s" { - name = "kubernetes" - version = "1.24.10" + name = "kubernetes" + version = "1.27.5" + registry_uid = data.spectrocloud_registry.public_registry.id } + data "spectrocloud_pack" "aws_ubuntu" { - name = "ubuntu-aws" - version = "20.04" + name = "ubuntu-aws" + version = "22.04" + registry_uid = data.spectrocloud_registry.public_registry.id } ############# @@ -32,21 +46,29 @@ data "spectrocloud_cloudaccount_azure" "account" { } data "spectrocloud_pack" "azure_csi" { - name = "csi-azure" - version = "1.25.0" + name = "csi-azure" + version = "1.28.3" + registry_uid = data.spectrocloud_registry.public_registry.id } + data "spectrocloud_pack" "azure_cni" { - name = "cni-calico-azure" - version = "3.24.5" + name = "cni-calico-azure" + version = "3.26.1" + registry_uid = data.spectrocloud_registry.public_registry.id } + data "spectrocloud_pack" "azure_k8s" { - name = "kubernetes" - version = "1.24.10" + name = "kubernetes" + version = "1.27.5" + registry_uid = data.spectrocloud_registry.public_registry.id } + data "spectrocloud_pack" "azure_ubuntu" { - name = "ubuntu-azure" - version = "20.04" + name = "ubuntu-azure" + version = "22.04" + registry_uid = data.spectrocloud_registry.public_registry.id } + ############# # GCP ############# @@ -56,26 +78,25 @@ data "spectrocloud_cloudaccount_gcp" "account" { } data "spectrocloud_pack" "gcp_csi" { - name = "csi-gcp-driver" - version = "1.7.1" + name = "csi-gcp-driver" + version = "1.8.2" + registry_uid = data.spectrocloud_registry.public_registry.id } + data "spectrocloud_pack" "gcp_cni" { - name = "cni-calico" - version = "3.24.5" + name = "cni-calico" + version = "3.26.1" + registry_uid = data.spectrocloud_registry.public_registry.id } + data "spectrocloud_pack" "gcp_k8s" { - name = "kubernetes" - version = "1.24.10" + name = "kubernetes" + version = "1.27.5" + registry_uid = data.spectrocloud_registry.public_registry.id } + data "spectrocloud_pack" "gcp_ubuntu" { - name = "ubuntu-gcp" - version = "20.04" + name = "ubuntu-gcp" + version = "22.04" + registry_uid = data.spectrocloud_registry.public_registry.id } -############# -# Universal -############# - -data "spectrocloud_pack" "proxy" { - name = "spectro-proxy" - version = "1.3.0" -} \ No newline at end of file diff --git a/terraform/iaas-cluster-deployment-tf/inputs.tf b/terraform/iaas-cluster-deployment-tf/inputs.tf index 15b3212..1312b1d 100644 --- a/terraform/iaas-cluster-deployment-tf/inputs.tf +++ b/terraform/iaas-cluster-deployment-tf/inputs.tf @@ -48,9 +48,15 @@ variable "azure_resource_group" { default = "" } +variable "azure-use-azs" { + type = bool + description = "A flag for configuring whether to use Azure Availability Zones. Check if your Azure region supports availability zones by reviewing the [Azure Regions and Availability Zones](https://learn.microsoft.com/en-us/azure/reliability/availability-zones-service-support#azure-regions-with-availability-zone-support) resource" +} + variable "aws-region" { type = string description = "AWS region" + default = "us-east-1" } variable "gcp-region" { @@ -139,7 +145,7 @@ variable "azure_worker_nodes" { control_plane = false instance_type = "Standard_A8_v2" disk_size_gb = "60" - azs = [] + azs = ["1"] is_system_node_pool = false } description = "Azure worker nodes configuration." } diff --git a/terraform/iaas-cluster-deployment-tf/manifests/hello-universe.yaml b/terraform/iaas-cluster-deployment-tf/manifests/hello-universe.yaml index d62f2b4..5253f43 100644 --- a/terraform/iaas-cluster-deployment-tf/manifests/hello-universe.yaml +++ b/terraform/iaas-cluster-deployment-tf/manifests/hello-universe.yaml @@ -1,20 +1,27 @@ apiVersion: v1 +kind: Namespace +metadata: + name: hello-universe +--- +apiVersion: v1 kind: Service metadata: name: hello-universe-service + namespace: hello-universe spec: type: LoadBalancer - selector: - app: hello-universe ports: - protocol: TCP port: 8080 targetPort: 8080 + selector: + app: hello-universe --- apiVersion: apps/v1 kind: Deployment metadata: name: hello-universe-deployment + namespace: hello-universe spec: replicas: 2 selector: @@ -27,7 +34,7 @@ spec: spec: containers: - name: hello-universe - image: ghcr.io/spectrocloud/hello-universe:1.0.12 + image: ghcr.io/spectrocloud/hello-universe:1.1.0 imagePullPolicy: IfNotPresent ports: - containerPort: 8080 \ No newline at end of file diff --git a/terraform/iaas-cluster-deployment-tf/provider.tf b/terraform/iaas-cluster-deployment-tf/provider.tf index fc8effa..fbfd8d3 100644 --- a/terraform/iaas-cluster-deployment-tf/provider.tf +++ b/terraform/iaas-cluster-deployment-tf/provider.tf @@ -9,6 +9,8 @@ terraform { version = "4.0.4" } } + + required_version = ">= 1.5" } provider "spectrocloud" { project_name = "Default" diff --git a/terraform/iaas-cluster-deployment-tf/terraform.tfvars b/terraform/iaas-cluster-deployment-tf/terraform.tfvars index 3db4d98..b72c4b1 100644 --- a/terraform/iaas-cluster-deployment-tf/terraform.tfvars +++ b/terraform/iaas-cluster-deployment-tf/terraform.tfvars @@ -26,7 +26,8 @@ aws_worker_nodes = { ########################### # Azure Deployment Settings ############################ -deploy-azure = false # Set to true to deploy to Azure +deploy-azure = false # Set to true to deploy to Azure +azure-use-azs = true # Set to false when you deploy to a region without AZs azure-cloud-account-name = "REPLACE_ME" azure-region = "REPLACE_ME" @@ -39,7 +40,7 @@ azure_master_nodes = { control_plane = true instance_type = "Standard_A8_v2" disk_size_gb = "60" - azs = [] # If you want to deploy to multiple AZs, add them here + azs = ["1"] # If you want to deploy to multiple AZs, add them here. is_system_node_pool = false } @@ -48,7 +49,7 @@ azure_worker_nodes = { control_plane = false instance_type = "Standard_A8_v2" disk_size_gb = "60" - azs = ["1"] # If you want to deploy to multiple AZs, add them here but you must have at least one. + azs = ["1"] # If you want to deploy to multiple AZs, add them here. is_system_node_pool = false } @@ -65,7 +66,7 @@ gcp_master_nodes = { control_plane = true instance_type = "n1-standard-4" disk_size_gb = "60" - availability_zones = ["REPLACE_ME"] # If you want to deploy to multiple AZs, add them here. Example: ["central1-a", "central1-b"] + availability_zones = ["REPLACE_ME"] # If you want to deploy to multiple AZs, add them here. Example: ["us-central1-a", "us-central1-b"] } gcp_worker_nodes = { @@ -73,5 +74,5 @@ gcp_worker_nodes = { control_plane = false instance_type = "n1-standard-4" disk_size_gb = "60" - availability_zones = ["REPLACE_ME"] # If you want to deploy to multiple AZs, add them here. Example: ["central1-a", "central1-b"] + availability_zones = ["REPLACE_ME"] # If you want to deploy to multiple AZs, add them here. Example: ["us-central1-a", "us-central1-b"] } \ No newline at end of file diff --git a/terraform/iaas-cluster-update-tf/README.md b/terraform/iaas-cluster-update-tf/README.md new file mode 100644 index 0000000..91bbbdc --- /dev/null +++ b/terraform/iaas-cluster-update-tf/README.md @@ -0,0 +1,117 @@ +# IaaS Cluster Update + + + + +This Terraform code has three main toggle variables that you can use to deploy to one of the following cloud providers. + +| Variable| Provider| Description| Default | +|---|---|---|---| +| `deploy-aws` | AWS | Enable to deploy a cluster to AWS. | `false`| +| `deploy-azure` | GCP | Enable to deploy a cluster to Azure. | `false`| +| `deploy-gcp` | Azure | Enable to deploy a cluster to GCP. | `false`| + +> You can enable as many of the providers as you want. You just need to ensure all provider's required values are specified. + +To get started, open up the file **terraform.tfvars**. Toggle the provider variable mentioned in the table and start providing values for the respective cloud provider. Make sure you specify a value to your cloud provider variables and replace all values containing the string `REPLACE ME`. + + +## Requirements + +| Name | Version | +|------|---------| +| [spectrocloud](#requirement\_spectrocloud) | >= 0.13.1 | +| [tls](#requirement\_tls) | 4.0.4 | +| [local](#requirement\_local) | >=2.4.0 | + +## Providers + +| Name | Version | +|------|---------| +| [spectrocloud](#provider\_spectrocloud) | 0.16.1 | +| [tls](#provider\_tls) | 4.0.4 | +| [tls](#provider\_local) | 2.4.0 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [local_file.aws-kubeconfig](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | data source | +| [local_file.azure-kubeconfig](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | data source | +| [local_file.gcp-kubeconfig](https://registry.terraform.io/providers/hashicorp/local/latest/docs/resources/file) | data source | +| [spectrocloud_cluster.aws_cluster_api](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/cluster) | data source | +| [spectrocloud_cluster.azure_cluster_api](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/cluster) | data source | +| [spectrocloud_cluster.gcp_cluster_api](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/cluster) | data source | +| [spectrocloud_cluster_aws.aws-cluster](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_aws) | resource | +| [spectrocloud_cluster_aws.aws-cluster-api](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_aws) | resource | +| [spectrocloud_cluster_azure.azure-cluster](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_azure) | resource | +| [spectrocloud_cluster_azure.azure-cluster-api](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_azure) | resource | +| [spectrocloud_cluster_gcp.gcp-cluster](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_gcp) | resource | +| [spectrocloud_cluster_gcp.gcp-cluster-api](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_gcp) | resource | +| [spectrocloud_cluster_profile.aws-profile](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_profile) | resource | +| [spectrocloud_cluster_profile.aws-profile-3tier](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_profile) | resource | +| [spectrocloud_cluster_profile.aws-profile-api](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_profile) | resource | +| [spectrocloud_cluster_profile.azure-profile](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_profile) | resource | +| [spectrocloud_cluster_profile.azure-profile-3tier](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_profile) | resource | +| [spectrocloud_cluster_profile.azure-profile-api](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_profile) | resource | +| [spectrocloud_cluster_profile.gcp-profile](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_profile) | resource | +| [spectrocloud_cluster_profile.gcp-profile-3tier](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_profile) | resource | +| [spectrocloud_cluster_profile.gcp-profile-api](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_profile) | resource | +| [tls_private_key.tutorial_ssh_key](https://registry.terraform.io/providers/hashicorp/tls/4.0.4/docs/resources/private_key) | resource | +| [spectrocloud_cloudaccount_aws.account](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/cloudaccount_aws) | data source | +| [spectrocloud_cloudaccount_azure.account](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/cloudaccount_azure) | data source | +| [spectrocloud_cloudaccount_gcp.account](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/cloudaccount_gcp) | data source | +| [spectrocloud_pack.aws_cni](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source | +| [spectrocloud_pack.aws_csi](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source | +| [spectrocloud_pack.aws_k8s](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source | +| [spectrocloud_pack.aws_ubuntu](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source | +| [spectrocloud_pack.azure_cni](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source | +| [spectrocloud_pack.azure_csi](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source | +| [spectrocloud_pack.azure_k8s](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source | +| [spectrocloud_pack.azure_ubuntu](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source | +| [spectrocloud_pack.gcp_cni](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source | +| [spectrocloud_pack.gcp_csi](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source | +| [spectrocloud_pack.gcp_k8s](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source | +| [spectrocloud_pack.gcp_ubuntu](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) | data source | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [aws-cloud-account-name](#input\_aws-cloud-account-name) | The name of your AWS account as assigned in Palette | `string` | `""` | no | +| [aws-key-pair-name](#input\_aws-key-pair-name) | The name of the AWS key pair to use for SSH access to the cluster. Refer to [EC2 Key Pairs](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html) to learn more. | `string` | `""` | no | +| [aws-hello-universe-api-uri](#input\_aws-hello-universe-api-uri) | The URI of the `hello-universe-api` service deployed to AWS. | `string` | `"http://REPLACE_ME:3000"` | no | +| [aws-region](#input\_aws-region) | AWS region | `string` | `"us-east-1"` | yes | +| [aws\_master\_nodes](#input\_aws\_master\_nodes) | AWS master nodes configuration. |
"azs": [
"1"
],
"control_plane": true,
"count": "1",
"disk_size_gb": "60",
"instance_type": "Standard_A8_v2",
"is_system_node_pool": false
}
object({|
count = string
control_plane = bool
instance_type = string
disk_size_gb = string
availability_zones = list(string)
})
{| no | +| [aws\_worker\_nodes](#input\_aws\_worker\_nodes) | AWS worker nodes configuration. |
"availability_zones": [
"us-east-1a"
],
"control_plane": true,
"count": "1",
"disk_size_gb": "60",
"instance_type": "m4.2xlarge"
}
object({|
count = string
control_plane = bool
instance_type = string
disk_size_gb = string
availability_zones = list(string)
})
{| no | +| [azure-cloud-account-name](#input\_azure-cloud-account-name) | The name of your Azure account as assigned in Palette | `string` | `""` | no | +| [azure-hello-universe-api-uri](#input\_azure-hello-universe-api-uri) | The URI of the `hello-universe-api service deployed to Azure. | `string` | `"http://REPLACE_ME:3000"` | no | +| [azure-region](#input\_azure-region) | Azure region | `string` | `"eastus"` | no | +| [azure-use-azs](#input\_azure-use-azs) | A flag for configuring whether to use Azure Availability Zones. Check if your Azure region supports availability zones by reviewing the [Azure Regions and Availability Zones](https://learn.microsoft.com/en-us/azure/reliability/availability-zones-service-support#azure-regions-with-availability-zone-support) resource. | `bool` | `true` | no | +| [azure\_master\_nodes](#input\_azure\_master\_nodes) | Azure master nodes configuration. |
"availability_zones": [
"us-east-1a"
],
"control_plane": false,
"count": "1",
"disk_size_gb": "60",
"instance_type": "m4.2xlarge"
}
object({|
count = string
control_plane = bool
instance_type = string
disk_size_gb = string
azs = list(string)
is_system_node_pool = bool
})
{| no | +| [azure\_resource\_group](#input\_azure\_resource\_group) | Azure resource group | `string` | `""` | no | +| [azure\_subscription\_id](#input\_azure\_subscription\_id) | Azure subscription ID | `string` | `""` | no | +| [azure\_worker\_nodes](#input\_azure\_worker\_nodes) | Azure worker nodes configuration. |
"azs": [
"1"
],
"control_plane": true,
"count": "1",
"disk_size_gb": "60",
"instance_type": "Standard_A8_v2",
"is_system_node_pool": false
}
object({|
count = string
control_plane = bool
instance_type = string
disk_size_gb = string
azs = list(string)
is_system_node_pool = bool
})
{| no | +| [deploy-aws](#input\_deploy-aws) | A flag for enabling a deployment on AWS | `bool` | n/a | yes | +| [deploy-azure](#input\_deploy-azure) | A flag for enabling a deployment on Azure | `bool` | n/a | yes | +| [deploy-gcp](#input\_deploy-gcp) | A flag for enabling a deployment on GCP | `bool` | n/a | yes | +| [gcp-cloud-account-name](#input\_gcp-cloud-account-name) | The name of your GCP account as assigned in Palette | `string` | `""` | no | +| [gcp-hello-universe-api-uri](#input\_gcp-hello-universe-api-uri) | The URI of the `hello-universe-api` service deployed to GCP. | `string` | `"http://REPLACE_ME:3000"` | no | +| [gcp-region](#input\_gcp-region) | GCP region | `string` | `"us-central1"` | no | +| [gcp\_master\_nodes](#input\_gcp\_master\_nodes) | GCP master nodes configuration. |
"azs": [],
"control_plane": false,
"count": "1",
"disk_size_gb": "60",
"instance_type": "Standard_A8_v2",
"is_system_node_pool": false
}
object({|
count = string
control_plane = bool
instance_type = string
disk_size_gb = string
availability_zones = list(string)
})
{| no | +| [gcp\_project\_name](#input\_gcp\_project\_name) | The name of your GCP project | `string` | `""` | no | +| [gcp\_worker\_nodes](#input\_gcp\_worker\_nodes) | GCP worker nodes configuration. |
"availability_zones": [
"us-central1-a"
],
"control_plane": true,
"count": "1",
"disk_size_gb": "60",
"instance_type": "n1-standard-4"
}
object({|
count = string
control_plane = bool
instance_type = string
disk_size_gb = string
availability_zones = list(string)
})
{| no | +| [tags](#input\_tags) | The default tags to apply to Palette resources | `list(string)` |
"availability_zones": [
"us-central1-a"
],
"control_plane": false,
"count": "1",
"disk_size_gb": "60",
"instance_type": "n1-standard-4"
}
[| no | + +## Outputs + +| Name | Description | +|------|-------------| +| [Advisory](#output\_Advisory) | n/a | +| [aws_hello_universe_api_ip](#output\aws_hello_universe_api_ip) | Instructions to retrieve the IP address of the hello-universe-api service deployed to AWS. | +| [azure_hello_universe_api_ip](#output\azure_hello_universe_api_ip) | Instructions to retrieve the IP address of the hello-universe-api service deployed to Azure. | +| [gcp_hello_universe_api_ip](#output\gcp_hello_universe_api_ip) | Instructions to retrieve the IP address of the hello-universe-api service deployed to GCP. | diff --git a/terraform/iaas-cluster-update-tf/cluster_profiles.tf b/terraform/iaas-cluster-update-tf/cluster_profiles.tf new file mode 100644 index 0000000..8a647cf --- /dev/null +++ b/terraform/iaas-cluster-update-tf/cluster_profiles.tf @@ -0,0 +1,462 @@ +######################### +# AWS Cluster Profile +######################### +resource "spectrocloud_cluster_profile" "aws-profile" { + count = var.deploy-aws ? 1 : 0 + + name = "tf-aws-profile" + description = "A basic cluster profile for AWS" + tags = concat(var.tags, ["env:aws"]) + cloud = "aws" + type = "cluster" + version = "1.0.0" + + pack { + name = data.spectrocloud_pack.aws_ubuntu.name + tag = data.spectrocloud_pack.aws_ubuntu.version + uid = data.spectrocloud_pack.aws_ubuntu.id + values = data.spectrocloud_pack.aws_ubuntu.values + } + + pack { + name = data.spectrocloud_pack.aws_k8s.name + tag = data.spectrocloud_pack.aws_k8s.version + uid = data.spectrocloud_pack.aws_k8s.id + values = data.spectrocloud_pack.aws_k8s.values + } + + pack { + name = data.spectrocloud_pack.aws_cni.name + tag = data.spectrocloud_pack.aws_cni.version + uid = data.spectrocloud_pack.aws_cni.id + values = data.spectrocloud_pack.aws_cni.values + } + + pack { + name = data.spectrocloud_pack.aws_csi.name + tag = data.spectrocloud_pack.aws_csi.version + uid = data.spectrocloud_pack.aws_csi.id + values = data.spectrocloud_pack.aws_csi.values + } + + pack { + name = "hello-universe" + type = "manifest" + tag = "1.0.0" + values = "" + manifest { + name = "hello-universe" + content = file("manifests/hello-universe.yaml") + } + } +} + +# resource "spectrocloud_cluster_profile" "aws-profile-3tier" { +# count = var.deploy-aws ? 1 : 0 + +# name = "tf-aws-profile" +# description = "A basic cluster profile for AWS" +# tags = concat(var.tags, ["env:aws"]) +# cloud = "aws" +# type = "cluster" +# version = "1.1.0" + +# pack { +# name = data.spectrocloud_pack.aws_ubuntu.name +# tag = data.spectrocloud_pack.aws_ubuntu.version +# uid = data.spectrocloud_pack.aws_ubuntu.id +# values = data.spectrocloud_pack.aws_ubuntu.values +# } + +# pack { +# name = data.spectrocloud_pack.aws_k8s.name +# tag = data.spectrocloud_pack.aws_k8s.version +# uid = data.spectrocloud_pack.aws_k8s.id +# values = data.spectrocloud_pack.aws_k8s.values +# } + +# pack { +# name = data.spectrocloud_pack.aws_cni.name +# tag = data.spectrocloud_pack.aws_cni.version +# uid = data.spectrocloud_pack.aws_cni.id +# values = data.spectrocloud_pack.aws_cni.values +# } + +# pack { +# name = data.spectrocloud_pack.aws_csi.name +# tag = data.spectrocloud_pack.aws_csi.version +# uid = data.spectrocloud_pack.aws_csi.id +# values = data.spectrocloud_pack.aws_csi.values +# } + +# pack { +# name = "hello-universe" +# type = "manifest" +# tag = "1.0.0" +# values = "" +# manifest { +# name = "hello-universe" +# content = templatefile("manifests/hello-universe-3tier.yaml", { +# api_uri = var.aws-hello-universe-api-uri +# }) +# } +# } +# } + +resource "spectrocloud_cluster_profile" "aws-profile-api" { + count = var.deploy-aws ? 1 : 0 + + name = "tf-aws-profile-api" + description = "A basic cluster profile for AWS" + tags = concat(var.tags, ["env:aws"]) + cloud = "aws" + type = "cluster" + + pack { + name = data.spectrocloud_pack.aws_ubuntu.name + tag = data.spectrocloud_pack.aws_ubuntu.version + uid = data.spectrocloud_pack.aws_ubuntu.id + values = data.spectrocloud_pack.aws_ubuntu.values + } + + pack { + name = data.spectrocloud_pack.aws_k8s.name + tag = data.spectrocloud_pack.aws_k8s.version + uid = data.spectrocloud_pack.aws_k8s.id + values = data.spectrocloud_pack.aws_k8s.values + } + + pack { + name = data.spectrocloud_pack.aws_cni.name + tag = data.spectrocloud_pack.aws_cni.version + uid = data.spectrocloud_pack.aws_cni.id + values = data.spectrocloud_pack.aws_cni.values + } + + pack { + name = data.spectrocloud_pack.aws_csi.name + tag = data.spectrocloud_pack.aws_csi.version + uid = data.spectrocloud_pack.aws_csi.id + values = data.spectrocloud_pack.aws_csi.values + } + + pack { + name = "hello-universe-api" + type = "manifest" + tag = "1.0.0" + values = "" + manifest { + name = "hello-universe-api" + content = file("manifests/hello-universe-api.yaml") + } + } +} + +######################### +# Azure Cluster Profile +######################### +resource "spectrocloud_cluster_profile" "azure-profile" { + count = var.deploy-azure ? 1 : 0 + + name = "tf-azure-profile" + description = "A basic cluster profile for Azure" + tags = concat(var.tags, ["env:azure"]) + cloud = "azure" + type = "cluster" + version = "1.0.0" + + pack { + name = data.spectrocloud_pack.azure_ubuntu.name + tag = data.spectrocloud_pack.azure_ubuntu.version + uid = data.spectrocloud_pack.azure_ubuntu.id + values = data.spectrocloud_pack.azure_ubuntu.values + } + + pack { + name = data.spectrocloud_pack.azure_k8s.name + tag = data.spectrocloud_pack.azure_k8s.version + uid = data.spectrocloud_pack.azure_k8s.id + values = data.spectrocloud_pack.azure_k8s.values + } + + pack { + name = data.spectrocloud_pack.azure_cni.name + tag = data.spectrocloud_pack.azure_cni.version + uid = data.spectrocloud_pack.azure_cni.id + values = data.spectrocloud_pack.azure_cni.values + } + + pack { + name = data.spectrocloud_pack.azure_csi.name + tag = data.spectrocloud_pack.azure_csi.version + uid = data.spectrocloud_pack.azure_csi.id + values = data.spectrocloud_pack.azure_csi.values + } + + pack { + name = "hello-universe" + type = "manifest" + tag = "1.0.0" + values = "" + manifest { + name = "hello-universe" + content = file("manifests/hello-universe.yaml") + } + } +} + +# resource "spectrocloud_cluster_profile" "azure-profile-3tier" { +# count = var.deploy-azure ? 1 : 0 + +# name = "tf-azure-profile" +# description = "A basic cluster profile for Azure" +# tags = concat(var.tags, ["env:azure"]) +# cloud = "azure" +# type = "cluster" +# version = "1.1.0" + +# pack { +# name = data.spectrocloud_pack.azure_ubuntu.name +# tag = data.spectrocloud_pack.azure_ubuntu.version +# uid = data.spectrocloud_pack.azure_ubuntu.id +# values = data.spectrocloud_pack.azure_ubuntu.values +# } + +# pack { +# name = data.spectrocloud_pack.azure_k8s.name +# tag = data.spectrocloud_pack.azure_k8s.version +# uid = data.spectrocloud_pack.azure_k8s.id +# values = data.spectrocloud_pack.azure_k8s.values +# } + +# pack { +# name = data.spectrocloud_pack.azure_cni.name +# tag = data.spectrocloud_pack.azure_cni.version +# uid = data.spectrocloud_pack.azure_cni.id +# values = data.spectrocloud_pack.azure_cni.values +# } + +# pack { +# name = data.spectrocloud_pack.azure_csi.name +# tag = data.spectrocloud_pack.azure_csi.version +# uid = data.spectrocloud_pack.azure_csi.id +# values = data.spectrocloud_pack.azure_csi.values +# } + +# pack { +# name = "hello-universe" +# type = "manifest" +# tag = "1.0.0" +# values = "" +# manifest { +# name = "hello-universe" +# content = templatefile("manifests/hello-universe-3tier.yaml", { +# api_uri = var.azure-hello-universe-api-uri +# }) +# } +# } +# } + +resource "spectrocloud_cluster_profile" "azure-profile-api" { + count = var.deploy-azure ? 1 : 0 + + name = "tf-azure-profile-api" + description = "A basic cluster profile for Azure" + tags = concat(var.tags, ["env:azure"]) + cloud = "azure" + type = "cluster" + + pack { + name = data.spectrocloud_pack.azure_ubuntu.name + tag = data.spectrocloud_pack.azure_ubuntu.version + uid = data.spectrocloud_pack.azure_ubuntu.id + values = data.spectrocloud_pack.azure_ubuntu.values + } + + pack { + name = data.spectrocloud_pack.azure_k8s.name + tag = data.spectrocloud_pack.azure_k8s.version + uid = data.spectrocloud_pack.azure_k8s.id + values = data.spectrocloud_pack.azure_k8s.values + } + + pack { + name = data.spectrocloud_pack.azure_cni.name + tag = data.spectrocloud_pack.azure_cni.version + uid = data.spectrocloud_pack.azure_cni.id + values = data.spectrocloud_pack.azure_cni.values + } + + pack { + name = data.spectrocloud_pack.azure_csi.name + tag = data.spectrocloud_pack.azure_csi.version + uid = data.spectrocloud_pack.azure_csi.id + values = data.spectrocloud_pack.azure_csi.values + } + + pack { + name = "hello-universe-api" + type = "manifest" + tag = "1.0.0" + values = "" + manifest { + name = "hello-universe-api" + content = file("manifests/hello-universe-api.yaml") + } + } +} + + +######################### +# GCP Cluster Profile +######################### +resource "spectrocloud_cluster_profile" "gcp-profile" { + count = var.deploy-gcp ? 1 : 0 + + name = "tf-gcp-profile" + description = "A basic cluster profile for GCP" + tags = concat(var.tags, ["env:azure"]) + cloud = "gcp" + type = "cluster" + version = "1.0.0" + + pack { + name = data.spectrocloud_pack.gcp_ubuntu.name + tag = data.spectrocloud_pack.gcp_ubuntu.version + uid = data.spectrocloud_pack.gcp_ubuntu.id + values = data.spectrocloud_pack.gcp_ubuntu.values + } + + pack { + name = data.spectrocloud_pack.gcp_k8s.name + tag = data.spectrocloud_pack.gcp_k8s.version + uid = data.spectrocloud_pack.gcp_k8s.id + values = data.spectrocloud_pack.gcp_k8s.values + } + + pack { + name = data.spectrocloud_pack.gcp_cni.name + tag = data.spectrocloud_pack.gcp_cni.version + uid = data.spectrocloud_pack.gcp_cni.id + values = data.spectrocloud_pack.gcp_cni.values + } + + pack { + name = data.spectrocloud_pack.gcp_csi.name + tag = data.spectrocloud_pack.gcp_csi.version + uid = data.spectrocloud_pack.gcp_csi.id + values = data.spectrocloud_pack.gcp_csi.values + } + + pack { + name = "hello-universe" + type = "manifest" + tag = "1.0.0" + values = "" + manifest { + name = "hello-universe" + content = file("manifests/hello-universe.yaml") + } + } +} + +# resource "spectrocloud_cluster_profile" "gcp-profile-3tier" { +# count = var.deploy-gcp ? 1 : 0 + +# name = "tf-gcp-profile" +# description = "A basic cluster profile for GCP" +# tags = concat(var.tags, ["env:azure"]) +# cloud = "gcp" +# type = "cluster" +# version = "1.1.0" + +# pack { +# name = data.spectrocloud_pack.gcp_ubuntu.name +# tag = data.spectrocloud_pack.gcp_ubuntu.version +# uid = data.spectrocloud_pack.gcp_ubuntu.id +# values = data.spectrocloud_pack.gcp_ubuntu.values +# } + +# pack { +# name = data.spectrocloud_pack.gcp_k8s.name +# tag = data.spectrocloud_pack.gcp_k8s.version +# uid = data.spectrocloud_pack.gcp_k8s.id +# values = data.spectrocloud_pack.gcp_k8s.values +# } + +# pack { +# name = data.spectrocloud_pack.gcp_cni.name +# tag = data.spectrocloud_pack.gcp_cni.version +# uid = data.spectrocloud_pack.gcp_cni.id +# values = data.spectrocloud_pack.gcp_cni.values +# } + +# pack { +# name = data.spectrocloud_pack.gcp_csi.name +# tag = data.spectrocloud_pack.gcp_csi.version +# uid = data.spectrocloud_pack.gcp_csi.id +# values = data.spectrocloud_pack.gcp_csi.values +# } + +# pack { +# name = "hello-universe" +# type = "manifest" +# tag = "1.0.0" +# values = "" +# manifest { +# name = "hello-universe" +# content = templatefile("manifests/hello-universe-3tier.yaml", { +# api_uri = var.gcp-hello-universe-api-uri +# }) +# } +# } +# } + +resource "spectrocloud_cluster_profile" "gcp-profile-api" { + count = var.deploy-gcp ? 1 : 0 + + name = "tf-gcp-profile-api" + description = "A basic cluster profile for GCP" + tags = concat(var.tags, ["env:azure"]) + cloud = "gcp" + type = "cluster" + + pack { + name = data.spectrocloud_pack.gcp_ubuntu.name + tag = data.spectrocloud_pack.gcp_ubuntu.version + uid = data.spectrocloud_pack.gcp_ubuntu.id + values = data.spectrocloud_pack.gcp_ubuntu.values + } + + pack { + name = data.spectrocloud_pack.gcp_k8s.name + tag = data.spectrocloud_pack.gcp_k8s.version + uid = data.spectrocloud_pack.gcp_k8s.id + values = data.spectrocloud_pack.gcp_k8s.values + } + + pack { + name = data.spectrocloud_pack.gcp_cni.name + tag = data.spectrocloud_pack.gcp_cni.version + uid = data.spectrocloud_pack.gcp_cni.id + values = data.spectrocloud_pack.gcp_cni.values + } + + pack { + name = data.spectrocloud_pack.gcp_csi.name + tag = data.spectrocloud_pack.gcp_csi.version + uid = data.spectrocloud_pack.gcp_csi.id + values = data.spectrocloud_pack.gcp_csi.values + } + + pack { + name = "hello-universe-api" + type = "manifest" + tag = "1.0.0" + values = "" + manifest { + name = "hello-universe-api" + content = file("manifests/hello-universe-api.yaml") + } + } +} diff --git a/terraform/iaas-cluster-update-tf/clusters.tf b/terraform/iaas-cluster-update-tf/clusters.tf new file mode 100644 index 0000000..cb31872 --- /dev/null +++ b/terraform/iaas-cluster-update-tf/clusters.tf @@ -0,0 +1,290 @@ +######################### +# AWS Cluster Profile +######################## +resource "spectrocloud_cluster_aws" "aws-cluster" { + count = var.deploy-aws ? 1 : 0 + + name = "aws-cluster" + tags = concat(var.tags, ["env:aws", "service:hello-universe-frontend"]) + cloud_account_id = data.spectrocloud_cloudaccount_aws.account[0].id + + cloud_config { + region = var.aws-region + ssh_key_name = var.aws-key-pair-name + } + + cluster_profile { + id = spectrocloud_cluster_profile.aws-profile[0].id + # id = spectrocloud_cluster_profile.aws-profile-3tier[0].id + } + + machine_pool { + control_plane = true + control_plane_as_worker = true + name = "master-pool" + count = var.aws_master_nodes.count + instance_type = var.aws_master_nodes.instance_type + disk_size_gb = var.aws_master_nodes.disk_size_gb + azs = var.aws_master_nodes.availability_zones + } + + machine_pool { + name = "worker-pool" + count = var.aws_worker_nodes.count + instance_type = var.aws_worker_nodes.instance_type + disk_size_gb = var.aws_worker_nodes.disk_size_gb + azs = var.aws_worker_nodes.availability_zones + } + + timeouts { + create = "30m" + delete = "15m" + } +} + +resource "spectrocloud_cluster_aws" "aws-cluster-api" { + count = var.deploy-aws ? 1 : 0 + + name = "aws-cluster-api" + tags = concat(var.tags, ["env:aws", "service:hello-universe-backend"]) + cloud_account_id = data.spectrocloud_cloudaccount_aws.account[0].id + + cloud_config { + region = var.aws-region + ssh_key_name = var.aws-key-pair-name + } + + cluster_profile { + id = spectrocloud_cluster_profile.aws-profile-api[0].id + } + + machine_pool { + control_plane = true + control_plane_as_worker = true + name = "master-pool" + count = var.aws_master_nodes.count + instance_type = var.aws_master_nodes.instance_type + disk_size_gb = var.aws_master_nodes.disk_size_gb + azs = var.aws_master_nodes.availability_zones + } + + machine_pool { + name = "worker-pool" + count = var.aws_worker_nodes.count + instance_type = var.aws_worker_nodes.instance_type + disk_size_gb = var.aws_worker_nodes.disk_size_gb + azs = var.aws_worker_nodes.availability_zones + } + + timeouts { + create = "30m" + delete = "15m" + } +} + +resource "local_file" "aws-kubeconfig" { + count = var.deploy-aws ? 1 : 0 + + content = data.spectrocloud_cluster.aws_cluster_api[0].kube_config + filename = "aws-cluster-api.kubeconfig" + file_permission = "0644" + directory_permission = "0755" +} + +######################### +# Azure Cluster Profile +######################### +resource "spectrocloud_cluster_azure" "azure-cluster" { + count = var.deploy-azure ? 1 : 0 + + name = "azure-cluster" + tags = concat(var.tags, ["env:azure", "service:hello-universe-frontend"]) + cloud_account_id = data.spectrocloud_cloudaccount_azure.account[0].id + + cloud_config { + subscription_id = var.azure_subscription_id + resource_group = var.azure_resource_group + region = var.azure-region + ssh_key = tls_private_key.tutorial_ssh_key[0].public_key_openssh + } + + cluster_profile { + id = spectrocloud_cluster_profile.azure-profile[0].id + # id = spectrocloud_cluster_profile.azure-profile-3tier[0].id + } + + machine_pool { + control_plane = true + control_plane_as_worker = true + name = "master-pool" + count = var.azure_master_nodes.count + instance_type = var.azure_master_nodes.instance_type + azs = var.azure-use-azs ? var.azure_master_nodes.azs : [""] + is_system_node_pool = var.azure_master_nodes.is_system_node_pool + disk { + size_gb = var.azure_master_nodes.disk_size_gb + type = "Standard_LRS" + } + } + + machine_pool { + name = "worker-basic" + count = var.azure_worker_nodes.count + instance_type = var.azure_worker_nodes.instance_type + azs = var.azure-use-azs ? var.azure_worker_nodes.azs : [""] + is_system_node_pool = var.azure_worker_nodes.is_system_node_pool + } + + timeouts { + create = "30m" + delete = "15m" + } +} + +resource "spectrocloud_cluster_azure" "azure-cluster-api" { + count = var.deploy-azure ? 1 : 0 + + name = "azure-cluster-api" + tags = concat(var.tags, ["env:azure", "service:hello-universe-backend"]) + cloud_account_id = data.spectrocloud_cloudaccount_azure.account[0].id + + cloud_config { + subscription_id = var.azure_subscription_id + resource_group = var.azure_resource_group + region = var.azure-region + ssh_key = tls_private_key.tutorial_ssh_key[0].public_key_openssh + } + + cluster_profile { + id = spectrocloud_cluster_profile.azure-profile-api[0].id + } + + machine_pool { + control_plane = true + control_plane_as_worker = true + name = "master-pool" + count = var.azure_master_nodes.count + instance_type = var.azure_master_nodes.instance_type + azs = var.azure-use-azs ? var.azure_master_nodes.azs : [""] + is_system_node_pool = var.azure_master_nodes.is_system_node_pool + disk { + size_gb = var.azure_master_nodes.disk_size_gb + type = "Standard_LRS" + } + } + + machine_pool { + name = "worker-basic" + count = var.azure_worker_nodes.count + instance_type = var.azure_worker_nodes.instance_type + azs = var.azure-use-azs ? var.azure_worker_nodes.azs : [""] + is_system_node_pool = var.azure_worker_nodes.is_system_node_pool + } + + timeouts { + create = "30m" + delete = "15m" + } +} + +resource "local_file" "azure-kubeconfig" { + count = var.deploy-azure ? 1 : 0 + + content = data.spectrocloud_cluster.azure_cluster_api[0].kube_config + filename = "azure-cluster-api.kubeconfig" + file_permission = "0644" + directory_permission = "0755" +} + +######################### +# GCP Cluster Profile +######################### +resource "spectrocloud_cluster_gcp" "gcp-cluster" { + count = var.deploy-gcp ? 1 : 0 + + name = "gcp-cluster" + tags = concat(var.tags, ["env:gcp", "service:hello-universe-frontend"]) + cloud_account_id = data.spectrocloud_cloudaccount_gcp.account[0].id + + cloud_config { + project = var.gcp_project_name + region = var.gcp-region + } + + cluster_profile { + id = spectrocloud_cluster_profile.gcp-profile[0].id + # id = spectrocloud_cluster_profile.gcp-profile-3tier[0].id + } + + machine_pool { + control_plane = true + control_plane_as_worker = true + name = "master-pool" + count = var.gcp_master_nodes.count + instance_type = var.gcp_master_nodes.instance_type + disk_size_gb = var.gcp_master_nodes.disk_size_gb + azs = var.gcp_master_nodes.availability_zones + } + + machine_pool { + name = "worker-pool" + count = var.gcp_worker_nodes.count + instance_type = var.gcp_worker_nodes.instance_type + disk_size_gb = var.gcp_worker_nodes.disk_size_gb + azs = var.gcp_worker_nodes.availability_zones + } + + timeouts { + create = "30m" + delete = "15m" + } +} + +resource "spectrocloud_cluster_gcp" "gcp-cluster-api" { + count = var.deploy-gcp ? 1 : 0 + + name = "gcp-cluster-api" + tags = concat(var.tags, ["env:gcp", "service:hello-universe-backend"]) + cloud_account_id = data.spectrocloud_cloudaccount_gcp.account[0].id + + cloud_config { + project = var.gcp_project_name + region = var.gcp-region + } + + cluster_profile { + id = spectrocloud_cluster_profile.gcp-profile-api[0].id + } + + machine_pool { + control_plane = true + control_plane_as_worker = true + name = "master-pool" + count = var.gcp_master_nodes.count + instance_type = var.gcp_master_nodes.instance_type + disk_size_gb = var.gcp_master_nodes.disk_size_gb + azs = var.gcp_master_nodes.availability_zones + } + + machine_pool { + name = "worker-pool" + count = var.gcp_worker_nodes.count + instance_type = var.gcp_worker_nodes.instance_type + disk_size_gb = var.gcp_worker_nodes.disk_size_gb + azs = var.gcp_worker_nodes.availability_zones + } + + timeouts { + create = "30m" + delete = "15m" + } +} + +resource "local_file" "gcp-kubeconfig" { + count = var.deploy-gcp ? 1 : 0 + + content = data.spectrocloud_cluster.gcp_cluster_api[0].kube_config + filename = "gcp-cluster-api.kubeconfig" + file_permission = "0644" + directory_permission = "0755" +} diff --git a/terraform/iaas-cluster-update-tf/data.tf b/terraform/iaas-cluster-update-tf/data.tf new file mode 100644 index 0000000..7a03ecd --- /dev/null +++ b/terraform/iaas-cluster-update-tf/data.tf @@ -0,0 +1,129 @@ +#################################### +# Data resources for the profile +#################################### +data "spectrocloud_registry" "public_registry" { + name = "Public Repo" +} + +############# +# AWS +############# +data "spectrocloud_cloudaccount_aws" "account" { + count = var.deploy-aws ? 1 : 0 + name = var.aws-cloud-account-name +} + +data "spectrocloud_pack" "aws_csi" { + name = "csi-aws-ebs" + version = "1.22.0" + registry_uid = data.spectrocloud_registry.public_registry.id +} + +data "spectrocloud_pack" "aws_cni" { + name = "cni-calico" + version = "3.26.1" + registry_uid = data.spectrocloud_registry.public_registry.id +} + +data "spectrocloud_pack" "aws_k8s" { + name = "kubernetes" + version = "1.27.5" + registry_uid = data.spectrocloud_registry.public_registry.id +} + +data "spectrocloud_pack" "aws_ubuntu" { + name = "ubuntu-aws" + version = "22.04" + registry_uid = data.spectrocloud_registry.public_registry.id +} + +data "spectrocloud_cluster" "aws_cluster_api" { + count = var.deploy-aws ? 1 : 0 + + name = "aws-cluster-api" + context = "project" + + depends_on = [spectrocloud_cluster_aws.aws-cluster-api] +} + +############# +# Azure +############# +data "spectrocloud_cloudaccount_azure" "account" { + count = var.deploy-azure ? 1 : 0 + name = var.azure-cloud-account-name +} + +data "spectrocloud_pack" "azure_csi" { + name = "csi-azure" + version = "1.28.3" + registry_uid = data.spectrocloud_registry.public_registry.id +} + +data "spectrocloud_pack" "azure_cni" { + name = "cni-calico-azure" + version = "3.26.1" + registry_uid = data.spectrocloud_registry.public_registry.id +} + +data "spectrocloud_pack" "azure_k8s" { + name = "kubernetes" + version = "1.27.5" + registry_uid = data.spectrocloud_registry.public_registry.id +} + +data "spectrocloud_pack" "azure_ubuntu" { + name = "ubuntu-azure" + version = "22.04" + registry_uid = data.spectrocloud_registry.public_registry.id +} + +data "spectrocloud_cluster" "azure_cluster_api" { + count = var.deploy-azure ? 1 : 0 + + name = "azure-cluster-api" + context = "project" + + depends_on = [spectrocloud_cluster_azure.azure-cluster-api] +} + +############# +# GCP +############# +data "spectrocloud_cloudaccount_gcp" "account" { + count = var.deploy-gcp ? 1 : 0 + name = var.gcp-cloud-account-name +} + +data "spectrocloud_pack" "gcp_csi" { + name = "csi-gcp-driver" + version = "1.8.2" + registry_uid = data.spectrocloud_registry.public_registry.id +} + +data "spectrocloud_pack" "gcp_cni" { + name = "cni-calico" + version = "3.26.1" + registry_uid = data.spectrocloud_registry.public_registry.id +} + +data "spectrocloud_pack" "gcp_k8s" { + name = "kubernetes" + version = "1.27.5" + registry_uid = data.spectrocloud_registry.public_registry.id +} + +data "spectrocloud_pack" "gcp_ubuntu" { + name = "ubuntu-gcp" + version = "22.04" + registry_uid = data.spectrocloud_registry.public_registry.id +} + +data "spectrocloud_cluster" "gcp_cluster_api" { + count = var.deploy-gcp ? 1 : 0 + + name = "gcp-cluster-api" + context = "project" + + depends_on = [spectrocloud_cluster_gcp.gcp-cluster-api] +} diff --git a/terraform/iaas-cluster-update-tf/inputs.tf b/terraform/iaas-cluster-update-tf/inputs.tf new file mode 100644 index 0000000..d56bb91 --- /dev/null +++ b/terraform/iaas-cluster-update-tf/inputs.tf @@ -0,0 +1,215 @@ +variable "aws-cloud-account-name" { + type = string + description = "The name of your AWS account as assigned in Palette" + default = "" +} +variable "gcp-cloud-account-name" { + type = string + description = "The name of your GCP account as assigned in Palette" + default = "" +} + +variable "azure-cloud-account-name" { + type = string + description = "The name of your Azure account as assigned in Palette" + default = "" +} + +variable "gcp_project_name" { + type = string + description = "The name of your GCP project" + default = "" +} + +variable "deploy-aws" { + type = bool + description = "A flag for enabling a deployment on AWS" +} + +variable "deploy-gcp" { + type = bool + description = "A flag for enabling a deployment on GCP" +} + +variable "deploy-azure" { + type = bool + description = "A flag for enabling a deployment on Azure" +} + +variable "azure_subscription_id" { + type = string + description = "Azure subscription ID" + default = "" +} + +variable "azure_resource_group" { + type = string + description = "Azure resource group" + default = "" +} + +variable "azure-use-azs" { + type = bool + description = "A flag for configuring whether to use Azure Availability Zones. Check if your Azure region supports availability zones by reviewing the [Azure Regions and Availability Zones](https://learn.microsoft.com/en-us/azure/reliability/availability-zones-service-support#azure-regions-with-availability-zone-support) resource" +} + +variable "aws-region" { + type = string + description = "AWS region" + default = "us-east-1" +} + +variable "gcp-region" { + type = string + description = "GCP region" + default = "us-central1" +} + +variable "azure-region" { + type = string + description = "Azure region" + default = "eastus" +} + +variable "aws-hello-universe-api-uri" { + type = string + description = "The URI of the hello-universe-api service deployed to AWS." + default = "http://REPLACE_ME:3000" +} + +variable "azure-hello-universe-api-uri" { + type = string + description = "The URI of the hello-universe-api service deployed to Azure." + default = "http://REPLACE_ME:3000" +} + +variable "gcp-hello-universe-api-uri" { + type = string + description = "The URI of the hello-universe-api service deployed to GCP." + default = "http://REPLACE_ME:3000" +} + +variable "aws-key-pair-name" { + type = string + description = "The name of the AWS key pair to use for SSH access to the cluster. Refer to [EC2 Key Pairs](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html) to learn more." + default = "" +} + +variable "aws_master_nodes" { + type = object({ + count = string + control_plane = bool + instance_type = string + disk_size_gb = string + availability_zones = list(string) + }) + default = { + count = "1" + control_plane = true + instance_type = "m4.2xlarge" + disk_size_gb = "60" + availability_zones = ["us-east-1a"] + } + description = "AWS master nodes configuration." +} +variable "aws_worker_nodes" { + type = object({ + count = string + control_plane = bool + instance_type = string + disk_size_gb = string + availability_zones = list(string) + }) + default = { + count = "1" + control_plane = false + instance_type = "m4.2xlarge" + disk_size_gb = "60" + availability_zones = ["us-east-1a"] + } + description = "AWS worker nodes configuration." +} + +variable "azure_master_nodes" { + type = object({ + count = string + control_plane = bool + instance_type = string + disk_size_gb = string + azs = list(string) + is_system_node_pool = bool + }) + default = { + count = "1" + control_plane = true + instance_type = "Standard_A8_v2" + disk_size_gb = "60" + azs = ["1"] + is_system_node_pool = false } + description = "Azure master nodes configuration." +} + +variable "azure_worker_nodes" { + type = object({ + count = string + control_plane = bool + instance_type = string + disk_size_gb = string + azs = list(string) + is_system_node_pool = bool + }) + default = { + count = "1" + control_plane = false + instance_type = "Standard_A8_v2" + disk_size_gb = "60" + azs = ["1"] + is_system_node_pool = false } + description = "Azure worker nodes configuration." +} + +variable "gcp_master_nodes" { + type = object({ + count = string + control_plane = bool + instance_type = string + disk_size_gb = string + availability_zones = list(string) + }) + default = { + count = "1" + control_plane = true + instance_type = "n1-standard-4" + disk_size_gb = "60" + availability_zones = ["us-central1-a"] } + description = "GCP master nodes configuration." +} + +variable "gcp_worker_nodes" { + type = object({ + count = string + control_plane = bool + instance_type = string + disk_size_gb = string + availability_zones = list(string) + }) + default = { + count = "1" + control_plane = false + instance_type = "n1-standard-4" + disk_size_gb = "60" + availability_zones = ["us-central1-a"] } + description = "GCP worker nodes configuration." +} + +variable "tags" { + type = list(string) + description = "The default tags to apply to Palette resources" + default = [ + "spectro-cloud-education", + "app:hello-universe", + "repository:spectrocloud:tutorials", + "terraform_managed:true", + "tutorial:iaas-cluster-deployment-tf" + ] +} diff --git a/terraform/iaas-cluster-update-tf/manifests/hello-universe-3tier.yaml b/terraform/iaas-cluster-update-tf/manifests/hello-universe-3tier.yaml new file mode 100644 index 0000000..47c9bfe --- /dev/null +++ b/terraform/iaas-cluster-update-tf/manifests/hello-universe-3tier.yaml @@ -0,0 +1,43 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: hello-universe +--- +apiVersion: v1 +kind: Service +metadata: + name: hello-universe-service + namespace: hello-universe +spec: + type: LoadBalancer + ports: + - protocol: TCP + port: 8080 + targetPort: 8080 + selector: + app: hello-universe +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-universe-deployment + namespace: hello-universe +spec: + replicas: 2 + selector: + matchLabels: + app: hello-universe + template: + metadata: + labels: + app: hello-universe + spec: + containers: + - name: hello-universe + image: ghcr.io/spectrocloud/hello-universe:1.1.0 + imagePullPolicy: IfNotPresent + ports: + - containerPort: 8080 + env: + - name: API_URI + value: ${api_uri} diff --git a/terraform/iaas-cluster-update-tf/manifests/hello-universe-api.yaml b/terraform/iaas-cluster-update-tf/manifests/hello-universe-api.yaml new file mode 100644 index 0000000..2ccb3f8 --- /dev/null +++ b/terraform/iaas-cluster-update-tf/manifests/hello-universe-api.yaml @@ -0,0 +1,79 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: hello-universe-api +--- +apiVersion: v1 +kind: Service +metadata: + name: hello-universe-api-service + namespace: hello-universe-api +spec: + type: LoadBalancer + ports: + - protocol: TCP + port: 3000 + targetPort: 3000 + selector: + app: hello-universe-api +--- +apiVersion: v1 +kind: Service +metadata: + name: hello-universe-db-service + namespace: hello-universe-api +spec: + type: ClusterIP + ports: + - protocol: TCP + port: 5432 + targetPort: 5432 + selector: + app: hello-universe-db +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-universe-api-deployment + namespace: hello-universe-api +spec: + replicas: 1 + selector: + matchLabels: + app: hello-universe-api + template: + metadata: + labels: + app: hello-universe-api + spec: + containers: + - name: hello-universe-api + image: ghcr.io/spectrocloud/hello-universe-api:1.0.9 + imagePullPolicy: IfNotPresent + ports: + - containerPort: 3000 + env: + - name: DB_HOST + value: "hello-universe-db-service.hello-universe-api.svc.cluster.local" +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-universe-db-deployment + namespace: hello-universe-api +spec: + replicas: 1 + selector: + matchLabels: + app: hello-universe-db + template: + metadata: + labels: + app: hello-universe-db + spec: + containers: + - name: hello-universe-db + image: ghcr.io/spectrocloud/hello-universe-db:1.0.0 + imagePullPolicy: IfNotPresent + ports: + - containerPort: 5432 diff --git a/terraform/iaas-cluster-update-tf/manifests/hello-universe.yaml b/terraform/iaas-cluster-update-tf/manifests/hello-universe.yaml new file mode 100644 index 0000000..d601ec7 --- /dev/null +++ b/terraform/iaas-cluster-update-tf/manifests/hello-universe.yaml @@ -0,0 +1,40 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: hello-universe +--- +apiVersion: v1 +kind: Service +metadata: + name: hello-universe-service + namespace: hello-universe +spec: + type: LoadBalancer + ports: + - protocol: TCP + port: 8080 + targetPort: 8080 + selector: + app: hello-universe +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello-universe-deployment + namespace: hello-universe +spec: + replicas: 2 + selector: + matchLabels: + app: hello-universe + template: + metadata: + labels: + app: hello-universe + spec: + containers: + - name: hello-universe + image: ghcr.io/spectrocloud/hello-universe:1.1.0 + imagePullPolicy: IfNotPresent + ports: + - containerPort: 8080 diff --git a/terraform/iaas-cluster-update-tf/outputs.tf b/terraform/iaas-cluster-update-tf/outputs.tf new file mode 100644 index 0000000..cd99003 --- /dev/null +++ b/terraform/iaas-cluster-update-tf/outputs.tf @@ -0,0 +1,23 @@ +output "Advisory" { + value = <<-EOT + +It takes between one to three minutes for DNS to properly resolve the public load balancer URL. +We recommend waiting a few moments before clicking on the service URL to prevent the browser from caching an unresolved DNS request. + +EOT +} + +output "aws_hello_universe_api_ip" { + description = "Instructions to retrieve the IP address of the hello-universe-api service deployed to AWS." + value = var.deploy-aws ? "Use the following command to get the IP address of hello-universe-api service:\n\nexport KUBECONFIG=$(pwd)/aws-cluster-api.kubeconfig && \\\nkubectl get service hello-universe-api-service --namespace hello-universe-api --output jsonpath='{.status.loadBalancer.ingress[0].hostname}'" : null +} + +output "azure_hello_universe_api_ip" { + description = "Instructions to retrieve the IP address of the hello-universe-api service deployed to Azure." + value = var.deploy-azure ? "Use the following command to get the IP address of hello-universe-api service:\n\nexport KUBECONFIG=$(pwd)/azure-cluster-api.kubeconfig && \\\nkubectl get service hello-universe-api-service --namespace hello-universe-api --output jsonpath='{.status.loadBalancer.ingress[0].ip}'" : null +} + +output "gcp_hello_universe_api_ip" { + description = "Instructions to retrieve the IP address of the hello-universe-api service deployed to GCP." + value = var.deploy-gcp ? "Use the following command to get the IP address of hello-universe-api service:\n\nexport KUBECONFIG=$(pwd)/gcp-cluster-api.kubeconfig && \\\nkubectl get service hello-universe-api-service --namespace hello-universe-api --output jsonpath='{.status.loadBalancer.ingress[0].ip}'" : null +} diff --git a/terraform/iaas-cluster-update-tf/provider.tf b/terraform/iaas-cluster-update-tf/provider.tf new file mode 100644 index 0000000..ed6e533 --- /dev/null +++ b/terraform/iaas-cluster-update-tf/provider.tf @@ -0,0 +1,23 @@ +terraform { + required_providers { + spectrocloud = { + version = ">= 0.17.2" + source = "spectrocloud/spectrocloud" + } + tls = { + source = "hashicorp/tls" + version = "4.0.4" + } + + local = { + source = "hashicorp/local" + version = ">= 2.4.0" + } + } + + required_version = ">= 1.5" +} + +provider "spectrocloud" { + project_name = "Default" +} diff --git a/terraform/iaas-cluster-update-tf/ssh-key.tf b/terraform/iaas-cluster-update-tf/ssh-key.tf new file mode 100644 index 0000000..897cf60 --- /dev/null +++ b/terraform/iaas-cluster-update-tf/ssh-key.tf @@ -0,0 +1,5 @@ +resource "tls_private_key" "tutorial_ssh_key" { + count = var.deploy-azure ? 1 : 0 + algorithm = "RSA" + rsa_bits = "4096" +} diff --git a/terraform/iaas-cluster-update-tf/terraform.tfvars b/terraform/iaas-cluster-update-tf/terraform.tfvars new file mode 100644 index 0000000..e0ed62c --- /dev/null +++ b/terraform/iaas-cluster-update-tf/terraform.tfvars @@ -0,0 +1,84 @@ +########################### +# AWS Deployment Settings +############################ +deploy-aws = false # Set to true to deploy to AWS + +aws-cloud-account-name = "REPLACE_ME" +aws-region = "REPLACE_ME" +aws-key-pair-name = "REPLACE_ME" + +aws-hello-universe-api-uri = "http://REPLACE_ME:3000" # Set IP address of hello-universe API once deployed + +aws_master_nodes = { + count = "1" + control_plane = true + instance_type = "m4.2xlarge" + disk_size_gb = "60" + availability_zones = ["REPLACE_ME"] # If you want to deploy to multiple AZs, add them here. Example: ["us-east-1a", "us-east-1b"] +} + +aws_worker_nodes = { + count = "1" + control_plane = false + instance_type = "m4.2xlarge" + disk_size_gb = "60" + availability_zones = ["REPLACE_ME"] # If you want to deploy to multiple AZs, add them here. Example: ["us-east-1a", "us-east-1b"] +} + +########################### +# Azure Deployment Settings +############################ +deploy-azure = false # Set to true to deploy to Azure +azure-use-azs = true # Set to false when you deploy to a region without AZs + +azure-cloud-account-name = "REPLACE_ME" +azure-region = "REPLACE_ME" +azure_subscription_id = "REPLACE_ME" +azure_resource_group = "REPLACE_ME" + +azure-hello-universe-api-uri = "http://REPLACE_ME:3000" # Set IP address of hello-universe API once deployed + +azure_master_nodes = { + count = "1" + control_plane = true + instance_type = "Standard_A8_v2" + disk_size_gb = "60" + azs = ["1"] # If you want to deploy to multiple AZs, add them here. + is_system_node_pool = false +} + +azure_worker_nodes = { + count = "1" + control_plane = false + instance_type = "Standard_A8_v2" + disk_size_gb = "60" + azs = ["1"] # If you want to deploy to multiple AZs, add them here. + is_system_node_pool = false +} + +########################### +# GCP Deployment Settings +############################ +deploy-gcp = false # Set to true to deploy to GCP + +gcp-cloud-account-name = "REPLACE_ME" +gcp-region = "REPLACE_ME" +gcp_project_name = "REPLACE_ME" + +gcp-hello-universe-api-uri = "http://REPLACE_ME:3000" # Set IP address of hello-universe API once deployed + +gcp_master_nodes = { + count = "1" + control_plane = true + instance_type = "n1-standard-4" + disk_size_gb = "60" + availability_zones = ["REPLACE_ME"] # If you want to deploy to multiple AZs, add them here. Example: ["us-central1-a", "us-central1-b"] +} + +gcp_worker_nodes = { + count = "1" + control_plane = false + instance_type = "n1-standard-4" + disk_size_gb = "60" + availability_zones = ["REPLACE_ME"] # If you want to deploy to multiple AZs, add them here. Example: ["us-central1-a", "us-central1-b"] +}
"spectro-cloud-education",
"app:hello-universe",
"repository:spectrocloud:tutorials",
"terraform_managed:true",
"tutorial:iaas-cluster-deployment-tf"
]