I have a CentOS 7 VM, which has minikube running with --vm-driver=none
. On the VM itself, I can run kubectl commands to interact with the minikube cluster.
As I am new to k8s, I am not sure how to generate all the necessary values to put in the ~/.kube/config
file. My end goal is to interact with minikube cluster like my other AWS EKS clusters by using kubectl on my local machine.
To understand what you need in your local machine's ~/.kube/config
file, checkout the ~/.kube/config
file on the remote VM itself.
You'll find that you need to add these 3 items in your local machine's ~/.kube/config
file:
To add these 3 items, first you need to copy these 3 files from remote VM to your local machine:
~/.minikube/profiles/minikube/ca.crt
)~/.minikube/profiles/minikube/client.crt
)~/.minikube/profiles/minikube/client.key
)Now, you need to base64 encode these 3 files. For example, if you're on macOS, you can use this command:
base64 -i <input_file> -o <output_file>
Now you're ready to update your local machine's ~/.kube/config
file.
- cluster:
certificate-authority-data: <base64 of ca.crt file>
server: <same ip as remote VM's kubeconfig file, since you've used vm-driver=none>
name: minikube
- context:
cluster: minikube
user: minikube
name: minikube
- name: minikube
user:
client-certificate-data: <base64 of client.crt file>
client-key-data: <base64 of client.key file>