Commit Graph

267 Commits (284e8182a402cfd545fc000fedaea071fed873b0)

Author SHA1 Message Date
juanvallejo 6d3652eded remove hardcoded list of resources 2018-04-26 09:31:58 -04:00
Kubernetes Submit Queue acbccfba84
Merge pull request #62820 from juanvallejo/jvallejo/wire-more-print-flags
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
2018-04-26 02:20:34 -07:00
juanvallejo 27bd4ded04 wire printflags through additional cmds 2018-04-25 16:07:32 -04:00
juanvallejo 191a48f4c3 wire PrintFlags through get cmd 2018-04-25 15:02:48 -04:00
David Eads 8c1b687356 update more commands for iostreams 2018-04-25 08:45:15 -04:00
David Eads 0710f72c65 remove confusing flexibility for metadata interpretation 2018-04-23 13:31:55 -04:00
David Eads 8ef56776b9 provide standard iostream struct for commands 2018-04-20 12:54:11 -04:00
juanvallejo ecaddbfc36
update delete, replace, run cmds 2018-04-16 16:48:39 -04:00
Maciej Szulik d12a8a8d48
Move all create subcommands to its own subdirectory 2018-04-12 23:47:31 +02:00
Kubernetes Submit Queue 229d2df48a
Merge pull request #42873 from xilabao/add-apiresources-command
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 api-resources command

**What this PR does / why we need it**:
As the RBAC role need to be related to resources. I think we can use the command to get the supported resources. 

```
# ./cluster/kubectl.sh api-resources   
NAME                                  SHORTNAMES   APIGROUP                       NAMESPACED   KIND
bindings                                                                          true         Binding
componentstatuses                     cs                                          false        ComponentStatus
configmaps                            cm                                          true         ConfigMap
endpoints                             ep                                          true         Endpoints
events                                ev                                          true         Event
limitranges                           limits                                      true         LimitRange
namespaces                            ns                                          false        Namespace
nodes                                 no                                          false        Node
persistentvolumeclaims                pvc                                         true         PersistentVolumeClaim
persistentvolumes                     pv                                          false        PersistentVolume
pods                                  po                                          true         Pod
podtemplates                                                                      true         PodTemplate
replicationcontrollers                rc                                          true         ReplicationController
resourcequotas                        quota                                       true         ResourceQuota
secrets                                                                           true         Secret
serviceaccounts                       sa                                          true         ServiceAccount
services                              svc                                         true         Service
externaladmissionhookconfigurations                admissionregistration.k8s.io   false        ExternalAdmissionHookConfiguration
initializerconfigurations                          admissionregistration.k8s.io   false        InitializerConfiguration
customresourcedefinitions             crd          apiextensions.k8s.io           false        CustomResourceDefinition
apiservices                                        apiregistration.k8s.io         false        APIService
controllerrevisions                                apps                           true         ControllerRevision
daemonsets                            ds           apps                           true         DaemonSet
deployments                           deploy       apps                           true         Deployment
replicasets                           rs           apps                           true         ReplicaSet
statefulsets                          sts          apps                           true         StatefulSet
tokenreviews                                       authentication.k8s.io          false        TokenReview
localsubjectaccessreviews                          authorization.k8s.io           true         LocalSubjectAccessReview
selfsubjectaccessreviews                           authorization.k8s.io           false        SelfSubjectAccessReview
subjectaccessreviews                               authorization.k8s.io           false        SubjectAccessReview
horizontalpodautoscalers              hpa          autoscaling                    true         HorizontalPodAutoscaler
jobs                                               batch                          true         Job
certificatesigningrequests            csr          certificates.k8s.io            false        CertificateSigningRequest
daemonsets                            ds           extensions                     true         DaemonSet
deployments                           deploy       extensions                     true         Deployment
ingresses                             ing          extensions                     true         Ingress
networkpolicies                       netpol       extensions                     true         NetworkPolicy
podsecuritypolicies                   psp          extensions                     false        PodSecurityPolicy
replicasets                           rs           extensions                     true         ReplicaSet
networkpolicies                       netpol       networking.k8s.io              true         NetworkPolicy
poddisruptionbudgets                  pdb          policy                         true         PodDisruptionBudget
clusterrolebindings                                rbac.authorization.k8s.io      false        ClusterRoleBinding
clusterroles                                       rbac.authorization.k8s.io      false        ClusterRole
rolebindings                                       rbac.authorization.k8s.io      true         RoleBinding
roles                                              rbac.authorization.k8s.io      true         Role
podpresets                                         settings.k8s.io                true         PodPreset
storageclasses                        sc           storage.k8s.io                 false        StorageClass
```
**Which issue this PR fixes**: fixes https://github.com/kubernetes/kubernetes/issues/42932

**Special notes for your reviewer**:

**Release note**:

```release-note
add kubectl api-resources command to discovery of resources
```
2018-04-03 14:35:09 -07:00
Kazuki Suda 1989aa5023 Support completion for kubectl apply view/edit-last-applied 2018-03-24 14:42:02 +09:00
Kubernetes Submit Queue 5286806a52
Merge pull request #58353 from juanvallejo/jvallejo/usability-fix-label
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
```
2018-03-21 14:15:10 -07:00
juanvallejo 3dc952e761
fix kubectl_filedir completion 2018-03-13 16:21:30 -04:00
juanvallejo d1cb6e36f2
distinguish which labels belong to resource 2018-03-12 11:10:27 -04:00
xilabao 110641b34c add kubectl api-resources command 2018-03-09 17:47:17 +08:00
Cao Shufeng f0cd1ad04e fix warning info format
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
```
2018-03-01 16:39:31 +08:00
Maciej Szulik 2935fd69e9
Change printDeprecationWarning to use fmt.Fprintf instead of glog 2018-02-21 22:38:39 +01:00
Maciej Szulik 0bf2561898
Deprecate kubectl scale job 2018-02-21 22:31:15 +01:00
David Eads d7ddcca231 low hanging fruit for using cobra commands 2018-01-17 13:43:43 -05:00
lcfang 44e2e7a906 delete the unused function in kubectl 2018-01-04 12:00:38 +08:00
Kubernetes Submit Queue 6236cddab7
Merge pull request #54881 from juanvallejo/jvallejo/use-printer-for-cmd-through-factory
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
2017-12-16 19:19:44 -08:00
Tim Pepper bd4e89cf5d 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>
2017-12-13 17:01:50 -08:00
juanvallejo c53120e6b9
ensure PrinterForCommand is consumed through cmdutil.Factory 2017-12-05 13:39:29 -05:00
Kubernetes Submit Queue 81631eceb8
Merge pull request #48340 from superbrothers/completions-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>.

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
```
2017-11-09 21:39:28 -08:00
Kubernetes Submit Queue 7f9f847ce9
Merge pull request #54406 from superbrothers/kubectl-override-short-flags
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
```
2017-10-31 22:32:54 -07:00
Clayton Coleman 93fed120fb
Move printing the valid resource types to a function
Should be calculated from discovery in the future. Also improve
descriptions on the affected commands.
2017-10-30 23:45:45 -04:00
Maru Newby adc338d330 Remove all traces of federation 2017-10-26 13:37:37 -07:00
Kazuki Suda d2816bc1ba Improve 'kubectl completion` to override short flags
This commit improves `kubectl completion` to override short flags in
addition to long flags.
2017-10-22 13:18:44 +09:00
Mark Janssen a9ed995a81 Add missing short names to kubectl help text
Add two resource type short names that are available but not included in
the resource types help text that appears when running `kubectl get`.
2017-10-08 15:59:44 +02:00
Kazuki Suda cd75007b3b Support completions for kubectl config rename-context 2017-10-04 22:15:34 +09:00
Kubernetes Submit Queue 551c4581c2 Merge pull request #48267 from superbrothers/clusterrole-flag-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>.

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
```
2017-10-03 22:04:00 -07:00
juanvallejo dfef8574cf
error msg fixes
Miscellaneous error message tweaks.
Makes the error message displayed in `kubectl get` more visible.
Returns exit code 1 if a patch fails.
2017-09-13 17:55:29 -04:00
zhengjiajin 357db0c39c Add kubectl set env command 2017-08-25 19:53:22 +08:00
Kubernetes Submit Queue d5ab597eb3 Merge pull request #49935 from xiangpengzhao/remove-dep-alias
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`
```
2017-08-22 19:45:34 -07:00
ymqytw b776df8a20 move i18n to kubectl/util 2017-08-16 12:27:36 -07:00
Kazuki Suda 1b4da8f66a Support completions for --clusterrole of kubectl create clusterrolebinding 2017-08-16 19:36:40 +09:00
shiywang d14660c271 remove deprecated command 'kubectl stop' 2017-08-16 08:34:44 +08:00
xiangpengzhao d6aca27b53 Remove deprecated kubectl command aliases 2017-08-02 03:08:48 -04:00
xiangpengzhao 396c596e07
Add customresourcedefinition and its shortcut in "kubectl get" 2017-07-18 15:31:56 +08:00
Kubernetes Submit Queue 4b4e91977d Merge pull request #48274 from superbrothers/fix-to-override-kubectl-flags
Automatic merge from submit-queue (batch tested with PRs 48381, 48274)

Fix completions for --namespace to override kubectl flags

**What this PR does / why we need it**:
This PR fixes completions for --namespace to override kubectl flags. Due to not using __kubectl_parse_get, __kubectl_get_namespaces doesn't support to override kubectl flags.

**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
```
2017-07-16 19:03:36 -07:00
Kubernetes Submit Queue 0049dd0717 Merge pull request #48381 from superbrothers/completion-kubectl-config-delete-cluster
Automatic merge from submit-queue

