Class: EksCli::Cli
- Inherits:
-
Thor
- Object
- Thor
- EksCli::Cli
- Defined in:
- lib/eks_cli/cli.rb
Instance Method Summary collapse
- #add_iam_user(iam_arn) ⇒ Object
- #create ⇒ Object
- #create_default_storage_class ⇒ Object
- #create_dns_autoscaler ⇒ Object
- #create_nodegroup ⇒ Object
- #delete_cluster ⇒ Object
- #delete_nodegroup ⇒ Object
- #enable_gpu ⇒ Object
- #export_nodegroup ⇒ Object
- #scale_nodegroup ⇒ Object
- #set_docker_registry_credentials(username, password, email) ⇒ Object
- #set_iam_policies ⇒ Object
- #set_inter_vpc_networking(to_vpc_id, to_sg_id) ⇒ Object
- #show_config ⇒ Object
- #update_auth ⇒ Object
- #update_cluster_cni ⇒ Object
- #update_dns(hostname, k8s_service_name) ⇒ Object
- #version ⇒ Object
- #wait_for_cluster ⇒ Object
Instance Method Details
#add_iam_user(iam_arn) ⇒ Object
205 206 207 208 209 210 |
# File 'lib/eks_cli/cli.rb', line 205 def add_iam_user(iam_arn) with_context do Config[cluster_name].add_user(iam_arn, [:username], [:groups]) K8s::Auth.new(cluster_name).update if [:yes] end end |
#create ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/eks_cli/cli.rb', line 45 def create with_context do opts = {region: [:region], kubernetes_version: [:kubernetes_version], open_ports: [:open_ports], cidr: [:cidr], warm_ip_target: [:warm_ip_target] ? [:warm_ip_target].to_i : nil, subnet1_az: ([:subnet1_az] || Config::AZS[[:region]][0]), subnet2_az: ([:subnet2_az] || Config::AZS[[:region]][1]), subnet3_az: ([:subnet3_az] || Config::AZS[[:region]][2])} config.bootstrap(opts) cluster = EKS::Cluster.new(cluster_name).create cluster.update_kubeconfig wait_for_cluster enable_gpu if [:enable_gpu] create_default_storage_class if [:create_default_storage_class] create_dns_autoscaler if [:create_dns_autoscaler] update_cluster_cni if [:warm_ip_target] Log.info "cluster creation completed" end end |
#create_default_storage_class ⇒ Object
97 98 99 |
# File 'lib/eks_cli/cli.rb', line 97 def create_default_storage_class with_context { K8s::Client.new(cluster_name).create_default_storage_class } end |
#create_dns_autoscaler ⇒ Object
184 185 186 |
# File 'lib/eks_cli/cli.rb', line 184 def create_dns_autoscaler with_context { K8s::Client.new(cluster_name).create_dns_autoscaler } end |
#create_nodegroup ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/eks_cli/cli.rb', line 115 def create_nodegroup with_context do opts = .dup opts[:subnets] = opts[:subnets].map(&:to_i) Config[cluster_name].update_nodegroup(opts) unless opts[:all] if opts[:yes] cf_stacks = nodegroups.map {|ng| ng.create(wait_for_completion: false)} CloudFormation::Stack.await(cf_stacks) K8s::Auth.new(cluster_name).update end end end |
#delete_cluster ⇒ Object
148 149 150 |
# File 'lib/eks_cli/cli.rb', line 148 def delete_cluster with_context { EKS::Cluster.new(cluster_name).delete } end |
#delete_nodegroup ⇒ Object
155 156 157 |
# File 'lib/eks_cli/cli.rb', line 155 def delete_nodegroup with_context { nodegroups.each(&:delete) } end |
#enable_gpu ⇒ Object
87 88 89 |
# File 'lib/eks_cli/cli.rb', line 87 def enable_gpu with_context { K8s::Client.new(cluster_name).enable_gpu } end |
#export_nodegroup ⇒ Object
197 198 199 |
# File 'lib/eks_cli/cli.rb', line 197 def export_nodegroup with_context { nodegroups.each {|ng| ng.export_to_spotinst([:exact_instance_type]) } } end |
#scale_nodegroup ⇒ Object
136 137 138 139 140 141 142 143 144 145 |
# File 'lib/eks_cli/cli.rb', line 136 def scale_nodegroup with_context do nodegroups.each do |ng| min = ([:min] || config.for_group(ng.name)["min"]).to_i max = ([:max] || config.for_group(ng.name)["max"]).to_i ng.scale(min, max, [:asg], [:spotinst]) Config[cluster_name].update_nodegroup(.slice("min", "max").merge({"group_name" => ng.name})) if [:update] end end end |
#set_docker_registry_credentials(username, password, email) ⇒ Object
92 93 94 |
# File 'lib/eks_cli/cli.rb', line 92 def set_docker_registry_credentials(username, password, email) with_context { K8s::Client.new(cluster_name).set_docker_registry_credentials(username, password, email) } end |
#set_iam_policies ⇒ Object
166 167 168 |
# File 'lib/eks_cli/cli.rb', line 166 def set_iam_policies with_context { Config[cluster_name].set_iam_policies([:policies]) } end |
#set_inter_vpc_networking(to_vpc_id, to_sg_id) ⇒ Object
179 180 181 |
# File 'lib/eks_cli/cli.rb', line 179 def set_inter_vpc_networking(to_vpc_id, to_sg_id) with_context { VPC::Client.new(cluster_name).set_inter_vpc_networking(to_vpc_id, to_sg_id) } end |
#show_config ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/eks_cli/cli.rb', line 71 def show_config with_context do if [:group_name] puts JSON.pretty_generate(config.for_group([:group_name])) else puts JSON.pretty_generate(config.read_from_disk) end end end |
#update_auth ⇒ Object
160 161 162 |
# File 'lib/eks_cli/cli.rb', line 160 def update_auth with_context { K8s::Auth.new(cluster_name).update } end |
#update_cluster_cni ⇒ Object
82 83 84 |
# File 'lib/eks_cli/cli.rb', line 82 def update_cluster_cni with_context { K8s::Client.new(cluster_name).update_cni } end |
#update_dns(hostname, k8s_service_name) ⇒ Object
174 175 176 |
# File 'lib/eks_cli/cli.rb', line 174 def update_dns(hostname, k8s_service_name) with_context { Route53::Client.new(cluster_name).update_dns(hostname, k8s_service_name, [:namespace], [:route53_hosted_zone_id], [:elb_hosted_zone_id]) } end |
#version ⇒ Object
214 215 216 |
# File 'lib/eks_cli/cli.rb', line 214 def version puts EksCli::VERSION end |
#wait_for_cluster ⇒ Object
189 190 191 |
# File 'lib/eks_cli/cli.rb', line 189 def wait_for_cluster with_context { K8s::Client.new(cluster_name).wait_for_cluster } end |