Skip to content

spotinst/terraform-spotinst-ocean-gcp-k8s

Repository files navigation

terraform-spotinst-ocean-gcp-k8s

Terraform module for Spotinst provider resource spotinst_ocean_gke_import

Prerequisites

Installation of the Ocean controller is required by this resource. You can accomplish this by using the spotinst/ocean-controller module. The kubernetes provider will need to be initilaized before calling the ocean-controller module as follows:

module "ocean-gcp-k8s" {
  source = "spotinst/ocean-gcp-k8s/spotinst"
  ...
}

# Data Resources for kubernetes provider
#initialize the kubernetes provider with access to the specific cluster
provider "kubernetes" {
  host  = "https://${data.google_container_cluster.gke.endpoint}"
  token = data.google_client_config.default.access_token
  cluster_ca_certificate = base64decode(data.google_container_cluster.gke.master_auth[0].cluster_ca_certificate)
}

### data resources ###
data "google_client_config" "default" {}

#Retrieve cluster info to get instance group URLS
data "google_container_cluster" "gke" {
  name     = var.cluster_name
  location = var.location
}
##################

module "ocean-controller" {
  source = "spotinst/ocean-controller/spotinst"

  # Credentials.
  spotinst_account    = var.spotinst_account
  spotinst_token      = var.spotinst_token

  # Configuration.
  cluster_identifier  = module.ocean-gcp-k8s.ocean_controller_id
  tolerations = []
}

~> You must configure the same cluster_identifier both for the Ocean controller and for the spotinst_ocean_gke_import resource.

NOTE: If you would like to create a programmatic user and token for use with the Ocean controller pod review this example.

Usage

#Create Ocean cluster - Import existing GKE cluster
module "ocean-gcp-k8s" {
  source = "spotinst/ocean-gcp-k8s/spotinst"

  # Credentials.
  cluster_name                      = var.cluster_name
  location                          = var.location
}

Providers

Name Version
spotinst/spotinst >= 1.96.0
hashicorp/gcp

Modules

  • ocean-gcp-k8s - Creates Ocean Cluster
  • ocean-gcp-k8s-vng - (Optional) Add custom virtual node groups with custom configs Doc
  • ocean-controller - Create and installs Spot Ocean controller pod Doc

Documentation

If you're new to Spot and want to get started, please checkout our Getting Started guide, available on the Spot Documentation website.

Getting Help

We use GitHub issues for tracking bugs and feature requests. Please use these community resources for getting help:

Community

Contributing

Please see the contribution guidelines.