Currently prefix match logic is only implemented in kubectl describe and it seems not complete and not strong enough. Other command such as kubectl get, kubectl edit, kubectl exec especially kubectl logs do not have this feature.But this has been requested for a long time since 2015 and I think this is really useful if you use kubectl heavily.
This KEP describes how to implement prefix match globally in kubectl.
MotivationThe main motivation for doing this is due to the following two use cases.
use case1: save the keyboard!Let's say we are a developing a crd controller called my-super-awesome-crd-controller. After we deployed it to my namespace which is named my-namespace, we want to see if it is running, we will type the following command which contain 66 letters.bash kubectl get deploy -n my-namespace my-super-awesome-crd-controller
But if we have prefix this would be:bash kubectl get deploy -n my-namespace my
use case2: make command repeatableAnd in development env, we always need to see instant logs using kubectl logs -f.
It needs two commands since pod name changes everytime we start a new one.It maybe stupid, but it is quite straight forward.
If we are familiar with awk we maybe smarter:
Or we may use label selector but still a lot of letters to type.
If we have prefix, this would be much easier
Although moby/containerd and kubernetes are totally different project, some usage habits are similar.And in the communicate there are other life saving repo are very popular, like autojump.
Let take moby at a look.docker inspect docker exec docker logsdocker load all support prefix shortcut which is really convenient.
We could make the following commands recognize prefix: - kubectl get - kubectl edit - kubectl exec - kubectl logs
If the for the same prefix etcd returns multi records we may simply return error.
Risks and MitigationsWe should consider about if this will mislead user to make action on unwanted resources. Or add a command line flag to turn this on or off.
Design DetailsTODO I will add this after discuss.
AlternativesWe could use zsh autocomplete plugin to accomplish this but it has two fallback:
--
You received this message because you are subscribed to the Google Groups "kubernetes-sig-cli" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-sig-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kubernetes-sig-cli/43477517-5126-4cb5-8f5d-97b85f448264n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kubernetes-sig-cli/CAB_J3bYk5s_ca-a9XLorT7V5n1PkH-Xi6w0yEuVxXapCU9gwmg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kubernetes-sig-cli/CAL7FtguH595kraZgzzim4%3D-2fnqGKvhVgr7PCge7dLLEc0H5NA%40mail.gmail.com.