Chiranga Alwis:
Hi folks, under “151-Practice Test - KubeConfig”
• Question 13 - Shouldn’t we be using the KUBECONFIG
environment variable to set the default KubeConfig file reference? I was getting an incorrect answer after setting it in the ~/.bashrc
as well and noticed that the solution hint was suggesting replacement of all the content in the original default ~/.kube/config
.
unnivkn:
We don’t want to have to specify the kubeconfig file option on each command.
Make the my-kube-config file the default kubeconfig.
–Default kubeconfig file configured
–Hint:
Replace the contents in the default kubeconfig file with the content from my-kube-config file.
controlplane $ cd /root/.kube/
controlplane $ ls -ltr
total 12
-rw------- 1 root root 5567 Jan 29 02:08 config
drwxr-x— 4 root root 4096 Jan 29 02:08 cache
controlplane $
controlplane $ cp config bkp_config
controlplane $ ls -ltr
total 20
-rw------- 1 root root 5567 Jan 29 02:08 config
drwxr-x— 4 root root 4096 Jan 29 02:08 cache
-rw------- 1 root root 5567 Jan 29 02:58 bkp_config
controlplane $
controlplane $ cat /root/my-kube-config > config
controlplane $
controlplane $ ls -ltr
total 16
drwxr-x— 4 root root 4096 Jan 29 02:08 cache
-rw------- 1 root root 5567 Jan 29 02:58 bkp_config
-rw------- 1 root root 1380 Jan 29 02:59 config
controlplane $
controlplane $ vi config
controlplane $
Chiranga Alwis:
@unnivkn yeah I saw the hint in the question.
What I meant was instead of doing the above, isn’t setting the KUBECONFIG
environment variable the correct approach? Or is it there for merging multiple KubeConfigs?