Skip to content

Commit

Permalink
added openstack support (#49)
Browse files Browse the repository at this point in the history
Co-authored-by: Piyush Kumar <[email protected]>
  • Loading branch information
Piyush Kumar and kpiyush17 authored Aug 2, 2021
1 parent ee1459d commit 5ff8aa6
Show file tree
Hide file tree
Showing 29 changed files with 1,580 additions and 8 deletions.
21 changes: 21 additions & 0 deletions docs/data-sources/cloudaccount_openstack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
page_title: "spectrocloud_cloudaccount_openstack Data Source - terraform-provider-spectrocloud"
subcategory: ""
description: |-
---

# Data Source `spectrocloud_cloudaccount_openstack`





## Schema

### Optional

- **id** (String) The ID of this resource.
- **name** (String)


46 changes: 46 additions & 0 deletions docs/resources/cloudaccount_openstack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
page_title: "spectrocloud_cloudaccount_openstack Resource - terraform-provider-spectrocloud"
subcategory: ""
description: |-
---

# Resource `spectrocloud_cloudaccount_openstack`



## Example Usage

```terraform
resource "spectrocloud_cloudaccount_openstack" "account" {
name = "openstack-dev"
private_cloud_gateway_id = ""
openstack_username = var.openstack_username
openstack_password = var.openstack_password
identity_endpoint = var.identity_endpoint
parent_region = var.region
default_domain = var.domain
default_project = var.project
}
```

## Schema

### Required

- **default_domain** (String)
- **default_project** (String)
- **identity_endpoint** (String)
- **name** (String)
- **openstack_password** (String, Sensitive)
- **openstack_username** (String)
- **parent_region** (String)
- **private_cloud_gateway_id** (String)

### Optional

- **ca_certificate** (String)
- **id** (String) The ID of this resource.
- **openstack_allow_insecure** (Boolean)


214 changes: 214 additions & 0 deletions docs/resources/cluster_openstack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
---
page_title: "spectrocloud_cluster_openstack Resource - terraform-provider-spectrocloud"
subcategory: ""
description: |-
---

# Resource `spectrocloud_cluster_openstack`



## Example Usage

```terraform
data "spectrocloud_cloudaccount_openstack" "account" {
# id = <uid>
name = var.cluster_cloud_account_name
}
data "spectrocloud_cluster_profile" "profile" {
# id = <uid>
name = var.cluster_cluster_profile_name
}
data "spectrocloud_backup_storage_location" "bsl" {
name = var.backup_storage_location_name
}
resource "spectrocloud_cluster_openstack" "cluster" {
name = "openstack-piyush-tf-1"
cluster_profile {
id = data.spectrocloud_cluster_profile.profile.id
}
cloud_account_id = data.spectrocloud_cloudaccount_openstack.account.id
tags = ["dev"]
cloud_config {
domain = "Default"
project = "dev"
region = "RegionOne"
ssh_key = "Spectro2021"
dns_servers = ["10.10.128.8", "8.8.8.8"]
subnet_cidr = "192.168.151.0/24"
}
machine_pool {
control_plane = true
control_plane_as_worker = true
name = "master-pool"
count = 1
instance_type = "spectro-xlarge"
azs = ["zone1"]
}
machine_pool {
name = "worker-basic"
count = 2
instance_type = "spectro-large"
azs = ["zone1"]
}
backup_policy {
schedule = "0 0 * * SUN"
backup_location_id = data.spectrocloud_backup_storage_location.bsl.id
prefix = "prod-backup"
expiry_in_hour = 7200
include_disks = true
include_cluster_resources = true
}
scan_policy {
configuration_scan_schedule = "0 0 * * SUN"
penetration_scan_schedule = "0 0 * * SUN"
conformance_scan_schedule = "0 0 1 * *"
}
}
```

## Schema

### Required

- **cloud_account_id** (String)
- **cloud_config** (Block List, Min: 1, Max: 1) (see [below for nested schema](#nestedblock--cloud_config))
- **machine_pool** (Block List, Min: 1) (see [below for nested schema](#nestedblock--machine_pool))
- **name** (String)

### Optional

- **backup_policy** (Block List, Max: 1) (see [below for nested schema](#nestedblock--backup_policy))
- **cluster_profile** (Block List) (see [below for nested schema](#nestedblock--cluster_profile))
- **cluster_profile_id** (String, Deprecated)
- **id** (String) The ID of this resource.
- **os_patch_after** (String)
- **os_patch_on_boot** (Boolean)
- **os_patch_schedule** (String)
- **pack** (Block List) (see [below for nested schema](#nestedblock--pack))
- **scan_policy** (Block List, Max: 1) (see [below for nested schema](#nestedblock--scan_policy))
- **tags** (Set of String)
- **timeouts** (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

### Read-only

- **cloud_config_id** (String)
- **kubeconfig** (String)

<a id="nestedblock--cloud_config"></a>
### Nested Schema for `cloud_config`

Required:

- **dns_servers** (Set of String)
- **domain** (String)
- **project** (String)
- **region** (String)
- **ssh_key** (String)
- **subnet_cidr** (String)

Optional:

- **network_id** (String)
- **subnet_id** (String)


<a id="nestedblock--machine_pool"></a>
### Nested Schema for `machine_pool`

Required:

- **count** (Number)
- **instance_type** (String)
- **name** (String)

Optional:

- **azs** (Set of String)
- **control_plane** (Boolean)
- **control_plane_as_worker** (Boolean)
- **subnet_id** (String)
- **update_strategy** (String)


<a id="nestedblock--backup_policy"></a>
### Nested Schema for `backup_policy`

Required:

- **backup_location_id** (String)
- **expiry_in_hour** (Number)
- **prefix** (String)
- **schedule** (String)

Optional:

- **include_cluster_resources** (Boolean)
- **include_disks** (Boolean)
- **namespaces** (Set of String)


<a id="nestedblock--cluster_profile"></a>
### Nested Schema for `cluster_profile`

Required:

- **id** (String) The ID of this resource.

Optional:

- **pack** (Block List) (see [below for nested schema](#nestedblock--cluster_profile--pack))

<a id="nestedblock--cluster_profile--pack"></a>
### Nested Schema for `cluster_profile.pack`

Required:

- **name** (String)
- **tag** (String)
- **values** (String)



<a id="nestedblock--pack"></a>
### Nested Schema for `pack`

Required:

- **name** (String)
- **tag** (String)
- **values** (String)


<a id="nestedblock--scan_policy"></a>
### Nested Schema for `scan_policy`

Required:

- **configuration_scan_schedule** (String)
- **conformance_scan_schedule** (String)
- **penetration_scan_schedule** (String)


<a id="nestedblock--timeouts"></a>
### Nested Schema for `timeouts`

Optional:

- **create** (String)
- **delete** (String)
- **update** (String)


2 changes: 1 addition & 1 deletion docs/resources/project.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ description: |-
## Example Usage

```terraform
resource "spectrocloud_team" "project" {
resource "spectrocloud_project" "project" {
name = "dev1"
}
```
Expand Down
8 changes: 8 additions & 0 deletions examples/e2e/openstack/kubectl.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
resource "local_file" "kubeconfig" {
content = local.cluster_kubeconfig
filename = "kubeconfig_openstack-1"
file_permission = "0644"
directory_permission = "0755"
}
*/
5 changes: 5 additions & 0 deletions examples/e2e/openstack/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
locals {
cluster_kubeconfig = spectrocloud_cluster_openstack.cluster.kubeconfig
}
*/
34 changes: 34 additions & 0 deletions examples/e2e/openstack/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
terraform {
required_providers {
spectrocloud = {
version = ">= 0.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
}
16 changes: 16 additions & 0 deletions examples/e2e/openstack/resource_cloudaccount.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
resource "spectrocloud_cloudaccount_openstack" "account" {
name = "openstack-dev"
private_cloud_gateway_id = "60fe915794168c655c0d766a"
openstack_username = var.openstack_username
openstack_password = var.openstack_password
identity_endpoint = var.identity_endpoint
parent_region = var.region
default_domain = var.domain
default_project = var.project
}
*/

data "spectrocloud_cloudaccount_openstack" "account" {
name = "openstack-pcg-piyush-dev-2"
}
38 changes: 38 additions & 0 deletions examples/e2e/openstack/resource_cluster.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

resource "spectrocloud_cluster_openstack" "cluster" {
name = "openstack-piyush-tf-1"

cluster_profile {
id = data.spectrocloud_cluster_profile.profile.id
}

cloud_account_id = data.spectrocloud_cloudaccount_openstack.account.id
tags = ["dev"]


cloud_config {
domain = "Default"
project = "dev"
region = "RegionOne"
ssh_key = "Spectro2021"
dns_servers = ["10.10.128.8", "8.8.8.8"]
subnet_cidr = "192.168.151.0/24"
}

machine_pool {
control_plane = true
control_plane_as_worker = true
name = "master-pool"
count = 1
instance_type = "spectro-xlarge"
azs = ["zone1"]
}

machine_pool {
name = "worker-basic"
count = 2
instance_type = "spectro-large"
azs = ["zone1"]
}

}
Loading

0 comments on commit 5ff8aa6

Please sign in to comment.