Skip to content

Commit

Permalink
add support for image family (GoogleCloudPlatform#54)
Browse files Browse the repository at this point in the history
Problem: the user wants to use a custom image family,
and currently the families are hard coded.
Solution: add the family name as a variable.

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
Co-authored-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
2 people authored and wardharold committed May 23, 2023
1 parent 332db19 commit b558d17
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 4 deletions.
6 changes: 6 additions & 0 deletions fluxfw-gcp/tf/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
module "management_node" {
source = "./modules/management"
name_prefix = var.manager_name_prefix
family = var.manager_family

project_id = var.project_id
region = var.region
Expand Down Expand Up @@ -44,6 +45,8 @@ module "login_nodes" {
region = var.region

name_prefix = each.value.name_prefix
family = var.login_family

subnetwork = var.subnetwork
machine_arch = each.value.machine_arch
machine_type = each.value.machine_type
Expand All @@ -69,6 +72,9 @@ module "compute_nodes" {
project_id = var.project_id
region = var.region

family = var.compute_family
arm_family = var.compute_arm_family

name_prefix = each.value.name_prefix
subnetwork = var.subnetwork
machine_arch = each.value.machine_arch
Expand Down
4 changes: 2 additions & 2 deletions fluxfw-gcp/tf/modules/compute/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

data "google_compute_image" "fluxfw_compute_arm64_image" {
project = var.project_id
family = "flux-fw-compute-arm64"
family = var.arm_family
}

data "google_compute_image" "fluxfw_compute_x86_64_image" {
project = var.project_id
family = "flux-fw-compute-x86-64"
family = var.family
}

data "google_compute_zones" "available" {
Expand Down
12 changes: 12 additions & 0 deletions fluxfw-gcp/tf/modules/compute/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

variable "arm_family" {
description = "The source arm image family prefix to use"
type = string
default = "flux-fw-compute-arm64"
}

variable "automatic_restart" {
type = bool
description = "(Optional) Specifies whether the instance should be automatically restarted if it is terminated by Compute Engine (not terminated by a user)."
Expand All @@ -30,6 +36,12 @@ variable "compact_placement" {
default = false
}

variable "family" {
description = "The source X86 image family prefix to use"
type = string
default = "flux-fw-compute-x86-64"
}

variable "gpu" {
description = "The type and count of GPU(s) to attach to a compute node"
type = object({
Expand Down
2 changes: 1 addition & 1 deletion fluxfw-gcp/tf/modules/login/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

data "google_compute_image" "fluxfw_login_x86_64_image" {
project = var.project_id
family = "flux-fw-login-x86-64"
family = var.family
}

data "google_compute_zones" "available" {
Expand Down
6 changes: 6 additions & 0 deletions fluxfw-gcp/tf/modules/login/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ variable "boot_script" {
default = null
}

variable "family" {
description = "The source image family prefix to use"
type = string
default = "flux-fw-login-x86-64"
}

variable "machine_arch" {
description = "The instruction set architecture, ARM64 or x86_64, used by the login node"
type = string
Expand Down
2 changes: 1 addition & 1 deletion fluxfw-gcp/tf/modules/management/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

data "google_compute_image" "fluxfw_manager_image" {
project = var.project_id
family = "flux-fw-manager"
family = var.family
}

module "flux_manager_instance_template" {
Expand Down
6 changes: 6 additions & 0 deletions fluxfw-gcp/tf/modules/management/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ variable "compute_node_specs" {
type = string
}

variable "family" {
description = "The source image family prefix to use"
type = string
default = "flux-fw-manager"
}

variable "login_node_specs" {
description = "A JSON encoded list of maps each with the keys: 'name_prefix', 'machin_arch', 'machine_type', and 'instances' which describe the login node instances to create"
type = string
Expand Down
26 changes: 26 additions & 0 deletions fluxfw-gcp/tf/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ variable "cluster_storage" {
type = map(string)
}

variable "compute_arm_family" {
description = "The source arm image family prefix to be used by the compute node(s)"
type = string
default = "flux-fw-compute-arm64"
}

variable "compute_family" {
description = "The source image x86 prefix to be used by the compute node(s)"
type = string
default = "flux-fw-compute-x86-64"
}

variable "compute_node_specs" {
description = "A list of compute node specifications"
type = list(object({
Expand All @@ -39,6 +51,14 @@ variable "compute_scopes" {
type = set(string)
}


variable "login_family" {
description = "The source image prefix to be used by the login node"
type = string
default = "flux-fw-login-x86-64"
}


variable "login_node_specs" {
description = "A list of login node specifications"
type = list(object({
Expand All @@ -58,6 +78,12 @@ variable "login_scopes" {
type = set(string)
}

variable "manager_family" {
description = "The source image prefix to be used by the manager"
type = string
default = "flux-fw-manager"
}

variable "manager_machine_type" {
description = "The Compute Engine machine type to be used for the management node [note: must be an x86_64 or AMD machine type]"
type = string
Expand Down

0 comments on commit b558d17

Please sign in to comment.