eks_cli 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0483a00712a2dbd992ff9205d935edca0c03323f
4
- data.tar.gz: da1d19ee9dbd657f075e590da5ce5b338f347c59
3
+ metadata.gz: 775c8a4ece3a3041f4920b0fffd577e4ba5d2353
4
+ data.tar.gz: 93c3beda1c78f4476c03858673213beed220165e
5
5
  SHA512:
6
- metadata.gz: b15dc928f81caffd9ae3fcc0892952209b4a1f46c099874de3319c9c717822595e7a26b276c5b11fabbf466dbb1d0bd7c73a4f39dab8ecf7845e347cfc7162b9
7
- data.tar.gz: 2a7d2b3fd2ba7f1bf2f92e31d177222a503ef5f513bc26cc7b9fdac95949aaa5b925a9f94ad7fe465a0489e28bfb1e9823914365027930bc75ff066f07b49f24
6
+ metadata.gz: 7ee50a9740e720ef52734a7693cb4af7f30f827a8feccabf8229255a4a372c3fd9c7cf08b149330d66de5a8317ce74f3378a9afe5013319227ad8e16bc4b2fe9
7
+ data.tar.gz: 0b1918531fb93186c44eb87d51d654f430f02d0779b080cad4b3d20c5e52557f304e5982ed5b665876c2e3dc6ba724efcda08f3a8a82f3208880f70fc9cf3d09
data/README.md CHANGED
@@ -17,13 +17,43 @@ EKS cluster bootstrap with batteries included
17
17
  ## Usage
18
18
 
19
19
  ```
20
- $ gem install eks_cli -v 0.2.2
20
+ $ gem install eks_cli -v 0.2.3
21
21
  $ eks create --cluster-name My-EKS-Cluster
22
22
  $ eks create-nodegroup --cluster-name My-EKS-Cluster --group-name nodes --ssh-key-name <my-ssh-key> --yes
23
23
  ```
24
24
 
25
25
  You can type `eks` in your shell to get the full synopsis of available commands
26
26
 
27
+ ```bash
28
+ Commands:
29
+ eks add-iam-user IAM_ARN # adds an IAM user as an authorized member on the EKS cluster
30
+ eks create # creates a new EKS cluster
31
+ eks create-cluster-security-group # creates a SG for cluster communication
32
+ eks create-cluster-vpc # creates a vpc according to aws cloudformation template
33
+ eks create-default-storage-class # creates default storage class on a new k8s cluster
34
+ eks create-dns-autoscaler # creates kube dns autoscaler
35
+ eks create-eks-cluster # create EKS cluster on AWS
36
+ eks create-eks-role # creates an IAM role for usage by EKS
37
+ eks create-nodegroup # creates all nodegroups on environment
38
+ eks delete-nodegroup # deletes cloudformation stack for nodegroup
39
+ eks detach-iam-policies # detaches added policies to nodegroup IAM Role
40
+ eks enable-gpu # installs nvidia plugin as a daemonset on the cluster
41
+ eks export-nodegroup # exports nodegroup auto scaling group to spotinst
42
+ eks help [COMMAND] # Describe available commands or one specific command
43
+ eks scale-nodegroup --group-name=GROUP_NAME --max=N --min=N # scales a nodegroup
44
+ eks set-docker-registry-credentials USERNAME PASSWORD EMAIL # sets docker registry credentials
45
+ eks set-iam-policies --policies=one two three # sets IAM policies to be attached to created nodegroups
46
+ eks set-inter-vpc-networking TO_VPC_ID TO_SG_ID # creates a vpc peering connection, sets route tables and allows network access on SG
47
+ eks show-config # print cluster configuration
48
+ eks update-auth # update aws auth configmap to allow all nodegroups to connect to control plane
49
+ eks update-dns HOSTNAME K8S_SERVICE_NAME # alters route53 CNAME records to point to k8s service ELBs
50
+ eks version # prints eks_cli version
51
+ eks wait-for-cluster # waits until cluster responds to HTTP requests
52
+
53
+ Options:
54
+ c, --cluster-name=CLUSTER_NAME
55
+ ```
56
+
27
57
  ## Prerequisites
28
58
 
29
59
  1. Ruby
