简体   繁体   English

来自kubectl的“找不到资源”获取远程集群

[英]“No resources found” from kubectl get for remote cluster

I have kubectl configured for a multi-cluster setup involving local Kubernetes that comes with Docker Mac and a remote cluster using Minikube. 我已经为kubectl配置了一个多集群设置,涉及Docker Mac随附的本地Kubernetes和使用Minikube的远程集群。 When I switch context to my remote cluster kubectl can't find any resources like pods or services. 当我将上下文切换到我的远程集群时,kubectl无法找到任何资源,如pod或服务。 Where can I look at logs to find out more? 我在哪里可以查看日志以了解更多信息? I do see the resources if I run kubectl on the actual remote machine. 如果我在实际的远程机器上运行kubectl,我确实看到了资源。

When I execute kubectl version I get this: 当我执行kubectl version我得到这个:

Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:38:32Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.3", GitCommit:"721bfa751924da8d1680787490c54b9179b1fed0", GitTreeState:"clean", BuildDate:"2019-02-01T20:00:57Z", GoVersion:"go1.11.5", Compiler:"gc", Platform:"linux/amd64"}

kubectl get componentstatus returns: kubectl get componentstatus返回:

NAME                 STATUS    MESSAGE              ERROR
scheduler            Healthy   ok                   
controller-manager   Healthy   ok                   
etcd-0               Healthy   {"health": "true"}

kubectl cluster-info returns: kubectl cluster-info返回:

Kubernetes master is running at https://remote-cluster-ip:8443
KubeDNS is running at https://remote-cluster-ip:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

Executing kubectl cluster-info dump produces a ton of output. 执行kubectl cluster-info dump会产生大量输出。

I followed these steps to get Minikube working and successfully deployed a sample app. 我按照这些步骤使Minikube工作并成功部署了一个示例应用程序。 https://kubernetes.io/docs/setup/minikube/ https://kubernetes.io/docs/setup/minikube/

I followed these steps for multi-cluster config: https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/ 我按照以下步骤进行了多集群配置: https : //kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/

I copied over all the crt and key files from .minikube to my local machine for use in the config. 我将.minikube上的所有crt和密钥文件复制到我的本地计算机上,以便在配置中使用。 Here is my redacted config: 这是我的编辑配置:

apiVersion: v1
clusters:
- cluster:
    insecure-skip-tls-verify: true
    server: https://localhost:6443
  name: docker-for-desktop-cluster
- cluster:
    insecure-skip-tls-verify: true
    server: https://remote-cluster-ip:8443
  name: remote-cluster
contexts:
- context:
    cluster: docker-for-desktop-cluster
    user: docker-for-desktop
  name: docker-for-desktop
- context:
    cluster: remote-cluster
    namespace: remote-cluster
    user: minikube
  name: remote-cluster
current-context: remote-cluster
kind: Config
preferences: {}
users:
- name: docker-for-desktop
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED
- name: minikube
  user:
    client-certificate: /path/to/local/client.crt
    client-key: /path/to/local/client.key

Run kubectl get pods --all-namespaces to check if you can see pods across all namespaces. 运行kubectl get pods --all-namespaces以检查是否可以看到所有命名空间中的pods。 If you see your pods are running, than you have to set up a default namespace for your current context, ie 如果您看到您的pod正在运行,则必须为当前上下文设置默认命名空间,即

kubectl config set-context <remote-context-name> --namespace=default

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM