class EksCli::K8s::Auth

Public Class Methods

new(cluster_name) click to toggle source
# File lib/eks_cli/k8s/auth.rb, line 13
def initialize(cluster_name)
  @cluster_name = cluster_name
end

Public Instance Methods

update() click to toggle source
# File lib/eks_cli/k8s/auth.rb, line 17
def update
  Log.info "updating auth configmap on kubernetes"
  begin
    k8s_client.get_config_map("aws-auth", "kube-system")
    k8s_client.update_config_map(configmap)
  rescue KubeException => e
    Log.debug "exception updating configmap: #{e}"
    k8s_client.create_config_map(configmap)
  end
  Log.info "done"
end

Private Instance Methods

client() click to toggle source
# File lib/eks_cli/k8s/auth.rb, line 35
def client
  CloudFormation::Client.get(@cluster_name)
end
config() click to toggle source
# File lib/eks_cli/k8s/auth.rb, line 52
def config
  Config[@cluster_name]
end
configmap() click to toggle source
# File lib/eks_cli/k8s/auth.rb, line 56
def configmap
  ConfigmapBuilder.build(node_arns, users)
end
k8s_client() click to toggle source
# File lib/eks_cli/k8s/auth.rb, line 31
def k8s_client
  @k8s_client ||= K8s::Client.new(@cluster_name)
end
node_arns() click to toggle source
# File lib/eks_cli/k8s/auth.rb, line 39
def node_arns
  config["groups"]
    .keys
    .map {|name| NodeGroup.new(@cluster_name, name).cf_stack}
    .select {|stack| stack.eks_worker?}
    .select {|stack| stack.eks_cluster == @cluster_name}
    .map {|stack| stack.node_instance_role_arn}
end
users() click to toggle source
# File lib/eks_cli/k8s/auth.rb, line 48
def users
  config["users"]
end