Class: EksCli::EKS::Cluster

Inherits:
Object
  • Object
show all
Defined in:
lib/eks_cli/eks/cluster.rb

Instance Method Summary collapse

Constructor Details

#initialize(cluster_name) ⇒ Cluster

Returns a new instance of Cluster.



12
13
14
# File 'lib/eks_cli/eks/cluster.rb', line 12

def initialize(cluster_name)
  @cluster_name = cluster_name
end

Instance Method Details

#configObject



31
# File 'lib/eks_cli/eks/cluster.rb', line 31

def config; Config[@cluster_name]; end

#createObject



16
17
18
19
20
21
# File 'lib/eks_cli/eks/cluster.rb', line 16

def create
  Log.info "creating cluster #{@cluster_name}"
  cf_stack_outputs = CloudFormation::EKS.new(@cluster_name).create
  config.write(cf_stack_outputs)
  self
end

#deleteObject



23
24
25
26
27
28
29
# File 'lib/eks_cli/eks/cluster.rb', line 23

def delete
  delete_vpc_peering
  delete_services
  delete_nodegroups
  delete_cf_stack
  delete_config
end

#servicesObject



38
39
40
# File 'lib/eks_cli/eks/cluster.rb', line 38

def services
  k8s_client.get_services(namespace: "default").select {|s| s[:spec][:type] == "LoadBalancer"}
end

#update_kubeconfigObject



33
34
35
36
# File 'lib/eks_cli/eks/cluster.rb', line 33

def update_kubeconfig
  Log.info "updating kubeconfig for cluster #{@cluster_name}"
  Log.info `aws eks update-kubeconfig --name=#{@cluster_name} --region=#{config["region"]}`
end