eks_cli 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db3e72f358690e91b457a14a2965971c5c7f8096
4
- data.tar.gz: a1188295b0461d98b40a370985c8801b206fdf79
3
+ metadata.gz: 8018b870965acb14650d78b33c8d7ff7ac3fd146
4
+ data.tar.gz: b4253ff9454d66f1ef2fa65fba9ccc5dead775ba
5
5
  SHA512:
6
- metadata.gz: adadae25deffad969e6e357f76372a41e1646f337308483fb10fbb7dcf700084341cf4d77f391dceebeed43f433eed9669e3495764adc16a3e50f5a8a2810e8a
7
- data.tar.gz: 77e388b3a33309427255d85b9663e72144f3f8aeeab91a53b0e521acaa0a9dfde016494ccad7becbc1fb1996355f172793dacb91b05678e93b157d79f60d3379
6
+ metadata.gz: 00673c6ad254fb33cd2573f5558123c58682ad601cd431a7b7a244cbd98ce94c1a13574cf8f6bf17e9faff94d90c48a74c75f74f4a203eb3d223083f058b7755
7
+ data.tar.gz: ddec8dbd285e41a34cf2cef2a5f7fbc36ebefdd2ffac327e5eb2d309ae3f74a69ab33dce3c14a306ea4b0c244aa6a60f1965c8497e3f21761037c9a8ad58f512
data/README.md CHANGED
@@ -11,23 +11,25 @@ EKS cluster bootstrap with batteries included
11
11
  * Easily configure docker repository secrets to allow pulling private images
12
12
  * Manage Route53 DNS records to point at your Kubernetes services
13
13
  * Export nodegroups to SporInst Elastigroups
14
+ * Auto resolving AMIs by region & instance types (GPU enabled AMIs)
14
15
  * Even more...
15
16
 
16
17
  ## Usage
17
18
 
18
19
  ```
19
- $ gem install eks_cli -v 0.1.7
20
+ $ gem install eks_cli -v 0.1.8
20
21
  $ eks create us-west-2 --cluster-name My-EKS-Cluster
21
- $ eks create-nodegroup --cluster-name My-EKS-Cluster --group-name nodes --ssh-key-name my-ssh-key --yes
22
+ $ eks create-nodegroup --cluster-name My-EKS-Cluster --group-name nodes --ssh-key-name <my-ssh-key> --yes
22
23
  ```
23
24
 
24
25
  You can type `eks` in your shell to get the full synopsis of available commands
25
26
 
26
- ## Prerequisite
27
+ ## Prerequisites
27
28
 
28
29
  1. Ruby
