I am learning Kubernetes Label Selector at the URL below.
https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
Set-based requirement
Set-based label requirements allow filtering keys according to a set of values. Three kinds of operators are supported: in, notin and exists (only the key identifier). For example:
! partition
The fourth(This) example selects all resources without a label with key partition; no values are checked.
My assumption is that if I specify "!test", all pods will be output, I think that nothing is output when "!app" is specified.
I want to exclude the key and output as in the example described here, but the expected result was not obtained.
My @ Pc: ~ / Understanding-K8s / chap04 $ kubectl get pod -l! app My@Pc:~/Understanding-K8s/chap04$ kubectl get pod -l !app -bash: !app: event not found My@Pc:~/Understanding-K8s/chap04$ kubectl get pod -l "!app" -bash: !app: event not found My@Pc:~/Understanding-K8s/chap04$ kubectl get pod -l "!test" -bash: !test: event not found My@Pc:~/Understanding-K8s/chap04$ kubectl get pod -l !test -bash: !test: event not found
The result of executing the --show-labels command is as follows.
My @ Pc: ~ / Understanding-K8s / chap04 $ kubectl get pod --show-labels NAME READY STATUS RESTARTS AGE LABELS nginx-pod-a 1/1 Running 0 89m app=photo-view,env=stage nginx-pod-b 1/1 Running 0 89m app=imagetrain,env=test nginx-pod-c 1/1 Running 0 89m app=prediction,env=test nginx-pod-d 1/1 Running 0 89m app=photo-view,env=stage nginx-pod-e 1/1 Running 0 89m app=imagetrain,env=stage nginx-pod-f 1/1 Running 0 89m app=photo-view,env=prod
How can I exclude the intended keys such as app and env?
https://stackoverflow.com/questions/66937893/i-want-to-output-the-result-of-kubectl-get-pod-excluding-the-key-using-labelse April 04, 2021 at 11:57AM
没有评论:
发表评论