kubernetes: kubectl --local is not quite local across all the commands
This situation was discovered when I wanted to remove deprecated functionality in https://github.com/kubernetes/kubernetes/pull/90243. Unfortunately, due to how we are constructing client in almost every kubectl command this removal ended up with the following bug https://github.com/kubernetes/kubernetes/issues/90074.
The reason for that is that in each command’s Complete
method we create a client in one of the following ways:
o.Client, err = batchv1client.NewForConfig(clientConfig)
if err != nil {
return err
}
dynamicClient, err := f.DynamicClient()
if err != nil {
return err
}
discoveryClient, err := f.ToDiscoveryClient()
if err != nil {
return err
}
The problem is that with the deprecated code from #90243 removed all of the above calls will fail when creating a client with:
error: Missing or incomplete configuration info. Please point to an existing, complete config file:
1. Via the command-line flag --kubeconfig
2. Via the KUBECONFIG environment variable
3. In your home directory as ~/.kube/config
which does not happen if we silently default the server to http://localhost:8080
in deprecated getDefaultServer
.
There are two possible approaches to this problem:
- Go through each and every single command and add conditions for
--local
flag and not to create clients when it is specified. - Provide a smart mechanism allowing to inject dependencies (in this particular case, we are talking about clients).
During SIG-CLI call on July 15th, we agreed that solution 1 is a short-term and rather hacky approach to the problem and we would like to see this being approached as described in no. 2.
Any proposals to this should be discussed with @soltysh or during one of sig-cli calls.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 25 (14 by maintainers)
let us collaborate 😃
@soltysh Sir, is there anyone working on this?