29
- 2. `kubectl` with version > 10 on your `PATH`
30
- 3. `aws-iam-authenticator` on your `PATH`
30
+ 2. [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) version >= 10 on your `PATH`
31
+ 3. [aws-iam-authenticator](https://github.com/kubernetes-sigs/aws-iam-authenticator) on your `PATH`
32
+ 4. [aws-cli](https://docs.aws.amazon.com/cli/latest/userguide/installing.html) version >= 1.16.18 on your `PATH`
31
33
 
32
34
  ## Extra Stuff
33
35
 
@@ -94,7 +96,7 @@ Assuming you have some shared resources on another VPC (an RDS instance for exam
94
96
 
95
97
  1. Creating and accepting a VPC peering connection from your EKS cluster VPC to the old VPC
96
98
  2. Setting route tables on both directions to allow communication
97
- 3. Adding an ingress role to SG_ID to accept all communication from your new cluster nodes.
99
+ 3. Adding an ingress rule to SG_ID to accept all communication from your new cluster nodes.
98
100
 
99
101
  ### Exporting nodegroups to Spotinst
100
102
 
@@ -45,7 +45,11 @@ module EksCli
45
45
  end
46
46
 
47
47
  def eks_worker?
48
- !worker_tag.empty?
48
+ worker_tag
49
+ end
50
+
51
+ def eks_cluster
52
+ get_tag("eks-cluster")
49
53
  end
50
54
 
51
55
  def node_instance_role_arn
@@ -103,12 +107,13 @@ module EksCli
103
107
  client.describe_stacks(stack_name: @id).stacks.first
104
108
  end
105
109
 
106
- def worker_tag
107
- stack.tags.select {|t| worker_tag?(t)}
110
+ def get_tag(k)
111
+ tag = stack.tags.select {|t| t.key == k}.first
112
+ tag.value if tag
108
113
  end
109
114
 
110
- def worker_tag?(tag)
111
- tag.key == "eks-nodegroup"
115
+ def worker_tag
116
+ get_tag("eks-nodegroup")
112
117
  end
113
118
 
114
119
  end
@@ -111,7 +111,6 @@ module EksCli
111
111
 
112
112
  def group_defaults
113
113
  {"group_name" => "Workers",
114
- "ami" => "ami-0a54c984b9f908c81",
115
114
  "instance_type" => "m5.xlarge",
116
115
  "max" => 1,
117
116
  "min" => 1,
@@ -4,6 +4,7 @@ require 'config'
4
4
  require 'cloudformation/client'
5
5
  require 'cloudformation/stack'
6
6
  require 'log'
7
+ require 'nodegroup'
7
8
 
8
9
  module EksCli
9
10
  module K8s
@@ -36,17 +37,20 @@ module EksCli
36
37
  end
37
38
 
38
39
  def node_arns
39
- client
40
- .list_stacks(stack_status_filter: ["CREATE_COMPLETE"])
41
- .stack_summaries
42
- .map(&:stack_id)
43
- .map {|id| CloudFormation::Stack.new(@cluster_name, id)}
40
+ config["groups"]
41
+ .keys
42
+ .map {|name| NodeGroup.new(@cluster_name, name).cf_stack}
44
43
  .select {|stack| stack.eks_worker?}
44
+ .select {|stack| stack.eks_cluster == @cluster_name}
45
45
  .map {|stack| stack.node_instance_role_arn}
46
46
  end
47
47
 
48
48
  def users
49
- Config[@cluster_name]["users"]
49
+ config["users"]
50
+ end
51
+
52
+ def config
53
+ Config[@cluster_name]
50
54
  end
51
55
 
52
56
  def configmap
@@ -23,6 +23,16 @@ module EksCli
23
23
  group_name: "NodeGroupName",
24
24
  bootstrap_args: "BootstrapArguments"}
25
25
 
26
+ AMIS = {"us-west-2" => "ami-0a54c984b9f908c81",
27
+ "us-east-1" => "ami-0440e4f6b9713faf6",
28
+ "us-east-2" => "ami-0958a76db2d150238",
29
+ "us-west-1" => "ami-00c3b2d35bddd4f5c"}
30
+
31
+ GPU_AMIS = {"us-west-2" => "ami-08156e8fd65879a13",
32
+ "us-east-1" => "ami-0c974dde3f6d691a1",
33
+ "us-east-2" => "ami-089849e811ace242f",
34
+ "us-west-1" => "ami-0c3479bcd739094f0"}
35
+
26
36
  CAPABILITIES = ["CAPABILITY_IAM"]
27
37
 
28
38
  def initialize(cluster_name, name)
@@ -65,7 +75,14 @@ module EksCli
65
75
 
66
76
  def export_to_spotinst
67
77
  Log.info "exporting nodegroup #{@name} to spotinst"
68
- Log.info Spotinst::Client.new.import_asg(Config[@cluster_name]["region"], asg, [instance_type])
78
+ Log.info Spotinst::Client.new.import_asg(config["region"], asg, [instance_type])
79
+ end
80
+
81
+ def cf_stack
82
+ CloudFormation::Stack.find(@cluster_name, stack_name)
83
+ rescue Aws::CloudFormation::Errors::ValidationError => e
84
+ Log.error("could not find stack for nodegroup #{@name} - please make sure to run eks create-nodegroup --all --yes -c <cluster_name> to sync config")
85
+ raise e
69
86
  end
70
87
 
71
88
  private
@@ -74,10 +91,6 @@ module EksCli
74
91
  @cf_template_body ||= File.read(File.join($root_dir, '/assets/nodegroup_cf_template.yaml'))
75
92
  end
76
93
 
77
- def cf_stack
78
- CloudFormation::Stack.find(@cluster_name, stack_name)
79
- end
80
-
81
94
  def await(stack)
82
95
 
83
96
  while stack.pending? do
@@ -105,6 +118,7 @@ module EksCli
105
118
 
106
119
  def build_params
107
120
  @group["bootstrap_args"] = bootstrap_args
121
+ @group["ami"] ||= default_ami
108
122
  @group.except("taints").inject([]) do |params, (k, v)|
109
123
  params << build_param(k, v)
110
124
  end
@@ -128,6 +142,22 @@ module EksCli
128
142
  parameter_value: v.to_s}
129
143
  end
130
144
 
145
+ def default_ami
146
+ if gpu?
147
+ GPU_AMIS[config["region"]]
148
+ else
149
+ AMIS[config["region"]]
150
+ end
151
+ end
152
+
153
+ def gpu?
154
+ @group["instance_type"].start_with?("p2.") || @group["instance_type"].start_with?("p3.")
155
+ end
156
+
157
+ def config
158
+ Config[@cluster_name]
159
+ end
160
+
131
161
  end
132
162
 
133
163
  end
@@ -1,3 +1,3 @@
1
1
  module EksCli
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eks_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erez Rabih