使用不同的选项重新启动 Kubernetes API 服务器

Restart Kubernetes API server with different options

我对 Kubernetes 和集群还很陌生,所以这可能非常简单。

我在 this guide. I got some issues but it all worked in the end. So now I want to install the Web UI (Dashboard) 之后使用 kubeadm 设置了一个包含 5 个节点的 Kubernetes 集群。为此,我需要设置身份验证:

Please note, this works only if the apiserver is set up to allow authentication with username and password. This is not currently the case with the some setup tools (e.g., kubeadm). Refer to the authentication admin documentation for information on how to configure authentication manually.

所以我必须阅读 authentication page of the documentation. And I decided I want to add authentication via a Static Password File。为此,我必须将选项 --basic-auth-file=SOMEFILE 附加到 Api 服务器。

当我执行 ps -aux | grep kube-apiserver 时,这是结果,所以它已经是 运行。 (这是有道理的,因为我在调用 kubectl 时使用它)

kube-apiserver 
  --insecure-bind-address=127.0.0.1
  --admission-control=NamespaceLifecycle,LimitRanger,ServiceAccount,PersistentVolumeLabel,DefaultStorageClass,ResourceQuota 
  --service-cluster-ip-range=10.96.0.0/12 
  --service-account-key-file=/etc/kubernetes/pki/apiserver-key.pem 
  --client-ca-file=/etc/kubernetes/pki/ca.pem 
  --tls-cert-file=/etc/kubernetes/pki/apiserver.pem 
  --tls-private-key-file=/etc/kubernetes/pki/apiserver-key.pem 
  --token-auth-file=/etc/kubernetes/pki/tokens.csv 
  --secure-port=6443 
  --allow-privileged 
  --advertise-address=192.168.1.137
  --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname 
  --anonymous-auth=false 
  --etcd-servers=http://127.0.0.1:2379

我有几个问题:

/etc/kubernetes/manifests 中是一个名为 kube-apiserver.json 的文件。这是一个 JSON 文件,包含您可以设置的所有选项。我附加了 --basic-auth-file=SOMEFILE 并重新启动了系统(在文件 kubectl 更改后立即不再工作并且 API 被关闭)

重启后整个系统又能正常工作了。

更新

我没能 运行 使用这个仪表板。我最后所做的是在集群上安装仪表板。将密钥从主节点 (/etc/kubernetes/admin.conf) 复制到我的笔记本电脑,并 kubectl proxy 将仪表板的流量代理到我的本地计算机。现在我可以通过 127.0.0.1:8001/ui

在笔记本电脑上访问它

我刚刚发现这个用于类似的用例,API 服务器在添加带有文件路径的选项后崩溃。

我能够解决它,也许这对其他人也有帮助:

https://kubernetes.io/docs/reference/setup-tools/kubeadm/implementation-details/#constants-and-well-known-values-and-paths 中所述,/etc/kubernetes/manifests 中的文件是静态 pod 定义。因此容器规则适用。

因此,如果您添加带有文件路径的选项,请确保将其提供给具有 hostPath 卷的容器。