Change:
Currently, it could not delete multiple pods at once, need to delete them one by one, it's very inconvenient if I have tons of pods to delete. Unlike docker, docker can multiple stop/rm containers/images at once.
This is possible using label selectors as of , which is better if you have tons of pods.
I agree that using label selector is better to delete all of pods under the label. But to delete multile pods at once is still usable: I just want to delete 1/2 pods under the label, label selector will not work selector could not span over other selectors or pods Another reason is docker rm/stop x y z works, I will wonder why kubectl cannot. This is not urgent, but I hope it can be implemented.
I agree. Thanks for the suggestion.
Would this be a suitable task for someone new to k8s development? If so, I'd be willing to take a look at this, if someone could provide a couple of hints where to start.
Further to my last message, I have a functional work in progress I would like to share, if anyone is interested?
PRs are welcome. See
Yes, this is a reasonable place to start. Since its in the client, you won't get much orientation to the core server code, but it will be a good place to orient to the client side API. There us also prior art that you can model off of. The kubectl create ... command already supports multiple resources. A good command to adapter would be the 'label' command. You can find it in Many thanks in advance! Brendan On Feb 19, 2015 8:21 AM, "Eric Tune" wrote:

Discussion:
kubectl get pods "${kube_flags[@]}" -lname=redis-master | grep -q 'redis-master' [ ! $(delete pods --all pods -l name=redis-master) ]   # not --all and label selector together kubectl delete --all pods "${kube_flags[@]}" # --all remove all the pods <ins> kubectl create -f examples/guestbook/redis-master.json "${kube_flags[@]}" kubectl create -f examples/redis/redis-proxy.yaml "${kube_flags[@]}" kubectl get pods redis-master redis-proxy "${kube_flags[@]}" kubectl delete pods redis-master redis-proxy # delete multiple pods at once howmanypods="$(kubectl get pods  -o template -t "{{ len .items }}" "${kube_flags[@]}")" [ "$howmanypods" -eq 0 ] kubectl create -f examples/guestbook/redis-master.json "${kube_flags[@]}" kubectl create -f examples/redis/redis-proxy.yaml "${kube_flags[@]}" kubectl stop pods redis-master redis-proxy # stop multiple pods at once </ins> howmanypods="$(kubectl get pods  -o template -t "{{ len .items }}" "${kube_flags[@]}")" [ "$howmanypods" -eq 0 ]

kubectl get services "${kube_flags[@]}" kubectl get services "service-${version}-test" "${kube_flags[@]}" kubectl delete service frontend "${kube_flags[@]}" <ins> servicesbefore="$(kubectl get services  -o template -t "{{ len .items }}" "${kube_flags[@]}")" kubectl create -f examples/guestbook/frontend-service.json "${kube_flags[@]}" kubectl create -f examples/guestbook/redis-slave-service.json "${kube_flags[@]}" kubectl delete services frontend redisslave # delete multiple services at once servicesafter="$(kubectl get services  -o template -t "{{ len .items }}" "${kube_flags[@]}")" [ "$((${servicesafter} - ${servicesbefore}))" -eq 0 ] </ins> kube::log::status "Testing kubectl(${version}:replicationcontrollers)" kubectl get replicationcontrollers "${kube_flags[@]}"

kubectl get replicationcontrollers "${kube_flags[@]}" kubectl describe replicationcontroller frontend-controller "${kube_flags[@]}" | grep -q 'Replicas:.*3 desired' kubectl delete rc frontend-controller "${kube_flags[@]}" <ins> rcsbefore="$(kubectl get replicationcontrollers  -o template -t "{{ len .items }}" "${kube_flags[@]}")" kubectl create -f examples/guestbook/frontend-controller.json "${kube_flags[@]}" kubectl create -f examples/guestbook/redis-slave-controller.json "${kube_flags[@]}" kubectl delete rc frontend-controller redis-slave-controller "${kube_flags[@]}" # delete multiple controllers at once rcsafter="$(kubectl get replicationcontrollers  -o template -t "{{ len .items }}" "${kube_flags[@]}")" [ "$((${rcsafter} - ${rcsbefore}))" -eq 0 ] </ins> kube::log::status "Testing kubectl(${version}:nodes)" kubectl get nodes "${kube_flags[@]}"

resources []string namespace string <del> name      string </del> <ins> names     []string </ins> defaultNamespace bool requireNamespace bool

