Fix namespace support in kubectl aging plugin

The example plugin's comments mentioned the namespace support
limitation, awaiting kubectl to implement environment variable
propagation. Now that 1.8 is out, the requirement is satisfied.

This commit adds use of the conveyed namespace information to the
plugin example.

Fixes #55255
This commit is contained in:
Jonas Tingeborn 2017-11-07 19:07:58 +01:00
parent 45bdf707f0
commit f130ed9837
2 changed files with 2 additions and 4 deletions

View File

@ -22,7 +22,8 @@ class Numeric
end
end
pods_json = `kubectl get pods -o json`
namespace = ENV['KUBECTL_PLUGINS_CURRENT_NAMESPACE'] || 'default'
pods_json = `kubectl --namespace #{namespace} get pods -o json`
pods_parsed = JSON.parse(pods_json)
puts "The Magnificent Aging Plugin."

View File

@ -2,7 +2,4 @@ name: "aging"
shortDesc: "Aging shows pods by age"
longDesc: >
Aging shows pods from the current namespace by age.
Once we have plugin support for global flags through
env vars (planned for V1) we'll be able to switch
between namespaces using the --namespace flag.
command: ./aging.rb