Przemek Tyrkiel:
Hi, another question - in lab practice-test-kubeconfig-4`` question 13 - user is asked to
make my-kube-config file the default kubeconfig. Only accepted answer (and suggested by hint) is to replace default
kubeconfigcontent with values taken from
my-kube-config. However I think it can also be done by exporting
$KUBECONFIG (
export KUBECONFIG=/root/my-kube-config`). Shouldn’t it be also accepted?
Mohamed Ayman:
Hello @Przemek Tyrkiel,
Yes, you are right, it can be done using the $KUBECONFIG variable, but the lab validates the content of the kubeconfig file.
Thanks,
KodeKloud Support
Przemek Tyrkiel:
Could it be extended to also look for $KUBECONFIG
variable? That would be in-sync with documentation/help:
Modify kubeconfig files using subcommands like "kubectl config set current-context my-context"
The loading order follows these rules:
1. If the --kubeconfig flag is set, then only that file is loaded. The flag may only be set once and no merging takes
place.
2. If $KUBECONFIG environment variable is set, then it is used as a list of paths (normal path delimiting rules for
your system). These paths are merged. When a value is modified, it is modified in the file that defines the stanza. When
a value is created, it is created in the first file that exists. If no files in the chain exist, then it creates the
last file in the list.
3. Otherwise, ${HOME}/.kube/config is used and no merging takes place.
Mohamed Ayman:
Great! Thanks for sharing!