diff --git a/docs/resources/google_compute_node_group.md b/docs/resources/google_compute_node_group.md index d223c74c8..0cc0727c5 100644 --- a/docs/resources/google_compute_node_group.md +++ b/docs/resources/google_compute_node_group.md @@ -40,6 +40,10 @@ Properties that can be accessed from the `google_compute_node_group` resource: * `maintenance_policy`: Specifies how to handle instances when a node in the group undergoes maintenance. Set to one of: DEFAULT, RESTART_IN_PLACE, or MIGRATE_WITHIN_NODE_GROUP. The default value is DEFAULT. + * `maintenance_window`: contains properties for the timeframe of maintenance + + * `start_time`: instances.start time of the window. This must be in UTC format that resolves to one of 00:00, 04:00, 08:00, 12:00, 16:00, or 20:00. For example, both 13:00-5 and 08:00 are valid. + * `autoscaling_policy`: If you use sole-tenant nodes for your workloads, you can use the node group autoscaler to automatically manage the sizes of your node groups. * `mode`: The autoscaling mode. Set to one of the following: - OFF: Disables the autoscaler. - ON: Enables scaling in and scaling out. - ONLY_SCALE_OUT: Enables only scaling out. You must use this mode if your node groups are configured to restart their hosted VMs on minimal servers. diff --git a/docs/resources/google_compute_node_groups.md b/docs/resources/google_compute_node_groups.md index 56e61c30d..ddedf9bd2 100644 --- a/docs/resources/google_compute_node_groups.md +++ b/docs/resources/google_compute_node_groups.md @@ -31,6 +31,7 @@ See [google_compute_node_group.md](google_compute_node_group.md) for more detail * `node_templates`: an array of `google_compute_node_group` node_template * `sizes`: an array of `google_compute_node_group` size * `maintenance_policies`: an array of `google_compute_node_group` maintenance_policy + * `maintenance_windows`: an array of `google_compute_node_group` maintenance_window * `autoscaling_policies`: an array of `google_compute_node_group` autoscaling_policy * `zones`: an array of `google_compute_node_group` zone diff --git a/libraries/google/compute/property/nodegroup_maintenance_window.rb b/libraries/google/compute/property/nodegroup_maintenance_window.rb new file mode 100644 index 000000000..b776546d5 --- /dev/null +++ b/libraries/google/compute/property/nodegroup_maintenance_window.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in README.md and +# CONTRIBUTING.md located at the root of this package. +# +# ---------------------------------------------------------------------------- +module GoogleInSpec + module Compute + module Property + class NodeGroupMaintenanceWindow + attr_reader :start_time + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @start_time = args['startTime'] + end + + def to_s + "#{@parent_identifier} NodeGroupMaintenanceWindow" + end + end + end + end +end diff --git a/libraries/google_compute_node_group.rb b/libraries/google_compute_node_group.rb index a9f9cf5cc..65d9bcdde 100644 --- a/libraries/google_compute_node_group.rb +++ b/libraries/google_compute_node_group.rb @@ -15,6 +15,7 @@ # ---------------------------------------------------------------------------- require 'gcp_backend' require 'google/compute/property/nodegroup_autoscaling_policy' +require 'google/compute/property/nodegroup_maintenance_window' # A provider to manage Compute Engine resources. class ComputeNodeGroup < GcpResourceBase @@ -29,6 +30,7 @@ class ComputeNodeGroup < GcpResourceBase attr_reader :node_template attr_reader :size attr_reader :maintenance_policy + attr_reader :maintenance_window attr_reader :autoscaling_policy attr_reader :zone @@ -46,6 +48,7 @@ def parse @node_template = @fetched['nodeTemplate'] @size = @fetched['size'] @maintenance_policy = @fetched['maintenancePolicy'] + @maintenance_window = GoogleInSpec::Compute::Property::NodeGroupMaintenanceWindow.new(@fetched['maintenanceWindow'], to_s) @autoscaling_policy = GoogleInSpec::Compute::Property::NodeGroupAutoscalingPolicy.new(@fetched['autoscalingPolicy'], to_s) @zone = @fetched['zone'] end diff --git a/libraries/google_compute_node_groups.rb b/libraries/google_compute_node_groups.rb index 682505e59..ff2739c56 100644 --- a/libraries/google_compute_node_groups.rb +++ b/libraries/google_compute_node_groups.rb @@ -29,6 +29,7 @@ class ComputeNodeGroups < GcpResourceBase filter_table_config.add(:node_templates, field: :node_template) filter_table_config.add(:sizes, field: :size) filter_table_config.add(:maintenance_policies, field: :maintenance_policy) + filter_table_config.add(:maintenance_windows, field: :maintenance_window) filter_table_config.add(:autoscaling_policies, field: :autoscaling_policy) filter_table_config.add(:zones, field: :zone) @@ -76,6 +77,7 @@ def transformers 'nodeTemplate' => ->(obj) { return :node_template, obj['nodeTemplate'] }, 'size' => ->(obj) { return :size, obj['size'] }, 'maintenancePolicy' => ->(obj) { return :maintenance_policy, obj['maintenancePolicy'] }, + 'maintenanceWindow' => ->(obj) { return :maintenance_window, GoogleInSpec::Compute::Property::NodeGroupMaintenanceWindow.new(obj['maintenanceWindow'], to_s) }, 'autoscalingPolicy' => ->(obj) { return :autoscaling_policy, GoogleInSpec::Compute::Property::NodeGroupAutoscalingPolicy.new(obj['autoscalingPolicy'], to_s) }, 'zone' => ->(obj) { return :zone, obj['zone'] }, }