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.



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

def initialize(cluster_name)
  @cluster_name = cluster_name
end

Instance Method Details

#configObject



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

def config; Config[@cluster_name]; end

#createObject



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

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



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

def delete
  delete_vpc_peering
  delete_services
  delete_nodegroups
  delete_cf_stack
end

#update_kubeconfigObject



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

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