Spotinst Terraform Module to integrate existing k8s with Ocean
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:
provider "spotinst" {
token = "redacted"
account = "redacted"
}
module "ocean-aws-k8s" {
source = "spotinst/ocean-aws-k8s/spotinst"
...
}
## Option 1 to initialize kubernetes provider ##
# Data Resources for kubernetes provider
data "aws_eks_cluster" "cluster" {
name = "cluster name"
}
data "aws_eks_cluster_auth" "cluster" {
name = "cluster name"
}
provider "kubernetes" {
host = data.aws_eks_cluster.cluster.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
token = data.aws_eks_cluster_auth.cluster.token
}
##################
## Option 2 to initialize kubernetes provider ##
provider "kubernetes" {
config_path = "~/.kube/config"
}
##################
module "ocean-controller" {
source = "spotinst/ocean-controller/spotinst"
# Credentials.
spotinst_token = "redacted"
spotinst_account = "redacted"
# Configuration.
cluster_identifier = "cluster name"
}
~> You must configure the same cluster_identifier
both for the Ocean controller and for the spotinst_ocean_aws
resource. The k8s-ocean
module will use the cluster name as the identifier. Ensure this is also used in the controller config
module "ocean-aws-k8s" {
source = "spotinst/ocean-aws-k8s/spotinst"
# Configuration
cluster_name = "Sample-EKS"
region = "us-west-2"
subnet_ids = ["subnet-12345678","subnet-12345678"]
worker_instance_profile_arn = "arn:aws:iam::123456789:instance-profile/Spot-EKS-Workshop-Nodegroup"
security_groups = ["sg-123456789","sg-123456789"]
# Overwrite Name Tag and add additional
tags = {Name = "Ocean-Nodes", CreatedBy = "Terraform"}
}
Name | Version |
---|---|
spotinst/spotinst | >= 1.64.1 |
hashicorp/aws |
ocean-aws-k8s
- Creates Ocean Clusterocean-controller
- Create and installs Spot Ocean controller pod Dococean-aws-k8s-vng
- (Optional) Add custom virtual node groups Doc
If you're new to Spot and want to get started, please checkout our Getting Started guide, available on the Spot Documentation website.
We use GitHub issues for tracking bugs and feature requests. Please use these community resources for getting help:
- Ask a question on Stack Overflow and tag it with terraform-spotinst.
- Join our Spot community on Slack.
- Open an issue.
Please see the contribution guidelines.