Mea*_*ell 5 remote-access docker kubernetes minikube
我想看看是否可以使用本地(Mac)kubectl 连接到远程 minikube 集群(Ubuntu 盒子)。我目前使用 Docker,并且可以使用docker-machine
. 只需评估机器名称,docker 就会使用远程机器。
我想知道 minikube/kubectl 是否有类似的东西?我发现一些文章提到我需要将远程~/.minikube
目录复制到本地,并更改一些配置。但这对于像这样的工具docker-machine
无缝完成的事情来说似乎相当复杂。
是否有类似的工具可用,或者如果没有,有人可以帮助我完成连接到远程集群所需的步骤吗?
远程机器
目前我使用docker
驱动程序(这是命令的完整输出,只有一行):
$ minikube config view
- driver: docker
Run Code Online (Sandbox Code Playgroud)
并拥有多项NodePort
服务:
$ 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
Run Code Online (Sandbox Code Playgroud)
$ 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
Run Code Online (Sandbox Code Playgroud)
本地机
$ 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
Run Code Online (Sandbox Code Playgroud)
小智 5
没有可用的工具。远程访问 minikube 的方法是进行 SSH 隧道。
1-您需要能够从 Mac 到 Ubuntu 盒子进行 SSH。
2- 添加适当的 SSH 端口转发标志。运行以下命令
ssh -N -p 22 <user>@<public_ip> -L 127.0.0.1:18443:<minikube_ip>:8443
Run Code Online (Sandbox Code Playgroud)
在哪里:
用户是你的名字
public_ip 是你服务器的公网IP
minikube_ip 是 minikube 的 IP 地址,您可以使用命令 minikube ip 在服务器上找到它。可能是 192.168.49.2。
3-然后只需将适当的 K8s 凭据插入 Mac 上的 kubectl 中。
请参阅链接了解更多信息:
https://www.zepworks.com/posts/access-minikube-remotely-kvm/ https://www.chevdor.com/post/2021/02/docker_to_k8s/
归档时间: |
|
查看次数: |
6037 次 |
最近记录: |