-
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-456: Added Gke cluster support (#441)
* gke draft * draft * draft 2 * PLT-456:Added GKE cluster support in terrafrom * added support for node manitenace * Update cluster_common_hash.go added instance type in gke hash * updated sdk part * fixed import scenario * added import example * fix description
- Loading branch information
1 parent
2d2b217
commit b1380ea
Showing
13 changed files
with
1,112 additions
and
6 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,301 @@ | ||
--- | ||
page_title: "spectrocloud_cluster_gke Resource - terraform-provider-spectrocloud" | ||
subcategory: "" | ||
description: |- | ||
Resource for managing GKE clusters through Palette. | ||
--- | ||
|
||
# spectrocloud_cluster_gke (Resource) | ||
|
||
Resource for managing GKE clusters through Palette. | ||
|
||
## Example Usage | ||
|
||
|
||
```terraform | ||
data "spectrocloud_cloudaccount_gcp" "account" { | ||
name = var.gcp_cloud_account_name | ||
} | ||
data "spectrocloud_cluster_profile" "profile" { | ||
name = var.gke_cluster_profile_name | ||
} | ||
resource "spectrocloud_cluster_gke" "cluster" { | ||
name = var.cluster_name | ||
description = "Gke Cluster" | ||
tags = ["dev", "department:pax"] | ||
cloud_account_id = data.spectrocloud_cloudaccount_gcp.account.id | ||
context = "project" | ||
cluster_profile { | ||
id = data.spectrocloud_cluster_profile.profile.id | ||
} | ||
cloud_config { | ||
project = var.gcp_project | ||
region = var.gcp_region | ||
} | ||
update_worker_pool_in_parallel = true | ||
machine_pool { | ||
name = "worker-basic" | ||
count = 3 | ||
instance_type = "n2-standard-4" | ||
} | ||
} | ||
``` | ||
|
||
## Import | ||
|
||
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) | ||
to import the resource spectrocloud_cluster_gke by using its `id` with the Palette `context` separated by a colon. For example: | ||
|
||
```terraform | ||
import { | ||
to = spectrocloud_cluster_gke.example | ||
id = "example_id:context" | ||
} | ||
``` | ||
|
||
Using `terraform import`, import the cluster using the `id` colon separated with `context`. For example: | ||
|
||
```console | ||
% terraform import spectrocloud_cluster_gke.example example_id:project | ||
``` | ||
|
||
Refer to the [Import section](/docs#import) to learn more. | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `cloud_account_id` (String) | ||
- `cloud_config` (Block List, Min: 1, Max: 1) The GKE environment configuration settings such as project parameters and region parameters that apply to this cluster. (see [below for nested schema](#nestedblock--cloud_config)) | ||
- `machine_pool` (Block List, Min: 1) The machine pool configuration for the cluster. (see [below for nested schema](#nestedblock--machine_pool)) | ||
- `name` (String) The name of the cluster. | ||
|
||
### Optional | ||
|
||
- `apply_setting` (String) The setting to apply the cluster profile. `DownloadAndInstall` will download and install packs in one action. `DownloadAndInstallLater` will only download artifact and postpone install for later. Default value is `DownloadAndInstall`. | ||
- `backup_policy` (Block List, Max: 1) The backup policy for the cluster. If not specified, no backups will be taken. (see [below for nested schema](#nestedblock--backup_policy)) | ||
- `cluster_meta_attribute` (String) `cluster_meta_attribute` can be used to set additional cluster metadata information, eg `{'nic_name': 'test', 'env': 'stage'}` | ||
- `cluster_profile` (Block List) (see [below for nested schema](#nestedblock--cluster_profile)) | ||
- `cluster_rbac_binding` (Block List) The RBAC binding for the cluster. (see [below for nested schema](#nestedblock--cluster_rbac_binding)) | ||
- `context` (String) The context of the GKE cluster. Allowed values are `project` or `tenant`. Default is `project`. If the `project` context is specified, the project name will sourced from the provider configuration parameter [`project_name`](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs#schema). | ||
- `description` (String) The description of the cluster. Default value is empty string. | ||
- `force_delete` (Boolean) If set to `true`, the cluster will be force deleted and user has to manually clean up the provisioned cloud resources. | ||
- `force_delete_delay` (Number) Delay duration in minutes to before invoking cluster force delete. Default and minimum is 20. | ||
- `host_config` (Block List) The host configuration for the cluster. (see [below for nested schema](#nestedblock--host_config)) | ||
- `namespaces` (Block List) The namespaces for the cluster. (see [below for nested schema](#nestedblock--namespaces)) | ||
- `os_patch_after` (String) Date and time after which to patch cluster `RFC3339: 2006-01-02T15:04:05Z07:00` | ||
- `os_patch_on_boot` (Boolean) Whether to apply OS patch on boot. Default is `false`. | ||
- `os_patch_schedule` (String) Cron schedule for OS patching. This must be in the form of `0 0 * * *`. | ||
- `pause_agent_upgrades` (String) The pause agent upgrades setting allows to control the automatic upgrade of the Palette component and agent for an individual cluster. The default value is `unlock`, meaning upgrades occur automatically. Setting it to `lock` pauses automatic agent upgrades for the cluster. | ||
- `review_repave_state` (String) To authorize the cluster repave, set the value to `Approved` for approval and `""` to decline. Default value is `""`. | ||
- `scan_policy` (Block List, Max: 1) The scan policy for the cluster. (see [below for nested schema](#nestedblock--scan_policy)) | ||
- `skip_completion` (Boolean) If `true`, the cluster will be created asynchronously. Default value is `false`. | ||
- `tags` (Set of String) A list of tags to be applied to the cluster. Tags must be in the form of `key:value`. | ||
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) | ||
- `update_worker_pool_in_parallel` (Boolean) | ||
|
||
### Read-Only | ||
|
||
- `admin_kube_config` (String) Admin Kube-config for the cluster. This can be used to connect to the cluster using `kubectl`, With admin privilege. | ||
- `cloud_config_id` (String, Deprecated) ID of the cloud config used for the cluster. This cloud config must be of type `azure`. | ||
- `id` (String) The ID of this resource. | ||
- `kubeconfig` (String) Kubeconfig for the cluster. This can be used to connect to the cluster using `kubectl`. | ||
- `location_config` (List of Object) The location of the cluster. (see [below for nested schema](#nestedatt--location_config)) | ||
|
||
<a id="nestedblock--cloud_config"></a> | ||
### Nested Schema for `cloud_config` | ||
|
||
Required: | ||
|
||
- `project` (String) GCP project name. | ||
- `region` (String) | ||
|
||
|
||
<a id="nestedblock--machine_pool"></a> | ||
### Nested Schema for `machine_pool` | ||
|
||
Required: | ||
|
||
- `count` (Number) Number of nodes in the machine pool. | ||
- `instance_type` (String) | ||
- `name` (String) | ||
|
||
Optional: | ||
|
||
- `additional_labels` (Map of String) | ||
- `disk_size_gb` (Number) | ||
- `node` (Block List) (see [below for nested schema](#nestedblock--machine_pool--node)) | ||
- `taints` (Block List) (see [below for nested schema](#nestedblock--machine_pool--taints)) | ||
- `update_strategy` (String) Update strategy for the machine pool. Valid values are `RollingUpdateScaleOut` and `RollingUpdateScaleIn`. | ||
|
||
<a id="nestedblock--machine_pool--node"></a> | ||
### Nested Schema for `machine_pool.node` | ||
|
||
Required: | ||
|
||
- `action` (String) The action to perform on the node. Valid values are: `cordon`, `uncordon`. | ||
- `node_id` (String) The node_id of the node, For example `i-07f899a33dee624f7` | ||
|
||
|
||
<a id="nestedblock--machine_pool--taints"></a> | ||
### Nested Schema for `machine_pool.taints` | ||
|
||
Required: | ||
|
||
- `effect` (String) The effect of the taint. Allowed values are: `NoSchedule`, `PreferNoSchedule` or `NoExecute`. | ||
- `key` (String) The key of the taint. | ||
- `value` (String) The value of the taint. | ||
|
||
|
||
|
||
<a id="nestedblock--backup_policy"></a> | ||
### Nested Schema for `backup_policy` | ||
|
||
Required: | ||
|
||
- `backup_location_id` (String) The ID of the backup location to use for the backup. | ||
- `expiry_in_hour` (Number) The number of hours after which the backup will be deleted. For example, if the expiry is set to 24, the backup will be deleted after 24 hours. | ||
- `prefix` (String) Prefix for the backup name. The backup name will be of the format <prefix>-<cluster-name>-<timestamp>. | ||
- `schedule` (String) The schedule for the backup. The schedule is specified in cron format. For example, to run the backup every day at 1:00 AM, the schedule should be set to `0 1 * * *`. | ||
|
||
Optional: | ||
|
||
- `cluster_uids` (Set of String) The list of cluster UIDs to include in the backup. If `include_all_clusters` is set to `true`, then all clusters will be included. | ||
- `include_all_clusters` (Boolean) Whether to include all clusters in the backup. If set to false, only the clusters specified in `cluster_uids` will be included. | ||
- `include_cluster_resources` (Boolean) Whether to include the cluster resources in the backup. If set to false, only the cluster configuration and disks will be backed up. | ||
- `include_disks` (Boolean) Whether to include the disks in the backup. If set to false, only the cluster configuration will be backed up. | ||
- `namespaces` (Set of String) The list of Kubernetes namespaces to include in the backup. If not specified, all namespaces will be included. | ||
|
||
|
||
<a id="nestedblock--cluster_profile"></a> | ||
### Nested Schema for `cluster_profile` | ||
|
||
Required: | ||
|
||
- `id` (String) The ID of the cluster profile. | ||
|
||
Optional: | ||
|
||
- `pack` (Block List) For packs of type `spectro`, `helm`, and `manifest`, at least one pack must be specified. (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) The name of the pack. The name must be unique within the cluster profile. | ||
|
||
Optional: | ||
|
||
- `manifest` (Block List) (see [below for nested schema](#nestedblock--cluster_profile--pack--manifest)) | ||
- `registry_uid` (String) The registry UID of the pack. The registry UID is the unique identifier of the registry. This attribute is required if there is more than one registry that contains a pack with the same name. | ||
- `tag` (String) The tag of the pack. The tag is the version of the pack. This attribute is required if the pack type is `spectro` or `helm`. | ||
- `type` (String) The type of the pack. Allowed values are `spectro`, `manifest` or `helm`. The default value is `spectro`. | ||
- `uid` (String) The unique identifier of the pack. The value can be looked up using the [`spectrocloud_pack`](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack) data source. This value is required if the pack type is `spectro`. | ||
- `values` (String) The values of the pack. The values are the configuration values of the pack. The values are specified in YAML format. | ||
|
||
<a id="nestedblock--cluster_profile--pack--manifest"></a> | ||
### Nested Schema for `cluster_profile.pack.manifest` | ||
|
||
Required: | ||
|
||
- `content` (String) The content of the manifest. The content is the YAML content of the manifest. | ||
- `name` (String) The name of the manifest. The name must be unique within the pack. | ||
|
||
Read-Only: | ||
|
||
- `uid` (String) | ||
|
||
|
||
|
||
|
||
<a id="nestedblock--cluster_rbac_binding"></a> | ||
### Nested Schema for `cluster_rbac_binding` | ||
|
||
Required: | ||
|
||
- `type` (String) The type of the RBAC binding. Can be one of the following values: `RoleBinding`, or `ClusterRoleBinding`. | ||
|
||
Optional: | ||
|
||
- `namespace` (String) The Kubernetes namespace of the RBAC binding. Required if 'type' is set to 'RoleBinding'. | ||
- `role` (Map of String) The role of the RBAC binding. Required if 'type' is set to 'RoleBinding'. | ||
- `subjects` (Block List) (see [below for nested schema](#nestedblock--cluster_rbac_binding--subjects)) | ||
|
||
<a id="nestedblock--cluster_rbac_binding--subjects"></a> | ||
### Nested Schema for `cluster_rbac_binding.subjects` | ||
|
||
Required: | ||
|
||
- `name` (String) The name of the subject. Required if 'type' is set to 'User' or 'Group'. | ||
- `type` (String) The type of the subject. Can be one of the following values: `User`, `Group`, or `ServiceAccount`. | ||
|
||
Optional: | ||
|
||
- `namespace` (String) The Kubernetes namespace of the subject. Required if 'type' is set to 'ServiceAccount'. | ||
|
||
|
||
|
||
<a id="nestedblock--host_config"></a> | ||
### Nested Schema for `host_config` | ||
|
||
Optional: | ||
|
||
- `external_traffic_policy` (String) The external traffic policy for the cluster. | ||
- `host_endpoint_type` (String) The type of endpoint for the cluster. Can be either 'Ingress' or 'LoadBalancer'. The default is 'Ingress'. | ||
- `ingress_host` (String) The host for the Ingress endpoint. Required if 'host_endpoint_type' is set to 'Ingress'. | ||
- `load_balancer_source_ranges` (String) The source ranges for the load balancer. Required if 'host_endpoint_type' is set to 'LoadBalancer'. | ||
|
||
|
||
<a id="nestedblock--namespaces"></a> | ||
### Nested Schema for `namespaces` | ||
|
||
Required: | ||
|
||
- `name` (String) Name of the namespace. This is the name of the Kubernetes namespace in the cluster. | ||
- `resource_allocation` (Map of String) Resource allocation for the namespace. This is a map containing the resource type and the resource value. For example, `{cpu_cores: '2', memory_MiB: '2048'}` | ||
|
||
Optional: | ||
|
||
- `images_blacklist` (List of String) List of images to disallow for the namespace. For example, `['nginx:latest', 'redis:latest']` | ||
|
||
|
||
<a id="nestedblock--scan_policy"></a> | ||
### Nested Schema for `scan_policy` | ||
|
||
Required: | ||
|
||
- `configuration_scan_schedule` (String) The schedule for configuration scan. | ||
- `conformance_scan_schedule` (String) The schedule for conformance scan. | ||
- `penetration_scan_schedule` (String) The schedule for penetration scan. | ||
|
||
|
||
<a id="nestedblock--timeouts"></a> | ||
### Nested Schema for `timeouts` | ||
|
||
Optional: | ||
|
||
- `create` (String) | ||
- `delete` (String) | ||
- `update` (String) | ||
|
||
|
||
<a id="nestedatt--location_config"></a> | ||
### Nested Schema for `location_config` | ||
|
||
Read-Only: | ||
|
||
- `country_code` (String) | ||
- `country_name` (String) | ||
- `latitude` (Number) | ||
- `longitude` (Number) | ||
- `region_code` (String) | ||
- `region_name` (String) |
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 @@ | ||
terraform { | ||
required_providers { | ||
spectrocloud = { | ||
version = ">= 0.1" | ||
source = "spectrocloud/spectrocloud" | ||
} | ||
} | ||
} | ||
|
||
provider "spectrocloud" { | ||
host = var.sc_host | ||
api_key = var.sc_api_key | ||
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,31 @@ | ||
data "spectrocloud_cloudaccount_gcp" "account" { | ||
name = var.gcp_cloud_account_name | ||
} | ||
|
||
data "spectrocloud_cluster_profile" "profile" { | ||
name = var.gke_cluster_profile_name | ||
} | ||
|
||
|
||
resource "spectrocloud_cluster_gke" "cluster" { | ||
name = var.cluster_name | ||
description = "Gke Cluster" | ||
tags = ["dev", "department:pax"] | ||
cloud_account_id = data.spectrocloud_cloudaccount_gcp.account.id | ||
context = "project" | ||
|
||
cluster_profile { | ||
id = data.spectrocloud_cluster_profile.profile.id | ||
} | ||
|
||
cloud_config { | ||
project = var.gcp_project | ||
region = var.gcp_region | ||
} | ||
update_worker_pool_in_parallel = true | ||
machine_pool { | ||
name = "worker-basic" | ||
count = 3 | ||
instance_type = "n2-standard-4" | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
examples/resources/spectrocloud_cluster_gke/terraform.template.tfvars
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,19 @@ | ||
# Spectro Cloud credentials | ||
sc_host = "{Enter Spectro Cloud API Host}" #e.g: api.spectrocloud.com (for SaaS) | ||
sc_api_key = "{Enter Spectro Cloud API Key}" | ||
sc_project_name = "{Enter Spectro Cloud Project Name}" #e.g: Default | ||
|
||
# Google Cloud account credentials | ||
# Create a new GCP service account with the Editor role mapping | ||
# https://cloud.google.com/iam/docs/creating-managing-service-account-keys | ||
# | ||
# Paste the service account JSON key contents inside the yaml heredoc EOT markers. | ||
gcp_serviceaccount_json = <<-EOT | ||
{enter GCP service account json} | ||
EOT | ||
|
||
# GCP Cluster Placement properties | ||
# | ||
gcp_network = "{enter GCP network}" #e.g: "" (this one can be blank) | ||
gcp_project = "{enter GCP project}" | ||
gcp_region = "{enter GCP region}" #e.g: us-west3 |
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,19 @@ | ||
variable "sc_host" { | ||
description = "Spectro Cloud Endpoint" | ||
default = "api.spectrocloud.com" | ||
} | ||
|
||
variable "sc_api_key" { | ||
description = "Spectro Cloud API key" | ||
} | ||
|
||
variable "sc_project_name" { | ||
description = "Spectro Cloud Project (e.g: Default)" | ||
default = "Default" | ||
} | ||
|
||
variable "gcp_cloud_account_name" {} | ||
variable "gke_cluster_profile_name" {} | ||
variable "gcp_project" {} | ||
variable "gcp_region" {} | ||
variable "cluster_name" {} |
Oops, something went wrong.