Support completion for kubectl config delete-cluster

**What this PR does / why we need it**:
This PR supports completion for kubectl config delete-cluster.
```
$ kubectl config delete-cluster <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 delete-cluster
```
2017-07-16 18:50:08 -07:00
juanvallejo f28ffdb5e9
replace hardcoded use of "kubectl" in apply warning msg 2017-07-13 16:19:19 -04:00
deads2k 0801ded425 remove dead code 2017-07-07 09:12:29 -04:00
Kazuki Suda 4eee8ea119 Support completion for kubectl config delete-cluster 2017-07-01 22:01:43 +09:00
Kazuki Suda 4cdc5247fc Rename function to follow other similar functions 2017-06-29 23:32:22 +09:00
Kazuki Suda fe598e0401 Fix completions for --namespace to override flags
Due to not using __kubectl_parse_get, __kubectl_get_namespaces doesn't
support to override kubectl flags.
2017-06-29 23:25:12 +09:00
Kubernetes Submit Queue 1864a2403c Merge pull request #46151 from verb/kubectl-featuregate
Automatic merge from submit-queue

Add alpha command to kubectl

Also allow new commands to disable themselves by returning a nil value. This can be used to disable commands based on feature gates.

**What this PR does / why we need it**: Method of enabling alpha functionality in kubectl

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

**Special notes for your reviewer**: Part of a discussion in #45922 with @pwittrock

**Release note**:

```release-note
NONE
```
2017-06-23 05:00:35 -07:00
Kubernetes Submit Queue 625a980941 Merge pull request #46696 from xiangpengzhao/mark-deprecated-command
Automatic merge from submit-queue (batch tested with PRs 47227, 47119, 46280, 47414, 46696)

Mark deprecated info in short description of deprecated commands.

**What this PR does / why we need it**:
Mark deprecated commands in 'kubectl help'. See https://github.com/kubernetes/kubectl/issues/20

**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/20

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2017-06-22 23:59:28 -07:00
Lee Verberne 01c7d129fb Create a kubectl alpha subcommand
Alpha commands can be added under `kubectl alpha` and are always
accessible (regardless of feature gates). If no alpha commands have been
defined then `alpha` is not displayed in `help`.
2017-06-16 07:09:21 +00:00
Kazuki Suda 11230907b3 Fix missing __kubectl_parse_config 2017-06-11 07:12:23 +09:00