Access Minikube Using Kubectl From Remote Machine
Check out this article if you want to learn how to access Minikube development cluster with kubectl client, just like your access Kubernetes cluster to test your deployments.
Join the DZone community and get the full member experience.Join For Free
What Is Minikube?
Minikube is a tool that makes it easy to run Kubernetes locally. It runs a single-node Kubernetes cluster inside a Virtual Machine (VM) on your laptop for users looking to try out Kubernetes or develop with it day-to-day.
If you do not have a minikube setup just use the below link to setup.
It will help you connect to the minikube API server and schedule deployments.
curl -LO "https://storage.googleapis.com/kubernetes-release/release/
$(curl -s https://storage.googleapis.com/kubernetes-release/release/
Apply Port Forwarding in Network Settings
Once the setup is done open the network setting of minikube in VirtualBox and adds port forwarding to 8443. Port 51928 is mapped to 8443 of minikube in network settings below.
The next step is to start a minikube. Take a note of the IP address of your machine, for me, it was 192.168.0.101.
minikube start — apiserver-ips=192.168.0.101
Copy the Certificates and Key Files To Remote Machine
Copy ca.crt, client.crt and client.key to the remote machine and it has kubectl client, they are marked as yellow below. Please note both machines should be on the same network.
Run Base64 Encode
On remote machine Base64 encode the 3 files ca.crt, client.crt and client.crt and create a config file(location of config file is $HOME/.kube/config) with following content.
- name: minikube
Replace Content of Following Keys With base64 Encoded Content in Kube Config File Above
certificate-authority-data: with base64 encoded ca.crt
client-certificate-data: with base64 encoded client.crt
client-key-data: with base64 encoded client.key
Access the Cluster
You can now run the kubectl command to access this minikube cluster.
Credits for help in starting minikube:
Opinions expressed by DZone contributors are their own.
Step Into Serverless Computing
Top Six React Development Tools
Adding Mermaid Diagrams to Markdown Documents
Decoding eBPF Observability: How eBPF Transforms Observability as We Know It