Last active
March 9, 2016 08:28
-
-
Save itsprdp/2721a569a21762cc7b6f to your computer and use it in GitHub Desktop.
kubectl shortcuts for zsh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kgp () { | |
kubectl get pods $argv | |
} | |
kdp () { | |
kubectl describe pods $argv | |
} | |
kdr () { | |
kubectl describe rc $argv | |
} | |
kds () { | |
kubectl describe services $argv | |
} | |
kdsec() { | |
kubectl describe secrets $argv | |
} | |
kgs () { | |
kubectl get services $argv | |
} | |
kgr () { | |
kubectl get rc $argv | |
} | |
gcil () { | |
gcloud compute instances list $argv | |
} | |
gccl () { | |
gcloud container clusters list $argv | |
} | |
gdp () { | |
gcloud docker push $argv | |
} | |
kgsec () { | |
kubectl get secrets $argv | |
} | |
kdesc () { | |
kubectl describe $argv | |
} | |
k () { | |
kubectl $argv | |
} | |
# usage: kbash <pod-name> <container-name> | |
kbash() { | |
POD_NAME=$(kubectl get pods | grep $1 | awk '{ print $1 }') | |
CONT_NAME=$(kubectl get rc | grep $2 | awk '{ print $2 }') | |
kubectl exec -it $POD_NAME -c $CONT_NAME /bin/bash | |
} | |
# Convert .env files to kuber secrets | |
#envtokuber() { | |
# ruby ~/setup/kuberenv.rb $argv | |
#} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Encode .env file values to base64 and create json key values | |
require 'base64' | |
require 'yaml' | |
if ARGV[0] | |
env = {} | |
file = File.new(ARGV[0], "r") | |
exit unless file | |
data = file.read | |
env_vars = data.split("\n") | |
env_vars.each do |env_var| | |
next unless env_var.include?('export') | |
export_key, ival = env_var.split("=") if env_var | |
key = export_key.split("export ").last.gsub("_", "-").downcase if export_key | |
val = (ival)? Base64.strict_encode64(ival) : nil | |
env[key] = %Q("#{val}") | |
end | |
env.each {|k,v| puts "#{k}: #{v}" } | |
else | |
puts "Please pass the .env file path.\n Eg: ruby kuberenv.rb config/.env.staging\n" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment