Ocean GKE

This post demonstrates how to create an Ocean Cluster by importing an existing GKE cluster using the Spotinst Terraform V3 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"

  min_size = 0
  max_size = 2
  desired_capacity = 0

  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]


output "controller_cluster_id" {
  value = "${spotinst_ocean_gke_import.ocean-gke-example.cluster_controller_id}"


  • cluster_name – (Required) The group name.
  • location – (Required) The maximum number of instances the group should have at any time.
  • max_size – (Optional, Default: 1000) The upper limit of instances the cluster can scale up to.
  • min_size – (Optional) The lower limit of instances the cluster can scale down to.
  • desired_capacity – (Optional) The number of instances to launch and maintain in the cluster.
  • whitelist – (Required) the list of instance types to be used by Ocean when provisioning new instances.
  • backend_services – (Optional) Describes the backend service configurations.
    • 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 when location_type is regional. 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.