return b } <del> // ResourceTypeOrNameArgs indicates that the builder should accept one or two arguments // of the form `(<type1>[,<type2>,...]|<type> <name>)`. When one argument is received, the types // provided will be retrieved from the server (and be comma delimited).  When two arguments are // received, they must be a single type and name. If more than two arguments are provided an // error is set. The allowEmptySelector permits to select all the resources (via Everything func). </del> <ins> // ResourceTypeOrNameArgs indicates that the builder should accept arguments // of the form `(<type1>[,<type2>,...]|<type> <name1>[,<name2>,...])`. When one argument is // received, the types provided will be retrieved from the server (and be comma delimited). // When two or more arguments are received, they must be a single type and resource name(s). // The allowEmptySelector permits to select all the resources (via Everything func). </ins> func (b *Builder) ResourceTypeOrNameArgs(allowEmptySelector bool, args ...string) *Builder { <del> switch len(args) { case 2: b.name = args[1] </del> <ins> switch { case len(args) > 2: b.names = append(b.names, args[1:]...) b.ResourceTypes(SplitResourceArgument(args[0])...) case len(args) == 2: b.names = append(b.names, args[1]) </ins> b.ResourceTypes(SplitResourceArgument(args[0])...) <del> case 1: </del> <ins> case len(args) == 1: </ins> b.ResourceTypes(SplitResourceArgument(args[0])...) if b.selector == nil && allowEmptySelector { b.selector = labels.Everything() } <del> case 0: </del> <ins> case len(args) == 0: </ins> default: b.errs = append(b.errs, fmt.Errorf("when passing arguments, must be resource or resource and name")) }

func (b *Builder) ResourceTypeAndNameArgs(args ...string) *Builder { switch len(args) { case 2: <del> b.name = args[1] </del> <ins> b.names = append(b.names, args[1]) </ins> b.ResourceTypes(SplitResourceArgument(args[0])...) case 0: default:

// visit selectors if b.selector != nil { <del> if len(b.name) != 0 { </del> <ins> if len(b.names) != 0 { </ins> return &Result{err: fmt.Errorf("name cannot be provided when a selector is specified")} } if len(b.resources) == 0 {

return &Result{visitor: VisitorList(visitors), sources: visitors} } <del> // visit single item specified by name if len(b.name) != 0 { </del> <ins> // visit items specified by name if len(b.names) != 0 { isSingular := len(b.names) == 1 </ins> if len(b.paths) != 0 { <del> return &Result{singular: true, err: fmt.Errorf("when paths, URLs, or stdin is provided as input, you may not specify a resource by arguments as well")} </del> <ins> return &Result{singular: isSingular, err: fmt.Errorf("when paths, URLs, or stdin is provided as input, you may not specify a resource by arguments as well")} </ins> } if len(b.resources) == 0 { <del> return &Result{singular: true, err: fmt.Errorf("you must provide a resource and a resource name together")} </del> <ins> return &Result{singular: isSingular, err: fmt.Errorf("you must provide a resource and a resource name together")} </ins> } if len(b.resources) > 1 { <del> return &Result{singular: true, err: fmt.Errorf("you must specify only one resource")} </del> <ins> return &Result{singular: isSingular, err: fmt.Errorf("you must specify only one resource")} </ins> } mappings, err := b.resourceMappings() if err != nil { <del> return &Result{singular: true, err: err} </del> <ins> return &Result{singular: isSingular, err: err} </ins> } mapping := mappings[0] <ins> client, err := b.mapper.ClientForMapping(mapping) if err != nil { return &Result{err: err} } selectorNamespace := b.namespace </ins> if mapping.Scope.Name() != meta.RESTScopeNameNamespace { <del> b.namespace = "" </del> <ins> selectorNamespace = "" </ins> } else { if len(b.namespace) == 0 { <del> return &Result{singular: true, err: fmt.Errorf("namespace may not be empty when retrieving a resource by name")} </del> <ins> return &Result{singular: isSingular, err: fmt.Errorf("namespace may not be empty when retrieving a resource by name")} </ins> } } <del> client, err := b.mapper.ClientForMapping(mapping) if err != nil { return &Result{singular: true, err: err} } info := NewInfo(client, mappings[0], b.namespace, b.name) if err := info.Get(); err != nil { return &Result{singular: true, err: err} </del> <ins> visitors := []Visitor{} for _, name := range b.names { info := NewInfo(client, mapping, selectorNamespace, name) if err := info.Get(); err != nil { return &Result{singular: isSingular, err: err} } visitors = append(visitors, info) </ins> } <del> return &Result{singular: true, visitor: info, sources: []Visitor{info}} </del> <ins> return &Result{singular: isSingular, visitor: VisitorList(visitors), sources: visitors} </ins> } // visit items specified by paths