kubernetes管理工具
kubegems
环境说明
[root@k8s-master01 ~]# kubectl get node -owide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
k8s-master01 Ready master 102d v1.23.8 192.168.10.10 <none> CentOS Linux 7 (Core) 4.19.12-1.el7.elrepo.x86_64 containerd://1.6.6
k8s-master02 Ready <none> 102d v1.23.8 192.168.10.20 <none> CentOS Linux 7 (Core) 4.19.12-1.el7.elrepo.x86_64 containerd://1.6.6
k8s-master03 Ready <none> 102d v1.23.8 192.168.10.30 <none> CentOS Linux 7 (Core) 4.19.12-1.el7.elrepo.x86_64 containerd://1.6.6
k8s-node01 Ready <none> 102d v1.23.8 192.168.10.40 <none> CentOS Linux 7 (Core) 4.19.12-1.el7.elrepo.x86_64 containerd://1.6.6
k8s-node02 Ready <none> 102d v1.23.8 192.168.10.50 <none> CentOS Linux 7 (Core) 4.19.12-1.el7.elrepo.x86_64 containerd://1.6.6
k8s-node03 Ready <none> 102d v1.23.8 192.168.10.60 <none> CentOS Linux 7 (Core) 4.19.12-1.el7.elrepo.x86_64 containerd://1.6.6
已排坑指南
下载文件
[root@k8s-master01 ~]# wget https://github.com/kubegems/kubegems/raw/main/deploy/installer.yaml
[root@k8s-master01 ~]# wget https://raw.githubusercontent.com/kubegems/kubegems/main/deploy/addon-local-path-provisioner.yaml
[root@k8s-master01 ~]# wget https://raw.githubusercontent.com/kubegems/kubegems/main/deploy/kubegems.yaml
部署 installer
[root@k8s-master01 ~]# kubectl create namespace kubegems-installer
namespace/kubegems-installer created
[root@k8s-master01 ~]# kubectl apply -f installer.yaml
customresourcedefinition.apiextensions.k8s.io/plugins.plugins.kubegems.io created
serviceaccount/kubegems-installer created
secret/plugin-repository-kubegems created
secret/plugin-repository-local created
clusterrole.rbac.authorization.k8s.io/kubegems-installer-view created
clusterrole.rbac.authorization.k8s.io/kubegems-installer-edit created
clusterrolebinding.rbac.authorization.k8s.io/kubegems-installer created
deployment.apps/kubegems-installer created
[root@k8s-master01 ~]# kubectl -n kubegems-installer get po
NAME READY STATUS RESTARTS AGE
kubegems-installer-58b7959f7-vqhs8 1/1 Running 0 22s
kubegems 需要持久化一些重要数据,需要集群有可用的 CSI 插件
如果没有 CSI 插件,可以安装 local-path-provisioner
安装 local-path-provisioner
[root@k8s-master01 ~]# kubectl create namespace local-path-storage
namespace/local-path-storage created
[root@k8s-master01 ~]# kubectl apply -f addon-local-path-provisioner.yaml
plugin.plugins.kubegems.io/local-path-provisioner created
部署 kubegems 核心组件
[root@k8s-master01 ~]# kubectl create namespace kubegems
namespace/kubegems created
[root@k8s-master01 ~]# cat kubegems-mirror.yaml | grep local-path
storageClass: local-path # change me to use a production storage class # 改为您使用的 storageClass
[root@k8s-master01 ~]# cat kubegems-mirror.yaml | grep latest
kubegemsVersion: latest # change to specify kubegems version 改为上面查看的最新稳定版本或其他版本
修改后
kubegemsVersion: v1.21.6
[root@k8s-master01 ~]# mv kubegems-mirror.yaml kubegems.yaml
[root@k8s-master01 ~]# kubectl apply -f kubegems.yaml
plugin.plugins.kubegems.io/kubegems created
kubegems CR 下发后,大约需要 5 分钟才会一切正常,这取决于您的具体配置。
[root@k8s-master01 ~]# kubectl -n kubegems get pod
NAME READY STATUS RESTARTS AGE
kubegems-api-767bbdcb9c-9cqmx 1/1 Running 4 (2m ago) 3m41s
kubegems-argo-cd-app-controller-57c756777c-h65ns 1/1 Running 0 3m41s
kubegems-argo-cd-repo-server-84bc9df4cd-mv4hz 1/1 Running 0 3m41s
kubegems-argo-cd-server-58d6ccc99-cm2vd 1/1 Running 0 3m41s
kubegems-chartmuseum-74d498759c-k7md5 1/1 Running 0 3m41s
kubegems-charts-init-v1.21.6-wjtp5 0/1 Completed 0 3m41s
kubegems-dashboard-56f6dc755d-jrwjx 1/1 Running 0 3m41s
kubegems-gitea-0 1/1 Running 0 3m41s
kubegems-init-v1.21.6-kb9lk 0/1 Completed 4 3m41s
kubegems-msgbus-785dcf5d96-hswf9 1/1 Running 4 (2m31s ago) 3m41s
kubegems-mysql-0 1/1 Running 0 3m41s
kubegems-redis-master-0 1/1 Running 0 3m41s
kubegems-worker-7d6ffc5546-nhpmr 1/1 Running 4 (2m8s ago) 3m41s
访问 kubegems 仪表板 更改ClusterIP为NodePort
[root@k8s-master01 ~]# kubectl get svc -n kubegems
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubegems-api ClusterIP 10.96.112.136 <none> 80/TCP,9100/TCP 4m57s
kubegems-argo-cd-app-controller ClusterIP 10.96.3.156 <none> 8082/TCP 4m57s
kubegems-argo-cd-repo-server ClusterIP 10.96.35.228 <none> 8081/TCP 4m57s
kubegems-argo-cd-server ClusterIP 10.96.61.151 <none> 80/TCP,443/TCP 4m58s
kubegems-chartmuseum ClusterIP 10.96.191.82 <none> 8080/TCP 4m58s
kubegems-dashboard ClusterIP 10.96.100.5 <none> 80/TCP,9100/TCP 4m57s
kubegems-gitea-http ClusterIP None <none> 3000/TCP 4m58s
kubegems-gitea-ssh ClusterIP None <none> 22/TCP 4m58s
kubegems-msgbus ClusterIP 10.96.138.2 <none> 80/TCP,9100/TCP 4m57s
kubegems-mysql ClusterIP 10.96.153.164 <none> 3306/TCP 4m58s
kubegems-mysql-headless ClusterIP None <none> 3306/TCP 4m58s
kubegems-redis-headless ClusterIP None <none> 6379/TCP 4m58s
kubegems-redis-master ClusterIP 10.96.1.98 <none> 6379/TCP 4m57s
kubegems-worker ClusterIP 10.96.210.182 <none> 80/TCP,9100/TCP 4m58s
[root@k8s-master01 ~]# kubectl -n kubegems edit plugins.plugins.kubegems.io kubegems
plugin.plugins.kubegems.io/kubegems edited
或
[root@k8s-master01 ~]# kubectl edit svc -n kubegems kubegems-dashboard
访问kubegems
user: admin
password: demo!@#admin
添加集群
文件内容填
[root@k8s-master01 ~]# cat .kube/config
也可能为/etc/kubernetes/admin.conf或/etc/kubernetes/admin.yaml
Rancher
选择要安装的版本,这里选择稳定版 Stable
- 试用版 Latest
- 稳定版 Stable
- 测试版 Alpha
安装Helm
由于安装需要用helm包管理工具,已安装的可以忽略
[Helm GitHub](https://github.com/helm/helm/releases)
[root@k8s-master01 ~]# tar xf helm-v3.9.3-linux-amd64.tar.gz
[root@k8s-master01 ~]# cd linux-amd64/
[root@k8s-master01 linux-amd64]# mv helm /usr/local/bin/
[root@k8s-master01 linux-amd64]# helm version
version.BuildInfo{Version:"v3.9.3", GitCommit:"414ff28d4029ae8c8b05d62aa06c7fe3dee2bc58", GitTreeState:"clean", GoVersion:"go1.17.13"}
安装Rancher
[root@k8s-master01 ~]# helm repo add rancher-stable https://releases.rancher.com/server-charts/stable
[root@k8s-master01 ~]# helm repo update
[root@k8s-master01 ~]# kubectl create namespace cattle-system
[root@k8s-master01 ~]# kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.7.1/cert-manager.crds.yaml
[root@k8s-master01 ~]# helm repo update
[root@k8s-master01 ~]# helm install cert-manager jetstack/cert-manager \
> --namespace cert-manager \
> --create-namespace \
> --version v1.7.1
[root@k8s-master01 ~]# kubectl get pods --namespace cert-manager
NAME READY STATUS RESTARTS AGE
cert-manager-76d44b459c-rh5ns 1/1 Running 0 58s
cert-manager-cainjector-9b679cc6-8sctr 1/1 Running 0 58s
cert-manager-webhook-57c994b6b9-7xqc5 1/1 Running 0 58s
[root@k8s-master01 ~]# helm install rancher rancher-stable/rancher \
> --namespace cattle-system \
> --set hostname=rancher.my.org \
> --set bootstrapPassword=admin
[root@k8s-master01 ~]# kubectl -n cattle-system rollout status deploy/rancher
Waiting for deployment "rancher" rollout to finish: 0 of 3 updated replicas are available...
Waiting for deployment "rancher" rollout to finish: 1 of 3 updated replicas are available...
deployment "rancher" successfully rolled out
检查Rancher是否运行成功
[root@k8s-master01 ~]# kubectl -n cattle-system rollout status deploy/rancher
deployment "rancher" successfully rolled out
[root@k8s-master01 ~]# kubectl -n cattle-system get deploy rancher
NAME READY UP-TO-DATE AVAILABLE AGE
rancher 3/3 3 3 4m37s
修改ClusterIP为NodePort,通过浏览器进行访问
[root@k8s-master01 ~]# kubectl get svc -n cattle-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
rancher ClusterIP 10.96.192.102 <none> 80/TCP,443/TCP 5m57s
rancher-webhook ClusterIP 10.96.218.244 <none> 443/TCP 53s
webhook-service ClusterIP 10.96.65.225 <none> 443/TCP 53s
[root@k8s-master01 ~]# kubectl edit svc -n cattle-system rancher
[root@k8s-master01 ~]# kubectl get svc -n cattle-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
rancher NodePort 10.96.192.102 <none> 80:32646/TCP,443:30643/TCP 8m9s
rancher-webhook ClusterIP 10.96.218.244 <none> 443/TCP 3m5s
webhook-service ClusterIP 10.96.65.225 <none> 443/TCP 3m5s
默认密码admin
默认自动添加本地集群