Merge pull request #55258 from jojje/kubectl-aging-example-namespace-support

Automatic merge from submit-queue (batch tested with PRs 54460, 55258, 54858, 55506, 55510). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

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



**What this PR does / why we need it**:

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note

```
This commit is contained in:
Kubernetes Submit Queue 2017-11-11 10:45:19 -08:00 committed by GitHub
commit e43aae79e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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