-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PLT-274: Datasource for ippool. (#208)
* PLT-274: Datasource for ippool. * PLT-274: Refresh docs. * PLT-274: addressing review comments and adding examples for vmware static placement. * PLT-274: correcting provider version for a vmware static example. --------- Co-authored-by: nikolay-spectro <[email protected]>
- Loading branch information
Showing
22 changed files
with
459 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "spectrocloud_ippool Data Source - terraform-provider-spectrocloud" | ||
subcategory: "" | ||
description: |- | ||
--- | ||
|
||
# spectrocloud_ippool (Data Source) | ||
|
||
|
||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) The name of the IP pool. | ||
- `private_cloud_gateway_id` (String) The ID of the private cloud gateway. | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "spectrocloud_private_cloud_gateway Data Source - terraform-provider-spectrocloud" | ||
subcategory: "" | ||
description: |- | ||
--- | ||
|
||
# spectrocloud_private_cloud_gateway (Data Source) | ||
|
||
|
||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Optional | ||
|
||
- `id` (String) The ID of Private Cloud Gateway. | ||
- `name` (String) The Name of Private Cloud Gateway. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
data "spectrocloud_private_cloud_gateway" "gateway" { | ||
name = "pcg-benoitcamp-vcenter" | ||
} | ||
|
||
data "spectrocloud_ippool" "ippool" { | ||
name = "IP Pool Jesse" | ||
private_cloud_gateway_id = data.spectrocloud_private_cloud_gateway.gateway.id | ||
} | ||
|
||
variable "private_cloud_gateway_id" { | ||
type = string | ||
} | ||
|
||
output "same" { | ||
value = data.spectrocloud_ippool.ippool.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
terraform { | ||
required_providers { | ||
spectrocloud = { | ||
version = ">= 0.11.1" | ||
source = "spectrocloud/spectrocloud" | ||
} | ||
} | ||
} | ||
|
||
variable "sc_host" {} | ||
variable "sc_username" {} | ||
variable "sc_password" {} | ||
variable "sc_project_name" {} | ||
|
||
provider "spectrocloud" { | ||
host = var.sc_host | ||
username = var.sc_username | ||
password = var.sc_password | ||
project_name = var.sc_project_name | ||
trace = true | ||
} |
7 changes: 7 additions & 0 deletions
7
examples/data-sources/spectrocloud_private_cloud_gateway/datasource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
data "spectrocloud_private_cloud_gateway" "gateway" { | ||
name = "pcg-benoitcamp-vcenter" | ||
} | ||
|
||
output "same" { | ||
value = data.spectrocloud_private_cloud_gateway.gateway.id | ||
} |
21 changes: 21 additions & 0 deletions
21
examples/data-sources/spectrocloud_private_cloud_gateway/providers.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
terraform { | ||
required_providers { | ||
spectrocloud = { | ||
version = ">= 0.11.1" | ||
source = "spectrocloud/spectrocloud" | ||
} | ||
} | ||
} | ||
|
||
variable "sc_host" {} | ||
variable "sc_username" {} | ||
variable "sc_password" {} | ||
variable "sc_project_name" {} | ||
|
||
provider "spectrocloud" { | ||
host = var.sc_host | ||
username = var.sc_username | ||
password = var.sc_password | ||
project_name = var.sc_project_name | ||
trace = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Basic Cluster demo | ||
|
||
End-to-end example of provisioning a new VMware K8s cluster with all of its dependencies. This terraform configuration | ||
will provision the following resources on Spectro Cloud: | ||
- VMware Cluster Profile | ||
- VMware Cluster | ||
|
||
For SaaS deployments, there is a dependency to install the Private Cloud Gateway before VMware K8s clusters can be provisioned. | ||
Please proceed with installation of this appliance by following the documentation: | ||
[Spectro Cloud VMware Cluster](https://docs.spectrocloud.com/getting-started/?getting_started=vmware#yourfirstvmwarecluster). | ||
|
||
Once the private cloud gateway is running, please note the name of the created vSphere cloud account. Cloud accounts are managed | ||
in Spectro Cloud Admin view: | ||
- Login to Spectro Cloud UI (e.g for SaaS: https://console.spectrocloud.com) | ||
- Switch to the Admin view (bottom left in the main-menu) | ||
- Select _Settings_ in the main-menu | ||
- Select _Cloud Accounts_ | ||
- Note the name of the newly added vSphere cloud account | ||
|
||
This name will be specified as the `shared_Vmware_cloud_account_name` option in `terraform.tfvars`. | ||
|
||
Alternatively, look at using a `spectrocloud_cloud_account_vsphere` resource to have Terraform create | ||
a dedicated cloud account for this e2e example. | ||
|
||
## Instructions: | ||
|
||
Clone this repository to a local directory, and change directory to `examples/e2e/vsphere`. Proceed with the following: | ||
1. Follow the Spectro Cloud documentation to create a Private Cloud Gateway: | ||
[VMware First Cluster](https://docs.spectrocloud.com/getting-started/?getting_started=vmware#yourfirstvmwarecluster). | ||
2. From the current directory, copy the template variable file `terraform.template.tfvars` to a new file `terraform.tfvars`. | ||
3. Specify and update all the placeholder values in the `terraform.tfvars` file. | ||
4. Initialize and run terraform: `terraform init && terraform apply`. | ||
5. Wait for the cluster creation to finish. | ||
|
||
Once the cluster is provisioned, the cluster _kubeconfig_ file is exported in the current working directly. | ||
|
||
Export the kubeconfig and check cluster pods: | ||
|
||
```shell | ||
export KUBECONFIG=kubeconfig_vsphere-2 | ||
kubectl get pod -A | ||
``` | ||
|
||
## Clean up: | ||
|
||
Run the destroy operation: | ||
|
||
```shell | ||
terraform destroy | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
data "spectrocloud_private_cloud_gateway" "gateway" { | ||
name = var.gateway_name | ||
} | ||
|
||
data "spectrocloud_ippool" "ippool" { | ||
name = var.ippool_name | ||
private_cloud_gateway_id = data.spectrocloud_private_cloud_gateway.gateway.id | ||
} | ||
|
||
|
||
data "spectrocloud_cluster_profile" "profile" { | ||
name = "vmware-jben" | ||
version = "1.0.0" | ||
context = "project" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
resource "local_file" "kubeconfig" { | ||
content = local.cluster_kubeconfig | ||
filename = "kubeconfig_vsphere-2" | ||
file_permission = "0644" | ||
directory_permission = "0755" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
locals { | ||
cluster_kubeconfig = spectrocloud_cluster_vsphere.cluster.kubeconfig | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
output "cluster_id" { | ||
value = spectrocloud_cluster_vsphere.cluster.id | ||
} | ||
|
||
output "cluster_kubeconfig" { | ||
value = local.cluster_kubeconfig | ||
} | ||
|
||
output "clusterprofile_id" { | ||
value = data.spectrocloud_cluster_profile.profile.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
terraform { | ||
required_providers { | ||
spectrocloud = { | ||
version = ">= 0.11.1" | ||
source = "spectrocloud/spectrocloud" | ||
} | ||
} | ||
} | ||
|
||
variable "sc_host" { | ||
description = "Spectro Cloud Endpoint" | ||
default = "api.spectrocloud.com" | ||
} | ||
|
||
variable "sc_username" { | ||
description = "Spectro Cloud Username" | ||
} | ||
|
||
variable "sc_password" { | ||
description = "Spectro Cloud Password" | ||
sensitive = true | ||
} | ||
|
||
variable "sc_project_name" { | ||
description = "Spectro Cloud Project (e.g: Default)" | ||
default = "Default" | ||
} | ||
|
||
provider "spectrocloud" { | ||
host = var.sc_host | ||
username = var.sc_username | ||
password = var.sc_password | ||
project_name = var.sc_project_name | ||
# ignore_insecure_tls_error = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
resource "spectrocloud_cloudaccount_vsphere" "account" { | ||
name = var.new_vmware_cloud_account_name | ||
context = "project" | ||
private_cloud_gateway_id = data.spectrocloud_private_cloud_gateway.gateway.id | ||
vsphere_vcenter = var.vsphere_vcenter | ||
vsphere_username = var.vsphere_username | ||
vsphere_password = var.vsphere_password | ||
vsphere_ignore_insecure_error = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
resource "spectrocloud_cluster_vsphere" "cluster" { | ||
name = "vsphere-static2" | ||
cloud_account_id = spectrocloud_cloudaccount_vsphere.account.id | ||
|
||
cluster_profile { | ||
id = data.spectrocloud_cluster_profile.profile.id | ||
} | ||
|
||
cloud_config { | ||
ssh_key = var.cluster_ssh_public_key | ||
image_template_folder = var.vsphere_image_template_folder | ||
|
||
datacenter = var.vsphere_datacenter | ||
folder = var.vsphere_folder | ||
|
||
static_ip = true | ||
#network_type = "DDNS" | ||
network_search_domain = var.cluster_network_search | ||
} | ||
|
||
|
||
machine_pool { | ||
control_plane = true | ||
control_plane_as_worker = true | ||
name = "master-pool" | ||
count = 3 | ||
|
||
placement { | ||
cluster = var.vsphere_cluster | ||
resource_pool = var.vsphere_resource_pool | ||
datastore = var.vsphere_datastore | ||
network = var.vsphere_network | ||
static_ip_pool_id = data.spectrocloud_ippool.ippool.id | ||
} | ||
instance_type { | ||
disk_size_gb = 40 | ||
memory_mb = 8192 | ||
cpu = 4 | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Spectro Cloud credentials | ||
sc_host = "{enter Spectro Cloud API endpoint}" #e.g: api.spectrocloud.com (for SaaS) | ||
sc_username = "{enter Spectro Cloud username}" #e.g: [email protected] | ||
sc_password = "{enter Spectro Cloud password}" #e.g: supereSecure1! | ||
sc_project_name = "{enter Spectro Cloud project Name}" #e.g: Default | ||
|
||
# Cloud Account lookup by name | ||
# See README.md for instructions how to obtain this name | ||
shared_vmware_cloud_account_name = "{enter Spectro Cloud VMware Cloud Account name}" | ||
|
||
# SSH public key to inject into all K8s nodes | ||
# Insert your public key between the EOT markers | ||
# The public key starts with "ssh-rsa ...." | ||
cluster_ssh_public_key = <<-EOT | ||
{enter SSH Public Key} | ||
EOT | ||
|
||
# For DHCP, the search domain | ||
cluster_network_search = "{enter DHCP Search domain}" #e.g spectrocloud.local | ||
|
||
# VMware cluster placement properties | ||
# All fields except _vsphere\_resource\_pool_ are required fields | ||
vsphere_datacenter = "{enter vSphere Datacenter}" | ||
vsphere_folder = "{enter vSphere Folder}" | ||
|
||
vsphere_cluster = "{enter vSphere ESX Cluster}" | ||
vsphere_resource_pool = "{enter vSphere Resource Pool}" # Leave "" blank for Cluster Resource pool | ||
vsphere_datastore = "{enter vSphere Datastore}" | ||
vsphere_network = "{enter vSphere Network}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#cluster variables | ||
variable "vsphere_image_template_folder" {} | ||
variable "cluster_ssh_public_key" {} | ||
variable "cluster_network_search" {} | ||
|
||
variable "vsphere_datacenter" {} | ||
variable "vsphere_folder" {} | ||
|
||
variable "vsphere_cluster" {} | ||
variable "vsphere_resource_pool" {} | ||
variable "vsphere_datastore" {} | ||
variable "vsphere_network" {} | ||
|
||
# common | ||
variable "gateway_name" { | ||
type = string | ||
} | ||
|
||
variable "ippool_name" { | ||
type = string | ||
} | ||
|
||
# cloud account variables | ||
variable "new_vmware_cloud_account_name" {} | ||
|
||
variable "vsphere_vcenter" { | ||
type = string | ||
} | ||
|
||
variable "vsphere_username" { | ||
type = string | ||
} | ||
|
||
variable "vsphere_password" { | ||
type = string | ||
sensitive = true | ||
} |
Oops, something went wrong.