简体   繁体   English

配置 Kubectl 以连接到 local.network Kube.netes 集群

[英]Configure Kubectl to connect to a local network Kubernetes cluster

I'm trying to connect to a kube.netes cluster running on my Windows PC from my Mac.我正在尝试从我的 Mac 连接到在我的 Windows PC 上运行的 kube.netes 集群。 This is so I can continue to develop from my Mac but run everything on a machine with more resources.这样我就可以继续从我的 Mac 上开发,但在一台拥有更多资源的机器上运行所有东西。 I know that to do this I need to change the kubectl context on my Mac to point towards my Windows PC but don't know how to manually do this.我知道要做到这一点,我需要更改 Mac 上的 kubectl 上下文以指向我的 Windows PC,但不知道如何手动执行此操作。

When I've connected to a cluster before on AKS, I would use az aks get-credentials and this would correctly an entry to.kube/config and change the context to it.当我之前在 AKS 上连接到集群时,我会使用az aks get-credentials ,这会正确地进入 .kube/config 并将上下文更改为它。 I'm basically trying to do this but on a local.network.我基本上是在 local.network 上尝试这样做。

I've tried to add an entry into kubeconfig but get The connection to the server 192.168.1.XXX:6443 was refused - did you specify the right host or port?我试图在 kubeconfig 中添加一个条目,但得到The connection to the server 192.168.1.XXX:6443 was refused - did you specify the right host or port? . . I've also checked my antivirus on the Windows computer and no requests are getting blocked.我还在 Windows 计算机上检查了我的防病毒软件,没有请求被阻止。

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: {CERT}
    server: https://192.168.1.XXX:6443
  name: windows-docker-desktop
current-context: windows-docker-desktop
kind: Config
preferences: {}
users:
- name: windows-docker-desktop
  user:
    client-certificate-data: {CERT}
    client-key-data: {KEY}

I've also tried using kubectl --insecure-skip-tls-verify --context=windows-docker-desktop get pods which results in the same error: The connection to the server 192.168.1.XXX:6443 was refused - did you specify the right host or port?我也尝试过使用kubectl --insecure-skip-tls-verify --context=windows-docker-desktop get pods导致同样的错误: The connection to the server 192.168.1.XXX:6443 was refused - did you specify the right host or port? . .

Many thanks.非常感谢。

From your MAC try if the port is open: Like nc -zv 192.168.yourwindowsIp 6443. If it doest respond Open, you have a.network problem.从您的 MAC 尝试端口是否打开:如 nc -zv 192.168.yourwindowsIp 6443。如果它没有响应打开,则您有网络问题。 Try this.试试这个。

clusters:
- cluster:
    server: https://192.168.1.XXX:6443
    name: windows-docker-desktop
    insecure-skip-tls-verify: true

directly in the configfile直接在配置文件中

the set-context you dont need to specify as you have only one.您不需要指定的设置上下文,因为您只有一个。 To be sure it is not your firewall, disable it just for a very short period, only to test the conection.为确保它不是您的防火墙,请在很短的时间内禁用它,只是为了测试连接。

Last thing: Seems you are using Kube.netes in Docker-Desktop.最后一件事:您似乎在 Docker-Desktop 中使用 Kube.netes。 If not and you have a local cluster with more than 1 node, you need to install a.network fabric in your cluster like Flannel or Calico.如果没有,并且您有一个包含 1 个以上节点的本地集群,则需要在您的集群中安装一个网络结构,如 Flannel 或 Calico。 https://projectcalico.docs.tigera.io/about/about-calico https://github.com/flannel-io/flannel https://projectcalico.docs.tigera.io/about/about-calico https://github.com/flannel-io/flannel

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何配置本地 kubectl 连接到 kubernetes EKS 集群 - How to configure local kubectl to connect to kubernetes EKS cluster 如何在Kubernetes集群中配置Kubectl - How to configure kubectl in kubernetes cluster 在Windows上配置Kubectl以使用远程Kubernetes集群 - Configure kubectl to use a remote Kubernetes cluster on windows 无法kubectl连接我的kubernetes集群 - Unable to kubectl connect my kubernetes cluster 如何配置本地 kubectl 远程访问集群? - How to configure local kubectl to remote access to cluster? 配置kubectl命令访问azure上的远程kubernetes集群 - Configure kubectl command to access remote kubernetes cluster on azure 我的 kubernetes 集群 IP 地址已更改,现在 kubectl 将不再连接 - My kubernetes cluster IP address changed and now kubectl will no longer connect 配置 kubernetes 集群使用 OpenID Connect 认证 - Configure kubernetes cluster to use OpenID Connect Authentication Kubernetes pod 如何连接到与主机在同一本地网络(集群外)中运行的数据库? - How can a Kubernetes pod connect to database which is running in the same local network (outside the cluster) as the host? 不使用 gcloud 工具将 kubectl 的本地实例连接到 GKE 集群? - Connect local instance of kubectl to GKE cluster without using gcloud tool?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM