Skip to content

Commit

Permalink
New ocean controller and tidying (#51)
Browse files Browse the repository at this point in the history
* [examples] Bump default k8s version to current stable (1.30)

* [examples] Use ocean-controller v2 where possible (not Azure) and bump ocean-aws-k8s version accordingly

* [examples/from-scratch-with-eks-addon] removed due to redundancy (is equivalent to from-scratch)

* [examples] spotinst_token marked as sensitive

* [examples/azure-from-scratch] use ocean controller v2

* [examples/azure-from-vpc] use ocean controller v2

* [examples/azure-import-aks-cluster] use ocean controller v2

* [examples/from-scratch] use ocean controller v2

* [examples/aws-examples] use ocean controller v2

* [examples/gcp-examples] use ocean controller v2

* [examples/aws-examples] use ocean controller v2

* [examples/*-examples] tf lint

* [examples/*-examples] add helm to required providers

* update docs

* clean the versions file and remove non needed providers

* fix the vpc blueprints example

---------

Co-authored-by: Hafdís Erla <hafdis.helgadottir@netapp.com>
  • Loading branch information
Z4ck404 and HafdisE authored Nov 4, 2024
1 parent 6c9d404 commit 8215ab9
Show file tree
Hide file tree
Showing 43 changed files with 218 additions and 590 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ It can be combined with other Terraform modules to support a number of installat
1. Use the [AWS `vpc` Terraform Module](https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws/latest) to create a VPC network.
2. use the [AWS `eks` Terraform Module](https://registry.terraform.io/modules/terraform-aws-modules/eks/aws/latest) to create an EKS cluster.
3. Use the [SPOTINST `ocean-aws-k8s` Terraform module](https://registry.terraform.io/modules/spotinst/ocean-aws-k8s/spotinst/latest) to import the EKS cluster into Ocean
4. Use the [SPOTINST `ocean-controller` Terraform module](https://registry.terraform.io/modules/spotinst/ocean-controller/spotinst/latest) to install the controller deployment into kubernetes
4. Use the [SPOTINST `kubernetes-controller` Terraform module](https://registry.terraform.io/modules/spotinst/kubernetes-controller/ocean/latest) to install the ocean controller deployment into kubernetes
5. Use the [SPOTINST `ocean-spark` Terraform module](this module) to import the cluster into Ocean Spark.

Folder [`examples/from-scratch/`](https://github.com/spotinst/terraform-spotinst-ocean-spark/tree/main/examples/from-scratch) contains a full example.
Expand All @@ -59,7 +59,7 @@ Folder [`examples/from-scratch/`](https://github.com/spotinst/terraform-spotinst
1. Use the [AWS `vpc` Terraform Module](https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws/latest) to create a VPC network.
2. Use the [AWS `eks` Terraform module](https://registry.terraform.io/modules/terraform-aws-modules/eks/aws/latest) to create an EKS cluster.
3. Use the [SPOTINST `ocean-aws-k8s` Terraform module](https://registry.terraform.io/modules/spotinst/ocean-aws-k8s/spotinst/latest) to import the EKS cluster into Ocean
4. Use the [SPOTINST `ocean-controller` Terraform module](https://registry.terraform.io/modules/spotinst/ocean-controller/spotinst/latest) to install the controller deployment into kubernetes
4. Use the [SPOTINST `kubernetes-controller` Terraform module](https://registry.terraform.io/modules/spotinst/kubernetes-controller/ocean/latest) to install the ocean controller deployment into kubernetes
5. Create the Private link required resources (NLB, VPC endpoint service and LB TargetGroup). [AWS Docs About PrivateLink](https://docs.aws.amazon.com/vpc/latest/privatelink/getting-started.html).
6. Use the [ Terraform AWS EKS LB Controller Module](https://github.com/DNXLabs/terraform-aws-eks-lb-controller) to install the aws load balancer controller in the EKS cluster.
7. Use the [SPOTINST `ocean-spark` Terraform module](this module) to import the cluster into Ocean Spark and set the [ ingress private link input ](https://registry.terraform.io/providers/spotinst/spotinst/latest/docs/resources/ocean_spark#nestedblock--ingress--private_link)
Expand All @@ -70,7 +70,7 @@ Folder [`examples/from-scratch-with-private-link/`](https://github.com/spotinst/

1. use the [GCP `google_container_cluster` Terraform resource](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster) to create an GKE cluster.
2. Use the [SPOTINST `spotinst_ocean_gke_import` Terraform resource](https://registry.terraform.io/providers/spotinst/spotinst/latest/docs/resources/ocean_gke_import) to import the GKE cluster into Ocean
3. Use the [SPOTINST `ocean-controller` Terraform module](https://registry.terraform.io/modules/spotinst/ocean-controller/spotinst/latest) to install the controller deployment into kubernetes
3. Use the [SPOTINST `kubernetes-controller` Terraform module](https://registry.terraform.io/modules/spotinst/kubernetes-controller/ocean/latest) to install the ocean controller deployment into kubernetes
4. Use the [SPOTINST `ocean-spark` Terraform module](this module) to import the cluster into Ocean Spark.

Folder [`examples/gcp-from-scratch/`](https://github.com/spotinst/terraform-spotinst-ocean-spark/blob/main/examples/gcp-from-scratch/main.tf) contains a full example.
Expand All @@ -89,15 +89,15 @@ Folder [`examples/azure-from-scratch/`](https://github.com/spotinst/terraform-sp
#### 5. Import an existing EKS cluster

1. Use the [SPOTINST `ocean-aws-k8s` Terraform module](https://registry.terraform.io/modules/spotinst/ocean-aws-k8s/spotinst/latest) to import the EKS cluster into Ocean
2. Use the [SPOTINST `ocean-controller` Terraform module](https://registry.terraform.io/modules/spotinst/ocean-controller/spotinst/latest) to install the controller deployment into kubernetes
2. Use the [SPOTINST `kubernetes-controller` Terraform module](https://registry.terraform.io/modules/spotinst/kubernetes-controller/ocean/latest) to install the ocean controller deployment into kubernetes
3. Use the [SPOTINST `ocean-spark` Terraform module](this module) to import the cluster into Ocean Spark.

Folder [`examples/import-eks-cluster/`](https://github.com/spotinst/terraform-spotinst-ocean-spark/tree/main/examples/import-eks-cluster) contains a full example.

#### 6. Import an existing GKE cluster

1. Use the [SPOTINST `spotinst_ocean_gke_import` Terraform resource](https://registry.terraform.io/providers/spotinst/spotinst/latest/docs/resources/ocean_gke_import) to import the GKE cluster into Ocean
2. Use the [SPOTINST `ocean-controller` Terraform module](https://registry.terraform.io/modules/spotinst/ocean-controller/spotinst/latest) to install the controller deployment into kubernetes
2. Use the [SPOTINST `kubernetes-controller` Terraform module](https://registry.terraform.io/modules/spotinst/kubernetes-controller/ocean/latest) to install the ocean controller deployment into kubernetes
3. Use the [SPOTINST `ocean-spark` Terraform module](this module) to import the cluster into Ocean Spark.

Folder [`examples/gcp-import-gke-cluster/`](https://github.com/spotinst/terraform-spotinst-ocean-spark/blob/main/examples/gcp-import-gke-cluster/) contains a full example.
Expand Down
31 changes: 14 additions & 17 deletions examples/azure-from-scratch/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,26 @@ module "aks" {
###############################################################################
# Import AKS cluster into Ocean
###############################################################################

provider "kubernetes" {
host = module.aks.admin_host
username = module.aks.admin_username
password = module.aks.admin_password
client_certificate = base64decode(module.aks.admin_client_certificate)
client_key = base64decode(module.aks.admin_client_key)
cluster_ca_certificate = base64decode(module.aks.admin_cluster_ca_certificate)
provider "helm" {
kubernetes {
host = module.aks.admin_host
username = module.aks.admin_username
password = module.aks.admin_password
cluster_ca_certificate = base64decode(module.aks.admin_cluster_ca_certificate)
client_certificate = base64decode(module.aks.admin_client_certificate)
client_key = base64decode(module.aks.admin_client_key)
}
}

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

spotinst_token = var.spotinst_token
spotinst_account = var.spotinst_account
source = "spotinst/kubernetes-controller/ocean"
version = "0.0.14"

cluster_identifier = var.cluster_name
aks_connector_enabled = true
acd_identifier = var.cluster_name
cluster_identifier = var.cluster_name
spotinst_token = var.spotinst_token
spotinst_account = var.spotinst_account
}


module "ocean-aks-np" {
source = "spotinst/ocean-aks-np-k8s/spotinst"
version = "0.5.0"
Expand Down
5 changes: 3 additions & 2 deletions examples/azure-from-scratch/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ variable "azure_subscription_id" {
}

variable "spotinst_token" {
type = string
type = string
sensitive = true
}

variable "spotinst_account" {
Expand All @@ -33,7 +34,7 @@ variable "cluster_name" {

variable "cluster_version" {
type = string
default = "1.29"
default = "1.30"
}

variable "tags" {
Expand Down
8 changes: 4 additions & 4 deletions examples/azure-from-scratch/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ terraform {
source = "spotinst/spotinst"
version = "~> 1.90"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 2.10"
}
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.47"
}
helm = {
source = "hashicorp/helm"
version = "~> 2.12"
}
}
}
29 changes: 14 additions & 15 deletions examples/azure-from-vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,24 @@ module "aks" {
# Import AKS cluster into Ocean
###############################################################################

provider "kubernetes" {
host = module.aks.admin_host
username = module.aks.admin_username
password = module.aks.admin_password
client_certificate = base64decode(module.aks.admin_client_certificate)
client_key = base64decode(module.aks.admin_client_key)
cluster_ca_certificate = base64decode(module.aks.admin_cluster_ca_certificate)
provider "helm" {
kubernetes {
host = module.aks.admin_host
username = module.aks.admin_username
password = module.aks.admin_password
cluster_ca_certificate = base64decode(module.aks.admin_cluster_ca_certificate)
client_certificate = base64decode(module.aks.admin_client_certificate)
client_key = base64decode(module.aks.admin_client_key)
}
}

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

spotinst_token = var.spotinst_token
spotinst_account = var.spotinst_account
source = "spotinst/kubernetes-controller/ocean"
version = "0.0.14"

cluster_identifier = var.cluster_name
aks_connector_enabled = true
acd_identifier = var.cluster_name
cluster_identifier = var.cluster_name
spotinst_token = var.spotinst_token
spotinst_account = var.spotinst_account
}


Expand Down
5 changes: 3 additions & 2 deletions examples/azure-from-vpc/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ variable "azure_subscription_id" {
}

variable "spotinst_token" {
type = string
type = string
sensitive = true
}

variable "spotinst_account" {
Expand Down Expand Up @@ -41,7 +42,7 @@ variable "cluster_name" {

variable "cluster_version" {
type = string
default = "1.29"
default = "1.30"
}

variable "tags" {
Expand Down
8 changes: 4 additions & 4 deletions examples/azure-from-vpc/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ terraform {
source = "spotinst/spotinst"
version = "~> 1.90"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 2.10"
}
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.47"
}
helm = {
source = "hashicorp/helm"
version = "~> 2.12"
}
}
}
26 changes: 18 additions & 8 deletions examples/azure-import-aks-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ locals {
###############################################################################
# Import AKS cluster into Ocean
###############################################################################

provider "kubernetes" {
host = local.aks_admin.host
username = local.aks_admin.username
password = local.aks_admin.password
client_certificate = base64decode(local.aks_admin.client_certificate)
client_key = base64decode(local.aks_admin.client_key)
cluster_ca_certificate = base64decode(local.aks_admin.cluster_ca_certificate)
provider "helm" {
kubernetes {
host = local.aks_admin.host
username = local.aks_admin.username
password = local.aks_admin.password
client_certificate = base64decode(local.aks_admin.client_certificate)
client_key = base64decode(local.aks_admin.client_key)
cluster_ca_certificate = base64decode(local.aks_admin.cluster_ca_certificate)
}
}

module "ocean-controller" {
Expand All @@ -47,6 +48,15 @@ module "ocean-controller" {
acd_identifier = var.cluster_name
}

module "ocean-controller" {
source = "spotinst/kubernetes-controller/ocean"
version = "0.0.14"

cluster_identifier = var.cluster_name
spotinst_token = var.spotinst_token
spotinst_account = var.spotinst_account
}


module "ocean-aks-np" {
source = "spotinst/ocean-aks-np-k8s/spotinst"
Expand Down
3 changes: 2 additions & 1 deletion examples/azure-import-aks-cluster/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ variable "azure_subscription_id" {
}

variable "spotinst_token" {
type = string
type = string
sensitive = true
}

variable "spotinst_account" {
Expand Down
8 changes: 4 additions & 4 deletions examples/azure-import-aks-cluster/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ terraform {
source = "spotinst/spotinst"
version = "~> 1.90"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 2.10"
}
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.47"
}
helm = {
source = "hashicorp/helm"
version = "~> 2.12"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
variable "spotinst_token" {
type = string
type = string
sensitive = true
}

variable "spotinst_account" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ terraform {
source = "spotinst/spotinst"
version = "~> 1.90"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 2.26.0"
}
aws = {
source = "hashicorp/aws"
version = "~> 5.36"
Expand Down
16 changes: 9 additions & 7 deletions examples/from-private-vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ provider "spotinst" {

module "ocean-aws-k8s" {
source = "spotinst/ocean-aws-k8s/spotinst"
version = "0.2.3"
version = "1.5.0"

cluster_name = module.eks.cluster_id
region = var.aws_region
Expand All @@ -196,15 +196,17 @@ module "ocean-aws-k8s" {
}
}

provider "kubernetes" {
host = module.eks.cluster_endpoint
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
token = data.aws_eks_cluster_auth.this.token
provider "helm" {
kubernetes {
host = module.eks.cluster_endpoint
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
token = data.aws_eks_cluster_auth.this.token
}
}

module "ocean-controller" {
source = "spotinst/ocean-controller/spotinst"
version = "0.43.0"
source = "spotinst/kubernetes-controller/ocean"
version = "~> 0.0.14"

spotinst_token = var.spotinst_token
spotinst_account = var.spotinst_account
Expand Down
5 changes: 3 additions & 2 deletions examples/from-private-vpc/variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
variable "spotinst_token" {
type = string
type = string
sensitive = true
}

variable "spotinst_account" {
Expand All @@ -20,7 +21,7 @@ variable "cluster_name" {

variable "cluster_version" {
type = string
default = "1.29"
default = "1.30"
}

variable "vpc_id" {
Expand Down
8 changes: 4 additions & 4 deletions examples/from-private-vpc/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ terraform {
source = "spotinst/spotinst"
version = "~> 1.90"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 2.10"
}
aws = {
source = "hashicorp/aws"
version = "~> 5.28"
}
helm = {
source = "hashicorp/helm"
version = "~> 2.12"
}
}
}
6 changes: 3 additions & 3 deletions examples/from-scratch-eks-blueprint/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ resource "null_resource" "patience" {

module "ocean-aws-k8s" {
source = "spotinst/ocean-aws-k8s/spotinst"
version = "0.2.3"
version = "1.5.0"

# Configuration
cluster_name = var.cluster_name
Expand Down Expand Up @@ -207,8 +207,8 @@ provider "spotinst" {
}

module "ocean-controller" {
source = "spotinst/ocean-controller/spotinst"
version = "0.43.0"
source = "spotinst/kubernetes-controller/ocean"
version = "~> 0.0.14"

# Credentials.
spotinst_token = var.spotinst_token
Expand Down
3 changes: 3 additions & 0 deletions examples/from-scratch-eks-blueprint/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ terraform {
spotinst = {
source = "spotinst/spotinst"
}
helm = {
source = "hashicorp/helm"
}
}
}
Loading

0 comments on commit 8215ab9

Please sign in to comment.