杭州做網(wǎng)站的集團電商運營去哪里學(xué)比較好
文章目錄
- 一、設(shè)置主集群
- 方式一:使用 Web 控制臺
- 方式二:使用 Kubectl命令
- 二、在主集群中設(shè)置代理服務(wù)地址
- 方式一:使用 Web 控制臺
- 方式二:使用 Kubectl命令
- 三、登錄控制臺驗證
- 四、準備成員集群
- 方式一:使用 Web 控制臺
- 方式二:使用 Kubectl命令
- 五、導(dǎo)入成員集群
- 六、參考資料
一、設(shè)置主集群
如果已經(jīng)安裝了獨立的 KubeSphere 集群,可以編輯集群配置,將 clusterRole
的值設(shè)置為 host
。
方式一:使用 Web 控制臺
使用 admin
帳戶登錄控制臺,然后進入集群管理頁面上的定制資源定義,輸入關(guān)鍵字 ClusterConfiguration
,然后轉(zhuǎn)到其詳情頁面。編輯 ks-installer
的 YAML 文件。
方式二:使用 Kubectl命令
kubectl edit cc ks-installer -n kubesphere-system
multicluster:clusterRole: hosthostClusterName: kubesphere-master
PS:
hostClusterName: kubesphere-master
集群名稱需要跟主機名保存一致!!!
[root@kubesphere-master ~]# kubectl edit cc ks-installer -n kubesphere-system
clusterconfiguration.installer.kubesphere.io/ks-installer edited
在 kubectl 中執(zhí)行以下命令查看安裝過程:
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l 'app in (ks-install, ks-installer)' -o jsonpath='{.items[0].metadata.name}') -f
二、在主集群中設(shè)置代理服務(wù)地址
- 執(zhí)行以下命令來檢查服務(wù)。
kubectl -n kubesphere-system get svc
[root@kubesphere-master ~]# kubectl -n kubesphere-system get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ks-apiserver ClusterIP 10.233.57.31 <none> 80/TCP 126m
ks-console NodePort 10.233.47.149 <none> 80:30880/TCP 126m
ks-controller-manager ClusterIP 10.233.42.244 <none> 443/TCP 126m
minio ClusterIP 10.233.16.144 <none> 9000/TCP 78m
tower LoadBalancer 10.233.7.51 <pending> 8080:31899/TCP 4m10s
由于 EXTERNAL-IP
處于 pending
狀態(tài),需要手動設(shè)置代理地址。例如,如果公有 IP 地址為 139.198.120.120
,則需要將公網(wǎng) IP 的端口,如30721
轉(zhuǎn)發(fā)到 NodeIP
:NodePort
。
將 proxyPublishAddress
的值添加到 ks-installer
的配置文件中,并按如下所示輸入公有 IP 地址(此處示例 139.198.120.120
)和端口號。
方式一:使用 Web 控制臺
使用 admin
帳戶登錄控制臺,然后進入集群管理頁面上的定制資源定義,輸入關(guān)鍵字 ClusterConfiguration
,然后轉(zhuǎn)到其詳情頁面。編輯 ks-installer
的 YAML 文件。
方式二:使用 Kubectl命令
[root@kubesphere-master ~]# kubectl -n kubesphere-system edit clusterconfiguration ks-installer
clusterconfiguration.installer.kubesphere.io/ks-installer edited
在 kubectl 中執(zhí)行以下命令查看安裝過程:
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l 'app in (ks-install, ks-installer)' -o jsonpath='{.items[0].metadata.name}') -f
三、登錄控制臺驗證
發(fā)現(xiàn),此時該KubeSphere集群已成為主集群。
四、準備成員集群
為了通過主集群管理成員集群,需要使它們之間的 jwtSecret
相同。因此,首先需要在主集群中執(zhí)行以下命令來獲取它。
kubectl -n kubesphere-system get cm kubesphere-config -o yaml | grep -v "apiVersion" | grep jwtSecret
命令輸出結(jié)果如下所示:
jwtSecret: "93ObvPBzq1F1EEUZEydp6eJK8Cn0TqeZ"
如果已經(jīng)安裝了獨立的 KubeSphere 集群,可以編輯集群配置,將 clusterRole
的值設(shè)置為 member
。
方式一:使用 Web 控制臺
使用 admin
帳戶登錄控制臺,然后進入集群管理頁面上的定制資源定義,輸入關(guān)鍵字 ClusterConfiguration
,然后轉(zhuǎn)到其詳情頁面。編輯 ks-installer
的 YAML 文件。
方式二:使用 Kubectl命令
kubectl edit cc ks-installer -n kubesphere-system
- 在
ks-installer
的 YAML 文件中對應(yīng)輸入上面所示的jwtSecret
:
authentication:jwtSecret: 93ObvPBzq1F1EEUZEydp6eJK8Cn0TqeZ
- 向下滾動并將
clusterRole
的值設(shè)置為member
,然后點擊確定(如果使用 Web 控制臺)使其生效:
multicluster:clusterRole: member
按:wq
保存退出。
kubectl edit cc ks-installer -n kubesphere-system
clusterconfiguration.installer.kubesphere.io/ks-installer edited
在 kubectl 中執(zhí)行以下命令查看安裝過程:
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l 'app in (ks-install, ks-installer)' -o jsonpath='{.items[0].metadata.name}') -f
使用 kubectl 來獲取安裝日志以驗證狀態(tài)。運行以下命令,稍等片刻,如果成員集群已準備就緒,將看到成功的日志返回。
五、導(dǎo)入成員集群
以
admin
身份登錄 KubeSphere 控制臺,轉(zhuǎn)到集群管理頁面點擊添加集群。
在導(dǎo)入集群頁面輸入要導(dǎo)入的集群的基本信息。您也可以點擊右上角的編輯模式以 YAML 格式查看并編輯基本信息。編輯完成后,點擊下一步。
apiVersion: cluster.kubesphere.io/v1alpha1
kind: Cluster
spec:provider: Amazon EKSconnection:type: proxykubeconfig: ''joinFederation: true
metadata:name: xybeks-clusterannotations:kubesphere.io/alias-name: xybeks-clusterkubesphere.io/description: xybeks-clusterlabels:cluster.kubesphere.io/group: demo
在連接方式,選擇集群連接代理,然后點擊創(chuàng)建。主集群為代理部署 (Deployment) 生成的 YAML 配置文件會顯示在控制臺上。
根據(jù)指示在成員集群中
創(chuàng)建一個 agent.yaml
文件,然后將代理部署復(fù)制并粘貼到該文件中。在該節(jié)點上執(zhí)行 kubectl create -f agent.yaml
然后等待代理啟動并運行。請確保成員集群可以訪問代理地址。
[root@awseksec2 ~]# vim agent.yaml
[root@awseksec2 ~]# kubectl create -f agent.yaml
deployment.apps/cluster-agent created
待集群代理啟動并運行,會看到成員集群已經(jīng)導(dǎo)入主集群。
六、參考資料
🕹? 導(dǎo)入 AWS EKS 集群 (kubesphere.io)