Skip to content

Instantly share code, notes, and snippets.

@neshmi
Created March 24, 2018 15:04
Show Gist options
  • Save neshmi/7c905903cc32e2742c81e11cd713ac15 to your computer and use it in GitHub Desktop.
Save neshmi/7c905903cc32e2742c81e11cd713ac15 to your computer and use it in GitHub Desktop.
Force kubectl to refresh auth
#!/usr/bin/env ruby
require 'yaml'
kube_config = File.join(ENV["HOME"],".kube","config")
yaml = YAML.load(File.open(kube_config))
current_context = yaml["current-context"]
index = yaml["users"].find_index{|user| user["name"] == current_context}
yaml["users"][index]["user"]["auth-provider"]["config"]["expiry"] = Time.now.utc - 500
File.open(kube_config, 'w') { |f| YAML.dump(yaml, f) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment