手动安装 Clusternet
本教程将引导您以“最硬核”的方式安装 Clusternet。 您也可以尝试参考 使用Helm安装’Clusternet'进行安装。
这种“最硬核”的方式便于您学习,并理解安装 Clusternet 所需要的每一个任务。
您需要在子集群中部署clusternet-agent,在父集群中部署clusternet-hub和clusternet-scheduler。
在父集群中部署 clusternet-hub
kubectl apply -f deploy/hub
Note on kube-apiserver
Please refer to Kubernetes Version Skew to see whether the Kubernetes versions are supported. Please also note that whether the kube-apiserver running in the parent cluster should be configured with flag--aggregator-reject-forwarding-redirect=false.接下来,您需要为群集注册创建一个 token,随后会被 clusternet-agent 使用到。bootstrap token 或 service account token都可以。
如果支持
bootstrapping身份验证,即在父集群中运行的kube-apiserver显式地设置了--enable-bootstrap-token-auth=true,# 这将创建一个 bootstrap token 07401b.f395accd246ae52d kubectl apply -f manifests/samples/cluster_bootstrap_token.yaml如果父集群中的
kube-apiserver不支持bootstrapping身份验证 (例如 k3s) ,--enable-bootstrap-token-auth=false(缺省为false),请改用serviceaccount token。# 这将创建一个 serviceaccount token kubectl apply -f manifests/samples/cluster_serviceaccount_token.yaml kubectl get secret -n clusternet-system -o=jsonpath='{.items[?(@.metadata.annotations.kubernetes\.io/service-account\.name=="cluster-bootstrap-use")].data.token}' | base64 --decode; echo # 这里将输出一个长字符串。请记住这一点。
在父集群中部署 clusternet-scheduler
kubectl apply -f deploy/scheduler
在父集群中部署 clusternet-controller-manager (从 v0.15.0 版本起)
kubectl apply -f deploy/controller-manager
在子集群中部署 clusternet-agent
clusternet-agent 在子群集中运行,并帮助将自群集注册到父群集。
clusternet-agent 可以配置以下三种 SyncMode (通过参数 --cluster-sync-mode配置),
Push表示父集群中的所有资源更改,都将由clusternet-hub自动同步、推送,并应用于子集群。Pull表示clusternet-agent将监视、同步和应用父群集中的所有资源更改到子群集。Dual结合了Push和Pull模式. 强烈建议使用此模式,通常和 特性功能AppPusher一起使用。
特性功能 AppPusher 在 agent 侧工作,主要出于以下两个原因引入,
SyncMode是不建议在注册后更改的, 这可能会导致设置和行为不一致。这就是为什么强烈建议使用Dual。 当设置Dual模式时,AppPusher提供帮助将Push模式切换到Pull模式的方法,而无需更改参数--cluster-sync-mode,反之亦然。用于安全问题,例如子群集安全风险等。
当子集群禁用特性功能
AppPusher,父集群不会向其部署任何应用程序, 即使设置了同步模式Push或Dual。 此时,此子群集的工作方式类似于Pull模式。要部署的资源表示为
Description,您也可以运行自己的控制器来观察变更Description对象,然后分发和部署资源。
在部署 clusternet-agent 的时候,应提前创建一个 secret 对象,包含着可用于集群注册的 token。
# 创建命名空间 clusternet-system(如果未创建)
kubectl create ns clusternet-system
# 这里我们使用上面创建的token
PARENTURL=https://192.168.10.10 REGTOKEN=07401b.f395accd246ae52d envsubst < ./deploy/templates/clusternet_agent_secret.yaml | kubectl apply -f -
:pushpin: :pushpin: Note:
如果您是通过service account token验证,请将 07401b.f395accd246ae52d 替换为之前生成的 token
上面的 PARENTURL 是您要注册到的父集群的 apiserver 地址, apiserver 地址必须以 https 开头。目前仅支持 https 。 如果 apiserver 服务器未侦听标准 https 端口 (:443), 请在 URL 中指定端口号,以确保代理连接到正确的端点,对于实例 https://192.168.10.10:6443。
# 如果需要选用其他同步模式,请修改以下 YAML 文件中的 SyncMode
kubectl apply -f deploy/agent
检查集群注册
请按照 本指南 检查集群注册状态。
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.