Ocean GKE
This post demonstrates how to create an Ocean Cluster by importing an existing GKE cluster using the Spotinst Terraform V2 plugin.
This post assumes that you already have a Spotinst account and went through Spotinst Terraform Installation.Creating a GKE Ocean Cluster
Example Usage – Creating a GKE Ocean Import resource – Basic Example
resource "spotinst_ocean_gke_import" "example" { cluster_name = "example-cluster-name" location = "us-central1-a" whitelist = ["n1-standard-1", "n1-standard-2"] backend_services = [{ service_name = "example-backend-service" location_type = "regional" scheme = "INTERNAL" named_ports = { name = "http" ports = [80, 8080] } }] }
Parameters
cluster_name
– (Required) The group name.location
– (Required) The maximum number of instances the group should have at any time.whitelist
– (Required) the list of instance types to be used by Ocean when provisioning new instances.backend_services
– (Required) The minimum number of instances the group should have at any time.
service_name
– (Required) The name of the backend service.location_type
– (Optional) Sets which location the backend services will be active. Valid values:regional
,global
.scheme
– (Optional) Use whenlocation_type
isregional
. Set the traffic for the backend service to either between the instances in the VPC, or to traffic from the internet. Valid values:INTERNAL
,EXTERNAL
.named_port
– (Optional) Describes a named port and a list of ports.
port_name
– (Required) The name of the port.ports
– (Required) A list of ports.
Example Usage – Creating a custom GKE Ocean Launch Specification
Provides a custom Spotinst Ocean GKE Launch Spec resource.
resource "spotinst_ocean_gke_launch_spec" "example" { ocean_id = "o-123456" source_image = "image" metadata = [{ key = "gci-update-strategy" value = "update_disabled" }] labels = [{ key = "labelKey" value = "labelVal" }] taints = [{ key = "taintKey" value = "taintVal" effect = "taintEffect" }] }
Parameters
ocean_id
– (Required) The ID of the Ocean cluster in which the launchSpec is to be created.source_image
– (Required) Image URL.metadata
– (Required) launchSpec’s metadata.labels
– (Optional) Set labels for the custom launchSpec.taints
– (Optional) launchSpec’s taints.Example Usage – Creating a GKE Ocean Launch Specification Import
Provides a custom Spotinst Ocean GKE Launch Specification Import resource. Used to import an existing node pool into a Launch Specification of an existing Ocean cluster.
resource "spotinst_ocean_gke_launch_spec_import" "example" { ocean_id = "o-123456" node_pool_name = "default-pool" }
Parameters
ocean_id
– (Required) The ID of the Ocean cluster in which the launchSpec is to be created.node_pool_name
– (Required) The node pool to be imported.