Automatic merge from submit-queue. 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>.
Fixes kubectl Pod Disruption Budget and adds tests
**What this PR does / why we need it**:
This PR fixes several kubectl Pod Disruption Budget issues:
* The `min-available` parameter in Pod Disruption Budget V1 is not required (otherwise it will never use the default value)
* Removes the deprecated `min-available` default in Pod Disruption Budget V2
* The `selector` parameter in Pod Disruption Budget V2 is required
* Fixes (typo) the `max-unavailable` parameter check in Pod Disruption Budget V2
* Fixes some assertion error messages where the value printed was always the zero value of the parameter type instead of the parameter provided
* Updated kubectl Pod Disruption Budget to use policy V1Beta1 instead of unversioned API (see https://github.com/kubernetes/kubectl/issues/90)
* Add missing tests
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes https://github.com/kubernetes/kubectl/issues/101
**Special notes for your reviewer**:
Spllited in several commits to make the review process easier. Please let me know if you prefer to squash some commits or if you prefer to split them in different PRs.
**Release note**:
```release-note
NONE
```
/cc @kubernetes/sig-cli-pr-reviews
Automatic merge from submit-queue. 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>.
Using --show-labels with incompatible ‘kubectl get’ arguments should …
…error out
**What this PR does / why we need it**:
According to @ahmetb 's [issue](https://github.com/kubernetes/kubernetes/issues/55290)
Under specific circumstances, current behavior is that the `--show-labels` simply doesn’t make a difference since it’s not applicable.
**Which issue(s) this PR fixes** :
Fixes#55290
**Release note**:
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 55697, 55631, 51905, 55647, 55826). 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>.
Move category expander out of kubectl/resource
Removes coupling with unstructured. Part of refactoring get.go and simplifying the builder.
Automatic merge from submit-queue (batch tested with PRs 55682, 55444, 55456, 55717, 55131). 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>.
hint command missing namespace parameters
**What this PR does / why we need it**:
hint command miss namespace parameters.
before change, the hint is:
```shell
Use 'kubectl describe pod/<podname>' to see all of the containers in this pod.
```
after change, the hint is:
```shell
Use 'kubectl describe pod/<podname> -n <podnamespace>' to see all of the containers in this pod.
```
**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
NONE
```
Automatic merge from submit-queue (batch tested with PRs 55648, 55274, 54982, 51955, 55639). 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>.
Enhance label and taint documentation in kubectl
**What this PR does / why we need it**:
This adds some language around how taint and label keys can have a domain + '/' in front of them. From the current documentation, it would seem like these are not allowed even though [well known labels](https://kubernetes.io/docs/reference/labels-annotations-taints/) have them.
Also, it seemed unclear (to me) that both the label's key and value can be 63 characters long. I wanted to clarify this.
**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
None
**Special notes for your reviewer**:
Phrasing of "_DNS subdomain prefix and '/'_" was copied from [a validator's message](https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apimachinery/pkg/util/validation/validation.go#L57) ... I'm unsure if its the best wording, but wanted to be consistent with the validator.
**Release note**:
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 54602, 54877, 55243, 55509, 55128). 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>.
move cmd/util/printing.go#PrintResourceInfoForCommand -> factory…
**Release note**:
```release-note
NONE
```
This patch is one in a series of patches that aims to move all
printing functions to the `cmdutil.Factory` in order to make
the factory the one-stop shop for accessing printers in the client.
This PR is related to https://github.com/kubernetes/kubernetes/pull/50113 and aims to break the set of changes
introduced in this commit in order to make them easier to review.
@fabianofranz @mengqiy @shiywang @seans3
Automatic merge from submit-queue (batch tested with PRs 54826, 53576, 55591, 54946, 54825). 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>.
Make sure the ports are valid when parsing portString
**What this PR does / why we need it**:
We need ensure the ports are valid when parsing `portString`.
**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
```
Automatic merge from submit-queue (batch tested with PRs 55283, 55461, 55288, 53970, 55487). 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 an unreachable kubectl explain field lookup test
In error case, the condition `gotErr != test.err && gotPath !=
test.expectedPath` never fulfill because in this case both gotPath and
test.expectedPath are always an empty string. So the err “err: `field "what?"
does not exist`” doesn’t get tasted. For example, if you change the value of
`err:` to anything, the test still will pass. Also, since gotPath is empty
string in case of err, in the output error we probably don’t want to display
path.
**What this PR does / why we need it**:
Fixes an unreachable unit test.
**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
None
```
Automatic merge from submit-queue (batch tested with PRs 53337, 55465, 55512, 55522, 54554). 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>.
switch UpdatePodSpecForObject to work on v1.PodSpec, use info.VersionedObject, and avoid conversion completely
**What this PR does / why we need it**:
ref #54212
ref #https://github.com/kubernetes/kubectl/issues/83
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
**Special notes for your reviewer**:
cc @liggitt @pwittrock
**Release note**:
```release-note
NONE
```
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>.
add create subcommand for priorityclass
**What this PR does / why we need it**:
add `create priorityclass` sub command
**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 #54857
**Special notes for your reviewer**:
**Release note**:
```release-note
add create priorityclass sub command
```
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
```
Automatic merge from submit-queue (batch tested with PRs 54987, 55221, 54099, 55144, 54215). 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>.
Scale help
**What this PR does / why we need it**:
The `kubectl autoscale --help` says this:
```
# Auto scale a deployment "foo", with the number of pods between 2 and 10, target CPU utilization specified so a default autoscaling policy will be used:
kubectl autoscale deployment foo --min=2 --max=10
```
This is incorrect. A default autoscaling policy will be used because *no* target CPU utilization has been specified.
**Which issue(s) this PR fixes**:
**Special notes for your reviewer**:
**Release note**:
```release-note
NONE
```
Automatic merge from submit-queue. 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>.
Remove out of date TODO
**What this PR does / why we need it**:
Since https://github.com/kubernetes/kubernetes/issues/17384 has done, we can remove out of data TODO
**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
NONE
```
In error case, the condition “gotErr != test.err && gotPath !=
test.expectedPath” never fulfill because in this case both gotPath and
test.expectedPath always an empty string. So the err “err: `field "what?"
does not exist`” doesn’t get tasted. For example, if you change the value of
“err” to anything, the test still will pass. Also, since gotPath is empty
string in case of err, in the output error we probably don’t want to display
path.
Automatic merge from submit-queue. 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>.
Add apelisse to some OWNERS
I wrote most of this code anyway.
**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
NONE
```
Automatic merge from submit-queue (batch tested with PRs 55268, 55282, 55419, 48340, 54829). 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>.
Support completions for kubectl config rename-context
**What this PR does / why we need it**:
With this PR, kubectl config rename-context supports completion for current context.
```
$ kubectl config rename-context <tab>
cluster01 minikube
```
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
**Special notes for your reviewer**:
**Release note**:
```release-note
Support completion for kubectl config rename-context
```
Automatic merge from submit-queue (batch tested with PRs 55268, 55282, 55419, 48340, 54829). 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>.
Add MutatingWebhookConfiguration type
As part of Mutating Webhook support, this PR adds the configuration for Mutating webhooks. It also renames existing ReadOnly webhook configurations from ExternalAdmissionHookConfiguration to ValidatingWebhookConfiguration. As part of the process some sub-types are also renamed.
Lastly, the mutating webhook configurations are sorted by name to make the serial executing of them deterministic.
ref: https://github.com/kubernetes/features/issues/492
Automatic merge from submit-queue (batch tested with PRs 46946, 45792). 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>.
kubectl config get-contexts: sort output
This sorts the output of kubectl config get-contexts because the ordering is otherwise non-stable and makes it harder to find the context you're looking for when you have more than a few.
```release-note
The output of kubectl config get-contexts is now sorted alphabetically by the context name.
```
Automatic merge from submit-queue. 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>.
tolerate discovery errors in the restmapper
Found this while investigating a related problem. The restmapper can use the information it has found. It doesn't have to discard all of it.
Automatic merge from submit-queue. 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>.
kubectl/config/rename: fix wording
Using `Context %q renamed to %q.` in rename-context to be consistent with other
commands like delete-context, set-context, use-context.
/sig cli
/release-note none
Automatic merge from submit-queue (batch tested with PRs 55092, 55348, 55095, 55277, 55352). 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>.
refactor build in kubectl factory
Refactor kubectl factory and resource builder.
This will be helpful for `kinflate`.
```release-note
NONE
```
/assign @monopole
Automatic merge from submit-queue (batch tested with PRs 54177, 55203, 55120, 55275, 55260). 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>.
Make ReconcileOptions reusable
This change makes ReconcileOptions fully reusable by:
1. Replacing ResourceBuilder with a Visitor that can be generically plugged in. This decouples the use of file input from the options.
2. Replacing core client with namespace client since that smaller interface is what is needed by RunReconcile.
3. All fields are now checked by Validate as a way to document that they should be set before calling RunReconcile.
Signed-off-by: Monis Khan <mkhan@redhat.com>
```release-note
NONE
```
/assign @deads2k @fabianofranz @juanvallejo
Automatic merge from submit-queue. 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>.
Replace some occurances of kubernetes internal api types in kubectl
**What this PR does / why we need it**:
Removes dependency on k8s.io/kubernetes/pkg/apis/extensions from kubectl
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
part of https://github.com/kubernetes/kubectl/issues/83
fixes: https://github.com/kubernetes/kubectl/issues/92
**Special notes for your reviewer**:
**Release note**:
```NONE
```
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
Automatic merge from submit-queue (batch tested with PRs 53273, 55058, 55237, 50140). 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>.
add field selector for kubectl get
**What this PR does / why we need it**:
When working in #50075, I found current kubectl did not support using `field-selector`.
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes#14129
**Special notes for your reviewer**:
/cc @janetkuo @kargakis
/assign @derekwaynecarr @smarterclayton @bgrant0607
**Release note**:
```release-note
add field selector for kubectl get
```
This change makes ReconcileOptions fully reusable by:
1. Replacing ResourceBuilder with a Visitor that can be generically
plugged in. This decouples the use of file input from the options.
2. Replacing core client with namespace client since that smaller
interface is what is needed by RunReconcile.
3. All fields are now checked by Validate as a way to document that
they should be set before calling RunReconcile.
Signed-off-by: Monis Khan <mkhan@redhat.com>