@@ -31,7 +61,7 @@ You can type `eks` in your shell to get the full synopsis of available commands
31
61
  3. [aws-iam-authenticator](https://github.com/kubernetes-sigs/aws-iam-authenticator) on your `PATH`
32
62
  4. [aws-cli](https://docs.aws.amazon.com/cli/latest/userguide/installing.html) version >= 1.16.18 on your `PATH`
33
63
 
34
- ## Extra Stuff
64
+ ## Selected Commands
35
65
 
36
66
  ### Creating more than a single nodegroup
37
67
 
@@ -40,6 +70,12 @@ Nodegroups are created separately from the cluster.
40
70
  You can use `eks create-nodegroup` multiple times to create several nodegroups with different instance types and number of workers.
41
71
  Nodes in different nodegroups may communicate freely thanks to a shared Security Group.
42
72
 
73
+ ## Scaling nodegroups
74
+
75
+ Scale nodegroups up and down using
76
+
77
+ `$ eks scale-nodegroup --cluster-name My-EKS-Cluster --group-name nodes --min 1 --max 10`
78
+
43
79
  ### Authorize an IAM user to access the cluster
44
80
 
45
81
  `$ eks add-iam-user arn:aws:iam::XXXXXXXX:user/XXXXXXXX --cluster-name=My-EKS-Cluster --yes`
data/eks_cli.gemspec CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
26
26
  s.add_dependency 'aws-sdk-ec2', '1.62.0'
27
27
  s.add_dependency 'aws-sdk-cloudformation', '1.13.0'
28
28
  s.add_dependency 'aws-sdk-route53', '1.16.0'
29
+ s.add_dependency 'aws-sdk-autoscaling','1.13.0'
29
30
  s.add_dependency 'activesupport', '5.2.1.1'
30
31
  s.add_dependency 'kubeclient', '4.1.0'
31
32
  s.add_dependency 'httparty', '0.16.3'
data/lib/eks_cli/cli.rb CHANGED
@@ -123,6 +123,14 @@ module EksCli
123
123
  end
124
124
  end
125
125
 
126
+ desc "scale-nodegroup", "scales a nodegroup"
127
+ option :group_name, type: :string, required: true, desc: "nodegroup name to scale"
128
+ option :min, required: true, type: :numeric, desc: "Minimum number of nodes on the nodegroup"
129
+ option :max, required: true, type: :numeric, desc: "Maximum number of nodes on the nodegroup"
130
+ def scale_nodegroup
131
+ NodeGroup.new(cluster_name, options[:group_name]).scale(options[:min].to_i, options[:max].to_i)
132
+ end
133
+
126
134
  desc "delete-nodegroup", "deletes cloudformation stack for nodegroup"
127
135
  option :all, type: :boolean, default: false, desc: "delete all nodegroups. can't be used with --name"
128
136
  option :name, type: :string, desc: "delete a specific nodegroup. can't be used with --all"
@@ -1,4 +1,5 @@
1
1
  require 'active_support/core_ext/hash'
2
+ require 'aws-sdk-autoscaling'
2
3
  require 'config'
3
4
  require 'spotinst/client'
4
5
  require 'cloudformation/stack'
@@ -66,7 +67,7 @@ module EksCli
66
67
  end
67
68
 
68
69
  def asg
69
- cf_stack.resource("NodeGroup")
70
+ @asg ||= cf_stack.resource("NodeGroup")
70
71
  end
71
72
 
72
73
  def instance_type
@@ -85,6 +86,15 @@ module EksCli
85
86
  raise e
86
87
  end
87
88
 
89
+ def scale(min, max)
90
+ Log.info "scaling #{asg}: min -> #{min}, max -> #{max}"
91
+ Log.info asg_client.update_auto_scaling_group({
92
+ auto_scaling_group_name: asg,
93
+ max_size: max,
94
+ min_size: min
95
+ })
96
+ end
97
+
88
98
  private
89
99
 
90
100
  def cf_template_body
@@ -158,6 +168,10 @@ module EksCli
158
168
  Config[@cluster_name]
159
169
  end
160
170
 
171
+ def asg_client
172
+ @asg_client ||= Aws::AutoScaling::Client.new(region: config["region"])
173
+ end
174
+
161
175
  end
162
176
 
163
177
  end
@@ -1,3 +1,3 @@
1
1
  module EksCli
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
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.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erez Rabih
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.16.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: aws-sdk-autoscaling
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 1.13.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 1.13.0
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: activesupport
99
113
  requirement: !ruby/object:Gem::Requirement