Automatic merge from submit-queue (batch tested with PRs 56947, 56349, 57140, 53686, 57314). 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: Move no-headers flag get out of for loop
**What this PR does / why we need it**:
This makes no-headers flag get before the for loop happen, there's no need to get the flag multiple times.
**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 57324, 56931, 57000, 57150, 56965). 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>.
allow convert to default on a per object basis
`kubetl convert` needs to distinguish between cases where a user specifies a version (use this at all cost) and cases where it doesn't (for each object, find the best version to convert to). This allows that to happen.
Automatic merge from submit-queue (batch tested with PRs 57127, 57011, 56754, 56601, 56483). 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 bad output format for attaching pods
**What this PR does / why we need it**:
If the user wants to attach stdin, wants a TTY, and `o.In` is a terminal, `t.Raw` is set to true, which is causing bad format like #56450.
We should avoid print extra logs in `SafeFunc`. Move it outer.
**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#56450
**Special notes for your reviewer**:
/assign @thockin @kubernetes/sig-cli-bugs
**Release note**:
```release-note
None
```
Automatic merge from submit-queue (batch tested with PRs 56676, 57050, 54881, 56822, 57113). 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>.
ensure PrinterForCommand is consumed through cmdutil.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
Automatic merge from submit-queue (batch tested with PRs 56997, 57008, 56984, 56975, 56955). 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 internal version api from apply
Signed-off-by: dungeonmaster18 <umesh4257@gmail.com>
**What this PR does / why we need it**:
Remove internal api version from apply.go.
**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
it helps fixing [kubernetes/kubectl#83](https://github.com/kubernetes/kubectl/issues/83).
**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>.
Supplement unit test for kubectl logs
**What this PR does / why we need it**:
Supplement unit test for kubectl logs
**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 56639, 56746, 56715, 56673, 56726). 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 a typo in kubectl/diff cmd long description.
**What this PR does / why we need it**:
Correct a typo in kubelet alpha diff cmd long description.
**Release note**:
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 56639, 56746, 56715, 56673, 56726). 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>.
Simple code and typo fixed.
**What this PR does / why we need it**:
Simple code and typo fixed.
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
none
**Special notes for your reviewer**:
none
**Release note**:
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 56579, 55236, 56512, 56549, 56538). 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: point info url to user guide overview
The kubectl command output suggests a user find more information at the
github source repo, eg:
$ kubectl --help
kubectl controls the Kubernetes cluster manager.
Find more information at https://github.com/kubernetes/kubernetes.
But there is curated user documentation available at, eg:
https://kubernetes.io/docs/reference/kubectl/overview/
which upon referencing yields a much better experience for a user than the
top of the source repo.
Fixes#56511
Signed-off-by: Tim Pepper <tpepper@vmware.com>
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 56413, 56322, 56490, 56460, 56487). 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>.
Use policy client with explicit version
**What this PR does / why we need it**:
**Which issue(s) this PR fixes** :
Fixes partially #55993
**Special notes for your reviewer**:
/cc @caesarxuchao @sttts
**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>.
Make kubectl explain print the Kind and APIVersion of the resource
**What this PR does / why we need it**:
Kubectl explain currently doesn't print out the Kind and APIversion of the resource being explained. When running `kubectl explain hpa.spec`, for example, there is no way of knowing whether you're looking at the `autoscaling/v1` or the `autoscaling/v2beta1` version.
Also, `kubectl explain` is often used as a reference when writing YAML/JSON object manifests. It allows you to look up everything except the API version. Currently, you either need to know the API Version of a resource by heart or look it up in the online API docs.
This PR fixes both problems by having `kubectl explain` print out the full Kind and APIVersion of the resource it is explaining.
Here are a few examples of the new output:
```
$ kubectl explain deploy
KIND: Deployment
VERSION: extensions/v1beta1
DESCRIPTION:
...
$ kubectl explain hpa.spec
KIND: HorizontalPodAutoscaler
VERSION: autoscaling/v1
RESOURCE: spec <Object>
DESCRIPTION:
...
$ kubectl explain hpa.spec.maxReplicas
KIND: HorizontalPodAutoscaler
VERSION: autoscaling/v1
FIELD: maxReplicas <integer>
DESCRIPTION:
...
$ kubectl explain hpa.spec --recursive
KIND: HorizontalPodAutoscaler
VERSION: autoscaling/v1
RESOURCE: spec <Object>
DESCRIPTION:
behaviour of autoscaler. More info:
https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status.
specification of a horizontal pod autoscaler.
FIELDS:
maxReplicas <integer>
minReplicas <integer>
scaleTargetRef <Object>
apiVersion <string>
kind <string>
name <string>
targetCPUUtilizationPercentage <integer>
```
**Release note**:
```release-note
Kubectl explain now prints out the Kind and API version of the resource being explained
```
Automatic merge from submit-queue (batch tested with PRs 56217, 56268, 56263, 56328, 56200). 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>.
Use batch client with explicit version
**What this PR does / why we need it**:
**Which issue(s) this PR fixes** :
Fixes partially #55993
**Special notes for your reviewer**:
/cc @caesarxuchao @sttts
**Release note**:
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 55557, 55504, 56269, 55604, 56202). 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 internal version api from kubectl
**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**:
/cc @liggitt
**Release note**:
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 55900, 55995, 55913, 55467, 55376). 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>.
Improve unit test coverage of scale
**What this PR does / why we need it**:
1. Add unit test of ReplicaSet and StatefulSet to improve coverage of scale
2. Fix variable "fake" collideds with imported package name
3. Use Error with no value format and fix typo error messages
**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 55900, 55995, 55913, 55467, 55376). 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>.
Use structured generator for kubectl autoscale
**What this PR does / why we need it**:
Use structured generator for kubectl autoscale
**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
part of # https://github.com/kubernetes/kubectl/issues/138
**Special notes for your reviewer**:
/assign @mengqiy
**Release note**:
```release-note
Use structured generator for kubectl autoscale
```
Automatic merge from submit-queue (batch tested with PRs 55900, 55995, 55913, 55467, 55376). 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>.
Use extensions client with explicit version
**What this PR does / why we need it**:
Extensions client without explicit version has been deprecated, change them to the one with explicit version.
**Which issue(s) this PR fixes**:
Fixes partially #55993
**Special notes for your reviewer**:
**Release note**:
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 54604, 55781, 55806, 55935, 55991). 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>.
Use core client with explicit version
**What this PR does / why we need it**:
Core client without explicit version has been deprecated, change them to the one with explicit version.
**Which issue(s) this PR fixes**:
Fixes partially #55993
**Special notes for your reviewer**:
/cc @kubernetes/sig-api-machinery-pr-reviews
/cc @caesarxuchao @k82cn @sttts @kevin-wangzefeng
**Release note**:
```release-note
NONE
```
The kubectl command output suggests a user find more information at the
github source repo, eg:
$ kubectl --help
kubectl controls the Kubernetes cluster manager.
Find more information at https://github.com/kubernetes/kubernetes.
But there is curated user documentation available at, eg:
https://kubernetes.io/docs/reference/kubectl/overview/
which upon referencing yields a much better experience for a user than the
top of the source repo.
Fixes#56511
Signed-off-by: Tim Pepper <tpepper@vmware.com>
Automatic merge from submit-queue (batch tested with PRs 51321, 55969, 55039, 56183, 55976). 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>.
Topology aware volume scheduler and PV controller changes
**What this PR does / why we need it**:
Scheduler and PV controller changes to support volume topology aware scheduling, as specified in kubernetes/community#1168
**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#54435
**Special notes for your reviewer**:
* I've split the PR into logical commits to make it easier to review
* The remaining TODOs I plan to address next release unless you think it needs to be done now
**Release note**:
```release-note
Adds alpha support for volume scheduling, which allows the scheduler to make PersistentVolume binding decisions while respecting the Pod's scheduling requirements. Dynamic provisioning is not supported with this feature yet.
Action required for existing users of the LocalPersistentVolumes alpha feature:
* The VolumeScheduling feature gate also has to be enabled on kube-scheduler and kube-controller-manager.
* The NoVolumeNodeConflict predicate has been removed. For non-default schedulers, update your scheduler policy.
* The CheckVolumeBinding predicate has to be enabled in non-default schedulers.
```
@kubernetes/sig-storage-pr-reviews @kubernetes/sig-scheduling-pr-reviews
Automatic merge from submit-queue (batch tested with PRs 51321, 55969, 55039, 56183, 55976). 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 apply and strategic merge patch using openapi
- [x] support openapi in strategic merge patch
- [x] test openapi in strategic merge patch
- [x] kubectl apply use openapi to calculate diff be default. It will fall back to use baked-in types when openapi is not available.
- [x] test openapi in kubectl apply
Fixes: kubernetes/kubectl#55
```release-note
kubectl apply use openapi to calculate diff be default. It will fall back to use baked-in types when openapi is not available.
```
/assign @apelisse
Automatic merge from submit-queue (batch tested with PRs 54529, 53765). 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 #53735, check whether interface conversion is ok
**What this PR does / why we need it**:
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
fix#53735
avoid interface conversion error
**Special notes for your reviewer**:
**Release note**:
```release-note
```
Callers must take a dependency on one or the other set of conversions
and default client behavior. Future changes may add a Versioned() type,
but this is an accurate reflection of current code state.
The unified RESTMapper and Typer follow the new rules, but on error will
fallback to the legacy path (while still supporting Unstructured
objects). This allows callers to handle the appropriate distinction
themselves if necessary.
Add a LocalParam() method to the resource.Builder that DRYs up a large
chunk of complicated code in set commands.
Also remove error messages that depended on ObjectKinds() - future
changes will potentially remove this interface and the replacements here
are equivalent.
Delays the error until the first call and then preserves it for others.
More closely matches the intent of the Object() calls. Loaders are now
lazy and don't need to return errors directly.
Sets the stage for collapsing unstructured and structured builders
together.
Reduce all uses of Unstructured to the simpler form, and avoid asking
for mapper or typer unless it is required. Use Typed() for places that
previously used VersionedObject, and remove paths for versioned objects
from code that is now using unstructured.
Demonstrate its use with get.go by removing the need to call decode with
a hardcoded scheme. Add tests to get_test.go to restore proving that
unstructured conversion is possible.
Automatic merge from submit-queue (batch tested with PRs 55757, 55741, 55817, 55834, 51530). 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>.
Allow resource.Builder to modify requests per client
Gives the builder a hook point to add settings to each request. These
settings are applied before the request is created and so are unable to
view the request. Intended to set controls on a per request basis.
Prereq for server-side `kubectl get`
@enj as requested @kubernetes/sig-cli-api-reviews
Automatic merge from submit-queue (batch tested with PRs 55233, 55927, 55903, 54867, 55940). 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#PrintSuccess to factory_builder.go
**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 that set of changes
by introducing a portion of them in this commit in order to make
them easier to review.
@fabianofranz @mengqiy @shiywang @seans3
Automatic merge from submit-queue (batch tested with PRs 50457, 55558, 53483, 55731, 52842). 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>.
Show openapi custom columns in `kubectl get`
Change the name of the flag to something slightly more user-friendly,
while making it default true. The flag is kept so that someone can
revert it temporarly if things go wrong.
**What this PR does / why we need it**: OpenAPI can specify for some columns to be used in `kubectl get`. That's very useful for non-core/hard-coded type in order to print more valuable data in get.
**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**:
Closeskubernetes/kubectl#143
**Release note**:
```release-note
`kubectl get` will now use OpenAPI schema extensions by default to select columns for custom types.
```
Gives the builder a hook point to add settings to each request. These
settings are applied before the request is created and so are unable to
view the request. Intended to set controls on a per request basis.
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>.
Move unstructured conversion into pkg/runtime
Scheme conversion should support unstructured conversion natively to
allow going from unstructured to typed and back. It is not a higher
level responsibility to do that conversion because the scheme is the
only one who knows what types it supports.
@liggitt @kubernetes/sig-cli-api-reviews I am going to make Scheme support unstructured in ConvertToVersion and Convert, which means resource.Builder and the CLI can get simpler for all existing use cases where versioned and unstructured need to coexist.
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 explain: ignore trailing period
Fixes#54891
Ignores trailing period for kubectl explain i.e. `kubectl explain ingress.spec.rules.http.paths.` is valid and defaults to `kubectl explain ingress.spec.rules.http.paths`.
**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 unused function in cmd_test.go
PR removed unused defaultClientConfigForVersion() functions from cmd_test.go.
**What this PR does / why we need it**:
**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**:
```
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>.
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
If a user edits last-applied-configuration and it doesn't have an
apiVersion or kind, the command should error out. Now that we check for
kind and version on the unstructured object typer, the previously
passing test now correctly fails. Add a new explicit failure test and
make the existing test pass.
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
```
Change the name of the flag to something slightly more user-friendly,
while making it default true. The flag is kept so that someone can
revert it temporarly if things go wrong.
Add a new EmptyResource class that implements openapi.Resources, but
just doesn't have any resources. That is useful for tests that expect
the OpenAPISchema to be working, but don't expect any actual result.
Also implement CreateOpenAPISchemaFunc to simply plug in the TestFactory
code when you want to use an actual APISchema.
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
```
kubectl explain ingress.spec.rules.http.paths. is valid
and defaults to kubectl explain ingress.spec.rules.http.paths
Rational: We use kubectl explain by adding fields
(e.g. service, then service.spec, then service.spec.ports ...)
so it's very easy to forget a trailing . at the end. We should
ignore the trailing period and display the result without it.
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>
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 kubectl dependency internal version
**What this PR does / why we need it**:
ref kubernetes/kubectl#83
**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**:
use `k8s.io/api/core/v1` replace `k8s.io/kubernetes/pkg/api`
use `k8s.io/client-go/kubernetes/typed/core/v1` replace `k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion`
**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>.
Workloads V1
**What this PR does / why we need it**: This PR promotes the Deployment, ReplicaSet, and DaemonSet StatefulSet, ControllerRevision kinds to the apps/v1 group version.
https://github.com/kubernetes/features/issues/353
**Special notes for your reviewer**:
There will be at least two followups to this PR. The first to add a scale sub-resource when the correct location is resolved, and the second to deal with Conditions in the workloads API.
While it would have been preferable to move the kinds individually providing a lesser burden on reviewers, this proved impracticable due to the intricacies of version resolution in kubectl for objects of the different kinds in the same group.
```release-note
DaemonSet, Deployment, ReplicaSet, and StatefulSet have been promoted to GA and are available in the apps/v1 group version.
```
Automatic merge from submit-queue (batch tested with PRs 51401, 54056, 54977, 55017, 55052). 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>.
extensions: remove TPR remnants
The extensions group still had the TPR types + generated client. Having this in the codebase doesn't create any problems but would be good to clean up, especially since TPR access has been removed in 1.8.
**Release note**:
```release-note
NONE
```
/assign @sttts @deads2k
Automatic merge from submit-queue (batch tested with PRs 51401, 54056, 54977, 55017, 55052). 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 example and comments for kubectl convert
Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>
**What this PR does / why we need it**:
There are some erros in example and comments in convert
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
**Release note**:
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 51401, 54056, 54977, 55017, 55052). 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>.
[cli] exit when Validate() returns an error
cmdutil.UsageErrorf() does nothing but returna a string. When Validate()
returns an error, we should call exit() function.
fix: https://github.com/kubernetes/kubectl/issues/119
**Release note**:
```
NONE
```
Using "Context %q renamed to %q." in rename-context to be consistent with other
commands like delete-context, set-context, use-context.
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
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>.
discovery client not depend on pkg/api/legacyscheme
Switch kubectl's cached discovery client to use kubect's scheme (pkg/kubectl/scheme) which only registered with external version types.
The encoding and decoding here uses only `k8s.io/apimachinery/pkg/apis/meta/v1.APIGroupList` and `k8s.io/apimachinery/pkg/apis/meta/v1.APIResourceList` which are not internal version. So it should be safe.
```release-note
NONE
```
/assign @monopole
Automatic merge from submit-queue (batch tested with PRs 55016, 50887). 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>.
Cleanup resouce test
- Make client-go testing support decoding to external version
- Cleanup bad dependency of `pkg/kubectl/resource` pkg
```release-note
NONE
```
/assign @monopole @caesarxuchao
Automatic merge from submit-queue (batch tested with PRs 52367, 53363, 54989, 54872, 54643). 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 retainkeys strategy for new merge code
- Some prefactoring for retainkeys
- Add retainkeys strategy
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 52367, 53363, 54989, 54872, 54643). 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>.
should check and return err when visit failure
**What this PR does / why we need it**:
should check and return err when visit failure
**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 55004, 54957). 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>.
Update kube-openapi to use validation
**What this PR does / why we need it**: Moves openapi validation code to kube-openapi, so that we can move the rest of the code to apimachinery repository, so that later we can use it from both the client and the server.
**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 #Nothing
**Special notes for your reviewer**:
**Release note**:
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 54895, 54449). 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>.
Update the get command to follow more conventions of commands
Pure code movement, builds on top of #54446 and only the last commit is new. Will make refactoring get easier.
Automatic merge from submit-queue (batch tested with PRs 54042, 54185, 54880). 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>.
Inventory of kubectl dependency on main repository
**What this PR does / why we need it**:
Add an import-boss file to inventory what kubectl depends on, so
we can prune this list over time and eventually get kubectl out
of the main k/k repository.
**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Related to https://github.com/kubernetes/kubectl/issues/114
**Special notes for your reviewer**:
**Release note**:
```release-note
NONE
```
Add an import-boss file to inventory what kubectl depends on, so
we can prune this list over time and eventually get kubectl out
of the main k/k repository.
To update this list, You can list the dependencies using:
go list -f '{{ join .Deps "\n"}}' k8s.io/kubernetes/cmd/kubectl | grep
k8s.io/kubernetes | grep -v kubectl | grep -v vendor
Add the generated list of package names to .import-restrictions
file. Then run the hack/verify-import-boss.sh until you have you have
all the packages needed.
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>.
Improve 'kubectl completion` to override short flags
**What this PR does / why we need it**: This PR improves `kubectl completion` to override short flags in
addition to long flags. I tested this PR in both bash and zsh.
```
# Complete pods name in the `default` namespace
$ kubectl get po nginx-4217019353-<tab>
nginx-4217019353-mw1pk nginx-4217019353-rzw2c
# Complete pods name in the `kube-system` namepace due to overriding the namespace
$ kubectl -n kube-system get po kube<tab>
kube-addon-manager-minikube kube-dns-910330662-l9pwt kubernetes-dashboard-9fbhm
```
**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
NONE
```
Automatic merge from submit-queue (batch tested with PRs 53190, 54790, 54445, 52607, 54801). 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 created-by annotation
**What this PR does / why we need it**:
This PR removes `CreatedByAnnotation`.
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes#50720
**Release note**:
```release-note
The `kubernetes.io/created-by` annotation is no longer added to controller-created objects. Use the `metadata.ownerReferences` item that has `controller` set to `true` to determine which controller, if any, owns an object.
```
Automatic merge from submit-queue (batch tested with PRs 53190, 54790, 54445, 52607, 54801). 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>.
one of min-available/max-available must be specified when create pdb
**What this PR does / why we need it**:
fix TODO one of min-available/max-available must be specified when create pdb
**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
NONE
```
Automatic merge from submit-queue (batch tested with PRs 54446, 54202). 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>.
Create a new package for generic commands like get
This is in preparation for cleaning up the structure of `kubectl get` to ease implementing serverside get and streaming API responses. Moves a hardcoded constant into a method in preparation for a future serverside implementation. Also improves some existing description text.
Automatic merge from submit-queue (batch tested with PRs 54326, 54046). 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 apply does not send empty patch request
**What this PR does / why we need it**:
`kubectl apply -f filename` always send patch request to apiserver, whether the file changed or not.
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes#54010
**Special notes for your reviewer**:
**Release note**:
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 54774, 54820, 52192, 54827). 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>.
Added a test for proper `%s` handling when display last applied confi…
**What this PR does / why we need it**:
Added missing tests which checks proper handling of `%s` in arguments for command `kubectl apply view-last-applied`
**Which issue this PR fixes**
#54645
**Special notes for your reviewer**:
Added a test case to cover specific issue described.
It fails on version `v1.7.3`..`v1.7.9` and passes since `v1.8.0`.
P.S. Not sure if there is already a lower level test which covers this case in the k8s test suite. I would recommend to add this test, so the issue would not reoccur.
**Release note**:
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 54572, 54686). 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 partial env docs & examples
**What this PR does / why we need it**:
It adds documentation and examples to kubectl env.
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: This PR partially addresses [#98](https://github.com/kubernetes/kubectl/issues/98).
**Special notes for your reviewer**:
This is a partial PR. I'm mostly looking for feedback as to whether I'm on the right track with this issue. Any feedback is appreciated. Thanks.
(This is my contribution to Outreachy's Kubernetes internship application.)
**Release note**:
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 54728, 54818). 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>.
diff: Propragate errors when diffing
Because of that, errors while diffing would potentially not do anything,
leaving the user clueless of what was going on.
**What this PR does / why we need it**:
**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
NONE
```
Automatic merge from submit-queue (batch tested with PRs 54533, 54777, 54763, 54806, 54703). 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>.
Create kubectl's own instance of Scheme and Registry
Create kubectl's own instance of Registry and Scheme.
Switch most command that doesn't depend on internal types to use kubectl's own scheme and register.
There are some hack of registering the internal types in some of unit test now, they should be gone after switch to the external type.
Switch kubectl's factory code to use kubectl's scheme will create a lot of ripples.
I don't want make this PR a super giant PR, so I will do it in a followup PR.
Partially addressed #48564.
Copy the summary from https://github.com/kubernetes/kubernetes/pull/54533#issuecomment-340522302:
- creates pkg/kubectl/scheme (install.go and scheme.go) with
deps on properly vendored k8s.io packages.
- deletes about 80% percent of dependence on pkg/api/legacyscheme
- replaces direct dependence from pkg/kubectl on
pkg/apis/rbac
to a vendor style dependence on
k8s.io/api/rbac
and removes dependencies on rbac paths containing internalversion
- replaces almost 50% of direct dependence on pkg/api with (properly vendored)
k8s.io/api/core/v1
- deletes all of dependence on pkg/apis/policy and k8s.io/api/policy/v1beta1
```release-note
NONE
```
/assign @monopole @apelisse
cc: @pwittrock
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>.
Fix print format of rootScoped resourced in kubectl
**What this PR does / why we need it**:
remove _NAMESPACE_ filed when querying rootScoped resource with kubectl
**Which issue this PR fixes**
fixes#53767
**Special notes for your reviewer**:
/cc @smarterclayton
**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>.
Support api chunking in kubectl get
This enables chunking in the resource builder to make it easy to
retrieve resources in pages and visit partial result sets. This adds
`--chunk-size` to `kubectl get` only so that users can get comfortable
with the use of chunking in beta. Future changes will enable chunking
for all CLI commands so that bulk actions can be performed more
efficiently.
```
$ kubectl get pods --all-namespaces
... print batch of 500 pods ...
... print second batch of 500 pods ...
...
```
@kubernetes/sig-cli-pr-reviews @kubernetes/sig-api-machinery-pr-reviews
```release-note
`kubectl get` will by default fetch large lists of resources in chunks of up to 500 items rather than requesting all resources up front from the server. This reduces the perceived latency of managing large clusters since the server returns the first set of results to the client much more quickly. A new flag `--chunk-size=SIZE` may be used to alter the number of items or disable this feature when `0` is passed. This is a beta feature.
```
This enables chunking in the resource builder to make it easy to
retrieve resources in pages and visit partial result sets. This adds
`--chunk-size` to `kubectl get` only so that users can get comfortable
with the use of chunking in beta. Future changes will enable chunking
for all CLI commands so that bulk actions can be performed more
efficiently.
Automatic merge from submit-queue (batch tested with PRs 54112, 54150, 53816, 54321, 54338). 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 federation
This PR removes the federation codebase and associated tooling from the tree.
The first commit just removes the `federation` path and should be uncontroversial. The second commit removes references and associated tooling and suggests careful review.
Requirements for merge:
- [x] Bazel jobs no longer hard-code federation as a target ([test infra #4983](https://github.com/kubernetes/test-infra/pull/4983))
- [x] `federation-e2e` jobs are not run by default for k/k
**Release note**:
```release-note
Development of Kubernetes Federation has moved to github.com/kubernetes/federation. This move out of tree also means that Federation will begin releasing separately from Kubernetes. The impact of this is Federation-specific behavior will no longer be included in kubectl, kubefed will no longer be released as part of Kubernetes, and the Federation servers will no longer be included in the hyperkube binary and image.
```
cc: @kubernetes/sig-multicluster-pr-reviews @kubernetes/sig-testing-pr-reviews
Automatic merge from submit-queue (batch tested with PRs 54336, 54470, 54334, 54175). 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>.
Update kubectl drain command to use policy V1Beta1 instead of unversioned API
**What this PR does / why we need it**:
Removes kubectl dependency on `k8s.io/kubernetes/pkg/apis/policy` by switching to `k8s.io/api/policy/v1beta1`. Part of 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 https://github.com/kubernetes/kubectl/issues/90
**Special notes for your reviewer**:
/cc @kubernetes/sig-cli-pr-reviews
**Release note**:
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 52003, 54559, 54518). 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 kubectl create namespace dependencies on kubernetes/pkg/api
**What this PR does / why we need it**:
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**:
**Release note**:
```release-note
NONE
```
Automatic merge from submit-queue (batch tested with PRs 53051, 52489, 53920). 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>.
Implement `kubectl alpha diff` to diff resources
`kubectl alpha diff` lets you diff your resources against live
resources, or last applied, or even preview what changes are going to be
applied on the cluster.
This is still quite premature, and mostly untested.
**What this PR does / why we need it**:
**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**:
Clearly not ready for Release note.
```release-note
NONE
```
kubernetes/community#287
Automatic merge from submit-queue (batch tested with PRs 54107, 54184, 54377, 54094, 54111). 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>.
exit with correct exit code on plugin failure
**Release note**:
```release-note
NONE
```
Correctly exits after a plugin command execution failure with the correct exit code.
Related downstream bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1501756
**Before**
```
$ kubectl plugin will-fail-plugin
ls: cannot access 'does-not-exist': No such file or directory
error: exit status 2
$ echo $?
1
```
**After**
```
$ kubectl plugin will-fail-plugin
ls: cannot access 'does-not-exist': No such file or directory
error: exit status 2
$ echo $?
2
```
cc @fabianofranz
Automatic merge from submit-queue (batch tested with PRs 54270, 54479). 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 kubectl set command
**What this PR does / why we need it**:
1. fix some errors in 'kubectl set' series command
2.remove unused function in kubectl set env command
**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**:
```
NONE
```
Test running time goes from 150 seconds to 7 seconds with that one
simple trick. Do not re-parse openapi schema for every test, but keep
one version for the whole test (specifically since it's read-only anyway).
Automatic merge from submit-queue (batch tested with PRs 53479, 54373, 54441, 54443). 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 govet in pkg/kubectl/apply
**What this PR does / why we need it**: Fix govet warning by explicitly using field keys.
**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
NONE
```
Automatic merge from submit-queue (batch tested with PRs 53479, 54373, 54441, 54443). 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>.
Better error check for kubectl cluster-info
**What this PR does / why we need it**:
In RunClusterInfo, We try to connect to the api service and get some
information, but we just ignore the errors from Do().Visit(). We should
return the error returned by Do().Visit() so the "kubectl cluster-info"
would fail correctly with an error code.
In RunClusterInfo, We try to connect to the api service and get some
information, but we just ignore the errors from Do().Visit(). We should
return the error returned by Do().Visit() so the "kubectl cluster-info"
would fail correctly with an error code.
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
Fixes#54349
**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>.
add kubectl create --raw -f
Adds `--raw` to `kubectl create` to match `kubectl get --raw`. It re-uses the transport, reads the input stream (stdin or a single file for now) and posts directly to the endpoint specified. This let's you direct data directly at a subresource (as a for instance). I'd like to see this extended to `kubectl replace` too, so that we have full access to subresources via scripting without having to reproduce the transports.
@kubernetes/sig-cli-pr-reviews
```release-note
add `--raw` to `kubectl create` to POST using the normal transport
```
Automatic merge from submit-queue (batch tested with PRs 53743, 53564). 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>.
Polymorphic Scale Client
This PR introduces a polymorphic scale client based on discovery information that's able to scale scalable resources in arbitrary group-versions, as long as they present the scale subresource in their discovery information.
Currently, it supports `extensions/v1beta1.Scale` and `autoscaling/v1.Scale`, but supporting other versions of scale if/when we produce them should be fairly trivial.
It also updates the HPA to use this client, meaning the HPA will now work on any scalable resource, not just things in the `extensions/v1beta1` API group.
**Release note**:
```release-note
Introduces a polymorphic scale client, allowing HorizontalPodAutoscalers to properly function on scalable resources in any API group.
```
Unblocks #29698
Unblocks #38756
Unblocks #49504Fixes#38810
`kubectl alpha diff` lets you diff your resources against live
resources, or last applied, or even preview what changes are going to be
applied on the cluster.
This is still quite premature, and mostly untested.
In RunClusterInfo, We try to connect to the api service and get some
information, but we just ignore the errors from Do().Visit(). We should
return the error returned by Do().Visit() so the "kubectl cluster-info"
would fail correctly with an error code.
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>.
fed: Move cluster generator & constants from kubectl to kubefed pkg
This will ensure the history of the federation-only files can be cheaply retained during the branch filtering that will occur for #52992.
cc: @kubernetes/sig-multicluster-pr-reviews
/sig multicluster
/area federation
/assign irfanurrehman shashidharatd
/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>.
kubectl resource builder to use versioned list
Switch to using a versioned listed when return an object from the resource builder.
This is necessary to allow cli's built outside the kubernetes/kubernetes repo to vendor the resource builder logic without vendoring all of Kubernetes.
The following commands call the modified function. (identified by changing the function name and recompiling)
- [x] `attach`
- pkg/kubectl/cmd/attach.go:155: builder.Do().Object
- passes to `AttachablePodForObject` which does not support Lists of any kind
- [x] `get`
- pkg/kubectl/cmd/get.go:251: r.Object
- [x] check if isList with `IsListType` -> `GetItemsPtr` -> check for presence of `Items` field
- [x] pass to `ResourceVersion` -> `CommonAccessor` -> checks for `metav1.ListInterface` (which this PR introduces a compile time check to ensure v1.List implements this)
- [x] pass to `ExtractList` -> checks if items implement `runtime.RawExtension`
- [x] `rolling_update`
- pkg/kubectl/cmd/rollingupdate.go:207: request.Object
- only accepts lists of length 1. updated in PR to support both api.List and v1.List
- [x] `rollout_status`
- pkg/kubectl/cmd/rollout/rollout_status.go:107: r.Object
- passes to `ResourceVersion` -> `CommonAccessor` -> checks for `metav1.ListInterface`
```release-note
NONE
```
Closeskubernetes/kubectl#81
Automatic merge from submit-queue (batch tested with PRs 54199, 54181, 54196). 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>.
Update openapi to use kube-openapi code
**What this PR does / why we need it**: OpenAPI code has moved to `github.com/kubernetes/kube-openapi`. Let's use that code as a dependency, since now it's duplicated.
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes#51823
**Special notes for your reviewer**:
**Release note**:
```release-note
NONE
```
No user visible changes. Just code moving around.
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>.
update .dockercfg content to config.json
update the data format of .dockercfg to match the new docker config.json
format, which encapsulates all registry auth objects in an overall
"auths" object when an option `--config-format` is specified with the value
`--config-format=config.json`:
```
{
"auths": {
"reg.url": {
"auth": "...=="
}
}
}
```
**Release note**:
```release-note
secret data containing Docker registry auth objects is now generated using the config.json format
```
cc @bparees @fabianofranz
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>.
Create new unit tests for version and kind validation
This is a follow up PR per discussion in the
https://github.com/kubernetes/kubernetes/pull/53587
Creating new unit tests here for basic and aggregated validation of version
and kind group.
**What this PR does / why we need it**:
**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
NONE
```
Previously, the fake RESTClient in client-go required a Registry. It
used the Registry to fetch the GroupVersion for the fake client.
However, the way it did so was dubious in some cases (it hard-coded the
default API group in places), and not strictly necssary.
This updates the fake client to just recieve the GroupVersion and
internal group name directly, instead of requiring a Registry, so that
it can be consumed in unit tests where a Registry isn't necessarily
readily available (e.g. elsewhere in client-go).
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 user-specified ns to --dry-run created obj
Fixes https://github.com/kubernetes/kubernetes/issues/51068
**Release note**:
```release-note
NONE
```
Includes a namespace in a created resource's metadata when `--dry-run` is used if:
- a namespace was explicitly set by the user (via `--namespace`)
- No errors occur accessing the object's metadata
cc @fabianofranz @deads2k
update the data format of .dockercfg to match the new docker config.json
format, which encapsulates all registry auth objects in an overall
"auths" object:
{
"auths": {
"reg.url": {
"auth": "...=="
}
}
}
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>.
pkg/api: extract Scheme/Registry/Codecs into pkg/api/legacyscheme
This serves as
- a preparation for the pkg/api->pkg/apis/core move
- and makes the dependency to the scheme explicit when vizualizing
left depenncies.
The later helps with our our efforts to split up the monolithic repo
into self-contained sub-repos, e.g. for kubectl, controller-manager
and kube-apiserver in the future.