Class: EksCli::NodeGroup
- Inherits:
-
Object
- Object
- EksCli::NodeGroup
- Defined in:
- lib/eks_cli/nodegroup.rb
Constant Summary collapse
- T =
{cluster_name: "ClusterName", control_plane_sg_id: "ClusterControlPlaneSecurityGroup", nodes_sg_id: "ClusterSecurityGroup", min: "NodeAutoScalingGroupMinSize", max: "NodeAutoScalingGroupMaxSize", instance_type: "NodeInstanceType", ami: "NodeImageId", volume_size: "NodeVolumeSize", ssh_key_name: "KeyName", vpc_id: "VpcId", subnets: "Subnets", group_name: "NodeGroupName", bootstrap_args: "BootstrapArguments"}
- CAPABILITIES =
["CAPABILITY_IAM"]
Instance Method Summary collapse
- #asg ⇒ Object
- #create(wait_for_completion: true) ⇒ Object
- #delete ⇒ Object
- #detach_iam_policies ⇒ Object
- #export_to_spotinst ⇒ Object
-
#initialize(cluster_name, name) ⇒ NodeGroup
constructor
A new instance of NodeGroup.
- #instance_type ⇒ Object
- #tags ⇒ Object
Constructor Details
Instance Method Details
#asg ⇒ Object
58 59 60 |
# File 'lib/eks_cli/nodegroup.rb', line 58 def asg cf_stack.resource("NodeGroup") end |
#create(wait_for_completion: true) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/eks_cli/nodegroup.rb', line 34 def create(wait_for_completion: true) Log.info "creating stack for nodegroup #{@group["group_name"]}" stack = CloudFormation::Stack.create(@cluster_name, cloudformation_config) Log.info "stack created - #{@group["group_name"]} - #{stack.id}" if wait_for_completion await(stack) end stack end |
#delete ⇒ Object
53 54 55 56 |
# File 'lib/eks_cli/nodegroup.rb', line 53 def delete detach_iam_policies cf_stack.delete end |
#detach_iam_policies ⇒ Object
49 50 51 |
# File 'lib/eks_cli/nodegroup.rb', line 49 def detach_iam_policies IAM::Client.new(@cluster_name).detach_node_policies(cf_stack.node_instance_role_name) end |
#export_to_spotinst ⇒ Object
66 67 68 69 |
# File 'lib/eks_cli/nodegroup.rb', line 66 def export_to_spotinst Log.info "exporting nodegroup #{@name} to spotinst" Log.info Spotinst::Client.new.import_asg(Config[@cluster_name]["region"], asg, [instance_type]) end |
#instance_type ⇒ Object
62 63 64 |
# File 'lib/eks_cli/nodegroup.rb', line 62 def instance_type @group["instance_type"] end |
#tags ⇒ Object
44 45 46 47 |
# File 'lib/eks_cli/nodegroup.rb', line 44 def [{key: "eks-nodegroup", value: @group["group_name"]}, {key: "eks-cluster", value: @cluster_name}] end |