Automatic merge from submit-queue (batch tested with PRs 64034, 64072, 64146, 64059, 64161). 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 wait
Adds a `kubectl wait --for=[delete|condition=condition-name] resource/string` command. This allows generic waiting on well behaved conditions and for a resource or set of resources to be deleted.
This was requested for delete to do foreground deletion
WIP because I need to add test cases.
@kubernetes/sig-cli-maintainers this is using a separation of concerns made possible by the genericclioptions to make an easily unit testable command.
@smarterclayton
```release-note
adds a kubectl wait command
```
Automatic merge from submit-queue (batch tested with PRs 63914, 63887, 64116, 64026, 62933). 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 initContainers into completion suggestions for kubectl logs/attach
**What this PR does / why we need it**: This PR improves autocomplete of kubectl logs/attach to add initContainers into completion suggestions in addition to containers.
```
$ cat <<EOL | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
spec:
initContainers:
- name: init-myservice
image: busybox
command: ['sh', '-c', 'until nslookup myservice; do echo waiting for myservice; sleep 2; done;']
- name: init-mydb
image: busybox
command: ['sh', '-c', 'until nslookup mydb; do echo waiting for mydb; sleep 2; done;']
containers:
- name: myapp-container
image: busybox
command: ['sh', '-c', 'echo The app is running! && sleep 3600']
EOL
$ kubectl logs myapp-pod <tab><tab>
init-mydb init-myservice myapp-container
```
**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 63526, 60371, 63444). 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 completion for kubectl cp
**What this PR does / why we need it**: With this PR, kubectl cp supports completion. I tested this PR in bash and zsh.
```
$ kubectl cp kube-system/<tab>
kube-system/kube-state-metrics-769566fdfb-4v52s: kube-system/kubernetes-dashboard-6b6ddbd46-t5bv9: kube-system/prometheus-694594c45b-qk5lq:
```
**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixeskubernetes/kubectl#5
**Special notes for your reviewer**: @cblecker
**Release note**:
```release-note
`kubectl cp` supports completion.
```
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>.
wire printflags through additional cmds
**Release note**:
```release-note
NONE
```
Adds PrintFlag pattern to more commands.
cc @deads2k @soltysh
Automatic merge from submit-queue (batch tested with PRs 61487, 58353, 61078, 61219, 60792). 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>.
distinguish which labels belong to resource
**Release note**:
```release-note
NONE
```
Usability improvement for `kubectl label ... --list` when listing labels for more than one resource.
Append resource kind/name before its set of labels.
**Before**
```
$ kubectl label dc myapp test-deployment-config label1=test --list
app=myapp
label1=test
label1=test
```
**After**
```
$ kubectl label dc myapp test-deployment-config label1=test --list
Listing labels for DeploymentConfig/myapp:
label1=test
app=myapp
Listing labels for DeploymentConfig/test-deployment-config:
label1=test
```
Before this change:
```
$ kubectl exec -p nginx-aaaaaaaaaaaaa-67b58bf687-r68b9 ls
-p POD_NAME is DEPRECATED and will be removed in a future version. Use exec POD_NAME instead.bin
boot
dev
...
$ kubectl scale --replicas=2 job/pi
kubectl scale job is DEPRECATED and will be removed in a future version.job.batch "pi" scaled
```
After this change:
```
$ kubectl exec -p nginx-aaaaaaaaaaaaa-67b58bf687-r68b9 ls
-p POD_NAME is DEPRECATED and will be removed in a future version. Use exec POD_NAME instead.
bin
boot
dev
...
$ kubectl scale --replicas=2 job/pi
kubectl scale job is DEPRECATED and will be removed in a future version.
job.batch "pi" scaled
```
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
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 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. 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. 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 --clusterrole of kubectl create clusterrolebinding
**What this PR does / why we need it**:
This PR supports completion for --clusterrole of kubectl create clusterrolebinding.
```
$ kubectl create clusterrolebinding hoge --clusterrole <tab>
admin system:controller:daemon-set-controller system:controller:node-controller system:controller:service-controller system:kube-scheduler
cluster-admin system:controller:deployment-controller system:controller:persistent-volume-binder system:controller:statefulset-controller system:node
edit system:controller:disruption-controller system:controller:pod-garbage-collector system:controller:ttl-controller system:node-bootstrapper
system:auth-delegator system:controller:endpoint-controller system:controller:replicaset-controller system:discovery system:node-problem-detector
system:basic-user system:controller:generic-garbage-collector system:controller:replication-controller system:heapster system:node-proxier
system:controller:attachdetach-controller system:controller:horizontal-pod-autoscaler system:controller:resourcequota-controller system:kube-aggregator system:persistent-volume-provisioner
system:controller:certificate-controller system:controller:job-controller system:controller:route-controller system:kube-controller-manager view
system:controller:cronjob-controller system:controller:namespace-controller system:controller:service-account-controller system:kube-dns
```
**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**:
I feel that it is better to except system clusterroles from completion candidates. What do you think about it?
**Release note**:
```release-note
Support completion for --clusterrole of kubectl create clusterrolebinding
```
Automatic merge from submit-queue (batch tested with PRs 50806, 48789, 49922, 49935, 50438)
Remove deprecated kubectl command aliases
**What this PR does / why we need it**:
These command aliases have been deprecated for more than two years. It's time to remove them.
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
ref: #8319#6118#8596
**Special notes for your reviewer**:
/sig cli
**Release note**:
```release-note
Remove deprecated kubectl command aliases `apiversions, clusterinfo, resize, rollingupdate, run-container, update`
```