kubernetes: kubectl delete --all: does not include uninitialized resources
tl;dr Similar to #49032, kubectl delete --all
command does not delete the uninitialized resources. It appears like it does not query the resource list with ?includeUninitialized=true
in the first place.
Combined with #49032, these two issues prevents users from seeing or deleting uninitialized resources.
Update: Proposed solution in comments
See https://github.com/kubernetes/kubernetes/issues/49035#issuecomment-320809074 for the proposed course of action.
Repro steps
-
Have kubectl 1.7 cluster with --runtime-config=admissionregistration.k8s.io/v1alpha1 enabled.
-
Apply the initializer configuration below
apiVersion: admissionregistration.k8s.io/v1alpha1 kind: InitializerConfiguration metadata: name: example-config initializers: - name: podimage.example.com rules: - apiGroups: - "" apiVersions: - v1 resources: - pods
-
Run some pods:
kubectl run web --image=nginx --port 80 --replicas=5
kubectl get pods
won’t show anything due to #49032
-
Make API call with client-go listing pods (use
metav1.ListOptions{IncludeUninitialized: true}
and observe pods actually exist -
kubectl delete pods --all
doesn’t delete anything (prints “No resources found”). Running with -v=10 reveals:I0717 10:30:16.470350 76682 round_trippers.go:405] GET https://35.184.184.151/api/v1/namespaces/default/pods 200 OK in 40 milliseconds I0717 10:30:16.470373 76682 round_trippers.go:411] Response Headers: I0717 10:30:16.470378 76682 round_trippers.go:414] Content-Type: application/json I0717 10:30:16.470382 76682 round_trippers.go:414] Content-Length: 131 I0717 10:30:16.470386 76682 round_trippers.go:414] Date: Mon, 17 Jul 2017 17:30:16 GMT I0717 10:30:16.470413 76682 request.go:991] Response Body: {"kind":"PodList","apiVersion":"v1","metadata":{"selfLink":"/api/v1/namespaces/default/pods","resourceVersion":"4801"},"items":[]}
-
kubectl delete pod NAME
works (given you found out the names by querying the API directly with client-go)
kubectl version: 1.7.1
/sig cli /area bug
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 29 (29 by maintainers)
Before we add the flag, we should ask what users expect. I think users expect
kubectl delete pods --all
to delete uninitialized pods, as mentioned before.I think
kubectl get pods --show-all
should also show uninitialized.PR was mostly lgtm yesterday, so we are on the right track.
@ahmetb
Yes. Commands that spell out instance names (either via stdin or in the config file) should always include uninitialized objects.
--include-uninitialized
shouldn’t affect such commands at all.The entire proposal is about commands that use the LIST verb. The apiserver only hides uninitialized objecs from LIST operaions. Only
listOptions
has theincludeUninitialized
option.No. Both should includes uninitialized objects.
--include-uninitialized
doesn’t affect them at all.