How to access local kubernetes minicub panels remotely

Kubernetes question about newcomers (or rather, basic): A single node mini-cube (release 0.23) is installed in an ubuntu box running in my language (at IP address 192.168.0.20) using a virtual box.

Minikube launch command also completed successfully

minikube start Starting local Kubernetes v1.8.0 cluster... Starting VM... Getting VM IP address... Moving files into cluster... Setting up certs... Connecting to cluster... Setting up kubeconfig... Starting cluster components... Kubectl is now configured to use the cluster. 

The minikube toolbar is also a success. (works on 192.168.99.100{0000)

what i want to do is access the minikube toolbar from my macbook (runs on 192.168.0.11) on the same local network.

I also want to access the same minikube dashboard from the Internet.

To access the local network: Now, from what I understand, I use virtualbox (the default vm option), I can change the network type (to NAT with port forwarding) using the vboxnet command

 VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22" 

as indicated here

In my case it will be something like this

 VBoxManage modifyvm "VM name" --natpf1 "guesthttp,http,,30000,,8080" 

Am I thinking of the correct lines here?

Also, for remote access to the same panel address of the mini-switch, I can configure the no-ip.com service as a service. They asked to install their utility in the linux box, as well as configure port forwarding in the router settings, which will be redirected from the host port to the guest port. It's right? Did I miss something?

+15
source share
7 answers

I was able to run with something simple:

 kubectl proxy --address='0.0.0.0' --disable-filter=true 
+23
source

Ssh method

Suppose you have ssh in your ubuntu block.

First run kubectl proxy & to open the control panel at http://localhost:8001

Then display the control panel using ssh port forwarding by doing:

ssh -R 30000:127.0.0.1:8001 $USER@192.168.0.20

Now you must access the control panel from your macbook on your local network by pointing the browser to http://192.168.0.20:30000

To open it from the outside, simply output port 30000 using no-ip.com, perhaps change it to some standard port, for example 80.

Please note that this is not the easiest solution, but in some places it would work without superuser rights;) You can automate the login after restarting the ubuntu window using the init script and setting the public key for the connection.

+12
source

@ Jeff gave the perfect answer, give more tips to newbies.

  1. Launch the proxy server using the @Jeff script, by default it will open the proxy server at 0.0.0.0:8001.

     kubectl proxy --address='0.0.0.0' --disable-filter=true 
  2. Visit the toolbar at the link below:

     curl http://your_api_server_ip:8001/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/ 

You can find more detailed information in the official document .

+10
source

I recently had the same problem and solved it as follows:

  1. Connect the Minikube virtual machine to the local network by adding another network adapter in bridge network mode. For me, this was done by modifying the minikube virtual machine in the VirtualBox user interface and required stopping / starting the virtual machine. Not sure how this will work if you use hyperkit. Do not mess with the default network adapters configured by minikube: minikube depends on them. https://github.com/kubernetes/minikube/issues/1471
  2. If you have not already done so, install kubectl on your Mac: https://kubernetes.io/docs/tasks/tools/install-kubectl/
  3. Add the cluster and associated configuration to ~/.kube/config , as shown below, changing the server IP address to match your newly set virtual machine IP address. Names can also be changed if desired. Note that insecure-skip-tls-verify: true necessary because the https certificate generated by minikube is valid only for the internal IP addresses of the virtual machine.

     clusters: - cluster: insecure-skip-tls-verify: true server: https://192.168.0.101:8443 name: mykubevm contexts: - context: cluster: mykubevm user: kubeuser name: mykubevm users: - name: kubeuser user: client-certificate: /Users/myname/.minikube/client.crt client-key: /Users/myname/.minikube/client.key 
  4. Copy the ~/.minikube/client.* Files referenced in the configuration from your Linux Minikube host. These are the security key files required for access.

  5. Set the kubectl context: kubectl config set-context mykubevm . At this point, your minicub cluster should be accessible (try kubectl cluster-info ).

  6. Run kubectl proxy http://localhost:8000 to create a local proxy to access the dashboard. Go to this address in your browser.

It is also possible ssh to a minicube VM. Copy the ssh key pair from ~/.minikube/machines/minikube/id_rsa* to the .ssh directory (rename to avoid deleting other keys, for example mykubevm and mykubevm.pub ). Then ssh -i ~/.ssh/mykubevm docker@ <kubevm-IP>

+7
source

Minor changes in approach above.

I have an http web service with NodePort 30003. I make it available through port 80 by running:

sudo ssh -v -i ~/.ssh/id_rsa -N -L 0.0.0.0:80:localhost:30003 ${USER}@$(hostname)

+1
source

Jeff Pruty added a useful answer:

I was able to run something as simple as:

kubectl proxy --address='0.0.0.0' --disable-filter=true

But for me, this did not work initially.

I run this command on a CentOS 7 computer running kubectl (local IP: 192.168.0.20).

When I tried to access the dashboard from another computer (which was obviously on the local network):

 http://192.168.0.20:8001/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy/ 

then in my web browser there was only a timeout.

The solution for my case is that on CentOS 7 (and possibly other distributions) you need to open port 8001 in the OS firewall.

So in my case I need to work in a CentOS 7 terminal:

  sudo firewall-cmd --zone=public --add-port=8001/tcp --permanent sudo firewall-cmd --reload 

And after that. It is working! :)

Of course, you should know that this is an unsafe solution, because now someone has access to your toolbar. But I think that will be enough for local laboratory testing.

In other Linux distributions, the command for opening ports in the firewall may be different. Please use Google for this.

0
source

Thanks for your valuable answers. If you need to use the kubectl proxy command, which cannot be viewed all the time, use the "Service" object below in the YAML file, which can be viewed remotely until you stop it. Create a new yaml file minikube minikube-dashboard.yaml and write the code manually, I do not recommend copying and pasting it.

 apiVersion : v1 kind: Service metadata: labels: app: kubernetes-dashboard name: kubernetes-dashboard-test namespace: kube-system spec: ports: - port: 80 protocol: TCP targetPort: 9090 nodePort: 30000 selector: app: kubernetes-dashboard type: NodePort 

Run the command

 $ sudo kubectl apply -f minikube-dashboard.yaml 

Finally, open the URL: http: // your-public-ip-address: 30000 / #! / Persistentvolume? Namespace = default

0
source

Source: https://habr.com/ru/post/1273198/


All Articles