我需要知道当前工作节点连接的是哪个主节点。我可以在主节点上输入“kubectl get nodes”命令来查看工作节点,但我需要从工作节点本身找到主节点。
简单来说,在Kubernetes集群中如何从工作节点找到主节点?
我需要知道当前工作节点连接的是哪个主节点。我可以在主节点上输入“kubectl get nodes”命令来查看工作节点,但我需要从工作节点本身找到主节点。
简单来说,在Kubernetes集群中如何从工作节点找到主节点?
/etc/kubernetes/kubelet.conf
配置文件中找到它。该文件通常包含与kubelet
相关的信息。$ cat /etc/kubernetes/kubelet.conf
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: REDACTED
server: https://1.1.1.1:6443 <== here
name: default-cluster
contexts:
- context:
cluster: default-cluster
namespace: default
user: default-auth
name: default-context
current-context: default-context
kind: Config
preferences: {}
users:
- name: default-auth
user:
client-certificate: /var/lib/kubelet/pki/kubelet-client-current.pem
client-key: /var/lib/kubelet/pki/kubelet-client-current.pem
如果您有类似于yq
的东西,可以按如下方式获取:
yq .clusters[0].cluster.server /etc/kubernetes/kubelet.conf | tr -d "\n\""
gcloud container clusters get-credentials kafka-and-zookeepr --zone us-central1-a --project {YOUR_PROJECT_NAME}
kubectl cluster-info
Kubernetes master is running at https://xxx.xxx.xxx.xxx
GLBCDefaultBackend is running at https://xxx.xxx.xxx.xxx/api/v1/namespaces/kube-system/services/default-http-backend:http/proxy
Heapster is running at https://xxx.xxx.xxx.xxx/api/v1/namespaces/kube-system/services/heapster/proxy
KubeDNS is running at https://xxx.xxx.xxx.xxx/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://xxx.xxx.xxx.xxx/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy
类型
kubectl get nodes -o wide
并检查ROLES选项卡
/var/lib/kubelet/kubeconfig
。我通过检查/etc/default/kubelet
找到了它。 - Alex