Skip to content

Commit

Permalink
Lint terraform configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
JMGaljaard committed Sep 6, 2022
1 parent d4a630e commit 586d2da
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 93 deletions.
19 changes: 9 additions & 10 deletions terraform/terraform-dependencies/main.tf
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@

data "google_client_config" "default" {}



data "kustomization_build" "training-operator" {
# Retrieve kustomize templates
data "kustomization_build" "training_operator" {
path = "github.com/kubeflow/manifests.git/apps/training-operator/upstream/overlays/standalone?ref=${var.kubeflow_version}"
}


resource "kustomization_resource" "training-operator" {
for_each = data.kustomization_build.training-operator.ids
manifest = data.kustomization_build.training-operator.manifests[each.value]
# Deploy resources one-by-one.
resource "kustomization_resource" "training_operator" {
for_each = data.kustomization_build.training_operator.ids
manifest = data.kustomization_build.training_operator.manifests[each.value]
}

# Create NFS resource
Expand All @@ -19,15 +18,15 @@ resource "helm_release" "nfs_client_provisioner" {
repository = var.nfs_provisioner_repo_url
chart = var.nfs_provider_information.chart_name

namespace = var.nfs_provider_information.namespace
create_namespace = true
namespace = var.nfs_provider_information.namespace
create_namespace = true

values = [
templatefile("${path.module}/values.nfs.yaml.tpl", {
nfs_server_path = var.nfs_provider_information.server_path
image_repository = var.nfs_provider_information.image_repository
image_tag = var.nfs_provider_information.image_tag
pull_policy = var.nfs_provider_information.pull_policy
pull_policy = var.nfs_provider_information.pull_policy
nfs_size = var.nfs_provider_information.storage_size
})
]
Expand Down
28 changes: 14 additions & 14 deletions terraform/terraform-dependencies/providers.tf
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
locals {
terraform_service_account = "${var.account_id}@${var.project_id}.iam.gserviceaccount.com"
terraform_service_account = "${var.account_id}@${var.project_id}.iam.gserviceaccount.com"
}

provider "google" {
alias = "impersonation"
scopes = [
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/userinfo.email",
]
alias = "impersonation"
scopes = [
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/userinfo.email",
]
}

data "google_service_account_access_token" "default" {
provider = google.impersonation
target_service_account = local.terraform_service_account
scopes = ["userinfo-email", "cloud-platform"]
lifetime = "1200s"
provider = google.impersonation
target_service_account = local.terraform_service_account
scopes = ["userinfo-email", "cloud-platform"]
lifetime = "1200s"
}

provider "google" {
project = var.project_id
access_token = data.google_service_account_access_token.default.access_token
request_timeout = "60s"
project = var.project_id
access_token = data.google_service_account_access_token.default.access_token
request_timeout = "60s"
}

# Kustomization (i.e. Kustomize) requires kubernets config
# Kustomization (i.e. Kustomize) requires kubernetes config
provider "kustomization" {
kubeconfig_path = var.kubernetes_config_path
}
Expand Down
46 changes: 23 additions & 23 deletions terraform/terraform-dependencies/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,57 @@ variable "kubernetes_config_path" {
}

variable "project_id" {
type = string
default = "test-bed-fltk"
type = string
default = "test-bed-fltk"
description = "Google Cloud project name to create cluster in."
}

variable "cluster_name" {
type = string
default = "fltk-testbed-cluster"
type = string
default = "fltk-testbed-cluster"
description = "Name of the GKE cluster to be deployed in project <project_id>."
}

variable "project_region" {
type = string
default = "us-central1"
type = string
default = "us-central1"
description = "GKE region to deploy cluster in."
}

variable "project_zone" {
type = string
default = "us-central1-c"
type = string
default = "us-central1-c"
description = "GKE region to deploy cluster in."
}

variable "description" {
type = string
type = string
default = "Managed by terraform FLTK testbed deployment"
}

variable "account_id" {
type = string
type = string
description = "The service account Identifier to be used to interact with Google cloud."
default = "terraform-iam-service-account"
default = "terraform-iam-service-account"
}

variable "kubeflow_version" {
type = string
type = string
description = "Kubeflow (training operator) to install."
default = "v1.5.0"
default = "v1.5.0"
}

variable "nfs_provider_information" {
type = object({
release_name = string
chart_name = string
namespace = string
server_path = string
image_repository = string
image_tag = string
pull_policy = string
storage_size = string
})
type = object({
release_name = string
chart_name = string
namespace = string
server_path = string
image_repository = string
image_tag = string
pull_policy = string
storage_size = string
})
default = {
release_name = "nfs-server"
chart_name = "nfs-server-provisioner"
Expand Down
12 changes: 6 additions & 6 deletions terraform/terraform-gke/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module "gke" {
name = var.cluster_name
regional = var.regional_deployment
region = var.project_region
zones = slice(var.project_zones, 0, 1)
zones = slice(var.project_zones, 0, 1)
network = module.gcp-network.network_name
subnetwork = module.gcp-network.subnets_names[0]
ip_range_pods = var.ip_range_pods_name
Expand Down Expand Up @@ -92,15 +92,15 @@ module "gke" {
}

node_pools_taints = {
all = []
default-node-pool = [] # Default nodepool that will contain all the other pods
all = []
default-node-pool = [] # Default nodepool that will contain all the other pods

# Taint node pool for scheduling testbed-pods only/preferentially
medium-fltk-pool-1 = [
{
key = "fltk.node" # Taint is used in fltk pods
value = "medium-e2" # In case more explicit matching is required
effect = "PREFER_NO_SCHEDULE" # Other Pods are preferably not scheduled on this pool
key = "fltk.node" # Taint is used in fltk pods
value = "medium-e2" # In case more explicit matching is required
effect = "PREFER_NO_SCHEDULE" # Other Pods are preferably not scheduled on this pool
},
]
}
Expand Down
32 changes: 16 additions & 16 deletions terraform/terraform-gke/providers.tf
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
locals {
terraform_service_account = "${var.account_id}@${var.project_id}.iam.gserviceaccount.com"
terraform_service_account = "${var.account_id}@${var.project_id}.iam.gserviceaccount.com"
}

provider "google" {
alias = "impersonation"
scopes = [
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/userinfo.email",
]
alias = "impersonation"
scopes = [
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/userinfo.email",
]
}

data "google_service_account_access_token" "default" {
provider = google.impersonation
target_service_account = local.terraform_service_account
scopes = ["userinfo-email", "cloud-platform"]
lifetime = "1200s"
provider = google.impersonation
target_service_account = local.terraform_service_account
scopes = ["userinfo-email", "cloud-platform"]
lifetime = "1200s"
}

provider "google" {
project = var.project_id
access_token = data.google_service_account_access_token.default.access_token
request_timeout = "60s"
project = var.project_id
access_token = data.google_service_account_access_token.default.access_token
request_timeout = "60s"
}

provider "google-beta" {
project = var.project_id
access_token = data.google_service_account_access_token.default.access_token
request_timeout = "60s"
project = var.project_id
access_token = data.google_service_account_access_token.default.access_token
request_timeout = "60s"
}
41 changes: 17 additions & 24 deletions terraform/terraform-gke/variables.tf
Original file line number Diff line number Diff line change
@@ -1,65 +1,58 @@

variable "kubernetes_version" {
type = string
description = "Kubernetes version to use, note that kubeflow depends on version pre-1.22 for deployment as of now."
default = "1.21"
default = "1.21"
}

variable "project_id" {
type = string
default = "test-bed-fltk"
type = string
default = "test-bed-fltk"
description = "Google Cloud project name to create cluster in."
}

variable "cluster_name" {
type = string
default = "fltk-testbed-cluster"
type = string
default = "fltk-testbed-cluster"
description = "Name of the GKE cluster to be deployed in project <project_id>."
}

variable "regional_deployment" {
type = bool
default = false
type = bool
default = false
description = "Whether to deploy regional (additional 0.10 USD/hour cost for management) for higher availability."
}


variable "project_region" {
type = string
default = "us-central1"
type = string
default = "us-central1"
description = "GKE region to deploy cluster in."
}

variable "project_zones" {
type = list
default = ["us-central1-c"]
type = list(string)
default = ["us-central1-c"]
description = "GKE zones to deploy in. Zonal deployment will only take first zone."
}

variable "description" {
type = string
type = string
description = "Service account description"
default = "Managed by terraform FLTK testbed deployment"
default = "Managed by terraform FLTK testbed deployment"
}

variable "account_id" {
description = "The service account Identifier to be used to interact with Google cloud."
default = "terraform-iam-service-account"
}

variable "delete_on_destroy" {
type = bool
description = "Whether or not to tear down the entire project in GCP"
default = false
default = "terraform-iam-service-account"
}

variable "network" {
description = "Private network to be used by the cluster during deployment."
default = "gcp-private-network"
default = "gcp-private-network"
}

variable "subnetwork" {
description = "Subnetwork name for private network used in the cluster."
default = "gcp-private-subnetwork"
default = "gcp-private-subnetwork"
}

variable "ip_range_pods_name" {
Expand Down

0 comments on commit 586d2da

Please sign in to comment.