Merge pull request #32599 from mikedanese/kubectl-selector

Automatic merge from submit-queue

allow kubectl -f to filter by selector

cc @kubernetes/kubectl

Fixes #32544
This commit is contained in:
Kubernetes Submit Queue
2016-10-01 01:13:09 -07:00
committed by GitHub
6 changed files with 112 additions and 21 deletions

View File

@@ -992,6 +992,21 @@ __EOF__
# Clean up
kubectl delete pods test-pod "${kube_flags[@]}"
## kubectl apply -f with label selector should only apply matching objects
# Pre-Condition: no POD exists
kube::test::get_object_assert pods "{{range.items}}{{$id_field}}:{{end}}" ''
# apply
kubectl apply -l unique-label=bingbang -f hack/testdata/filter "${kube_flags[@]}"
# check right pod exists
kube::test::get_object_assert 'pods selector-test-pod' "{{${labels_field}.name}}" 'selector-test-pod'
# check wrong pod doesn't exist
output_message=$(! kubectl get pods selector-test-pod-dont-apply 2>&1 "${kube_flags[@]}")
kube::test::if_has_string "${output_message}" 'pods "selector-test-pod-dont-apply" not found'
# cleanup
kubectl delete pods selector-test-pod
## kubectl run should create deployments or jobs
# Pre-Condition: no Job exists
kube::test::get_object_assert jobs "{{range.items}}{{$id_field}}:{{end}}" ''