I am looking to see if I can connect to a remote minikube cluster (Ubuntu box) using local (Mac) kubectl. I currently use Docker and can do this very easily using docker-machine
. Simply eval to the machine name, and docker will use the remote machine.
I was wondering if there was anything similar for minikube/kubectl? I have found a few articles that mention that I need to copy my remote ~/.minikube
directory to my local, and change some config about. But this seems rather complicated for something a tool like docker-machine
does seamlessly.
Is there a similar tool available, or if not, could someone help me with steps needed to connect to a remote cluster?
Remote Machine
Currently I use the docker
driver (this is the complete output of the command, just the one line):
$ minikube config view
- driver: docker
And have a number of NodePort
services:
$ kubectl get service -A
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default apigateway NodePort 10.100.122.255 <none> 8080:30601/TCP 19h
default discoveryserver NodePort 10.101.106.231 <none> 8761:30602/TCP 19h
default elasticsearch NodePort 10.97.197.14 <none> 9200:30604/TCP 19h
default harness NodePort 10.97.233.245 <none> 9090:30603/TCP 19h
default kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 19h
default mongo NodePort 10.97.172.108 <none> 27017:32625/TCP 19h
kube-system kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 19h
$ kubectl config view
apiVersion: v1
clusters:
- cluster:
certificate-authority: /home/meanwhileinhell/.minikube/ca.crt
server: https://192.168.50.2:8443 <<<<<< `minikube ip`
name: minikube
contexts:
- context:
cluster: minikube
namespace: default
user: minikube
name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
user:
client-certificate: /home/meanwhileinhell/.minikube/profiles/minikube/client.crt
client-key: /home/meanwhileinhell/.minikube/profiles/minikube/client.key
Local machine
$ kubectl config view
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: DATA+OMITTED
server: https://kubernetes.docker.internal:6443
name: docker-desktop
- cluster:
certificate-authority: /Users/mih.mac/remote/.minikube/ca.crt
server: https://192.168.1.5:8443 <<<<<< Static IP of my remote machine
name: minikube
contexts:
- context:
cluster: docker-desktop
user: docker-desktop
name: docker-desktop
- context:
cluster: minikube
user: minikube
name: minikube
current-context: docker-desktop
kind: Config
preferences: {}
users:
- name: docker-desktop
user:
client-certificate-data: REDACTED
client-key-data: REDACTED
- name: minikube
user:
client-certificate: /Users/mih.mac/remote/.minikube/client.crt
client-key: /Users/mih.mac/remote/.minikube/client.key
There is no tool available. Way to remotely access minikube is to do SSH tunneling .
1- You need to be able to SSH from the Mac to the Ubuntu box.
2- Add appropriate SSH port forwarding flags.Run the following command
Where:
user is your name
public_ip is the public IP of your server
minikube_ip is the IP address of minikube, you can find it on the server using the command minikube ip. It will likely be 192.168.49.2.
3- Then just plug appropriate K8s credentials into kubectl on the Mac.
Please refer to the link for more information:
https://www.zepworks.com/posts/access-minikube-remotely-kvm/ https://www.chevdor.com/post/2021/02/docker_to_k8s/