公司目前k8s管理环境太多,不方便管理,因此对k8s测试环境进行迁移,方便统一管理
本文适用于RKE部署的k8s集群,管理平台为rancher
整体情况如下
名称 | 地址 | 版本 |
目标平台 | https://k8s.example.com | rancherv2.3.3 |
源平台 | https://rancher.example.com | rancherv2.3.5 |
第一步 在目标平台添加k8s集群
进入目标平台--全局---添加集群--导入集群
接下来就是导入的参数,我们使用认证过的ssl证书,所以选择是第一种,点击右边的复制按钮
这里可以根据自己的情况选择是认证的还是私有的。
此时不要点击完成。等执行完命令后再回来点击完成
进入命令行执行
[rancher@xr-prelocus ~]$ kubectl apply -f https://k8s.example.com/v3/import/zwl5xnpqzcrcpncvwt9hlw79kv8slpbttqkx97jfqtg4zsjgrj5vv5.yaml
Warning: resource clusterroles/proxy-clusterrole-kubeapiserver is missing the kubectl.kubernetes.io/last-applied-configuration annotation which is required by kubectl apply. kubectl apply should only be used on resources created declaratively by either kubectl create --save-config or kubectl apply. The missing annotation will be patched automatically.
clusterrole.rbac.authorization.k8s.io/proxy-clusterrole-kubeapiserver configured
Warning: resource clusterrolebindings/proxy-role-binding-kubernetes-master is missing the kubectl.kubernetes.io/last-applied-configuration annotation which is required by kubectl apply. kubectl apply should only be used on resources created declaratively by either kubectl create --save-config or kubectl apply. The missing annotation will be patched automatically.
clusterrolebinding.rbac.authorization.k8s.io/proxy-role-binding-kubernetes-master configured
namespace/cattle-system unchanged
serviceaccount/cattle unchanged
Warning: rbac.authorization.k8s.io/v1beta1 ClusterRoleBinding is deprecated in v1.17+, unavailable in v1.22+; use rbac.authorization.k8s.io/v1 ClusterRoleBinding
clusterrolebinding.rbac.authorization.k8s.io/cattle-admin-binding unchanged
secret/cattle-credentials-f18579e created
clusterrole.rbac.authorization.k8s.io/cattle-admin unchanged
deployment.apps/cattle-cluster-agent configured
daemonset.apps/cattle-node-agent configured
[rancher@xr-prelocus ~]$
执行完毕后返回来页面点击完成
检查会发现只有两个项目
由于项目是在原来的平台上建的,并没有随着迁移过来,所以需要自己新建项目并把命名空间迁移至该项目上。
此时在新平台上已经能够正常显示了,
删除旧平台上的k8s集群
到此迁移完成。