9.3. 使用自动导入 secret 导入
在仍登录到您的引擎集群时继续执行以下步骤:
-
检索您要导入的集群的
kubeconfig文件,或者您要导入的集群的 kube API 服务器和令牌。请参阅 Kubernetes 集群的文档,以了解在什么位置找到kubeconfig文件或 kube api 服务器和令牌 使用您的
kubeconfig或您的 server/token 对来创建包含类似以下模板的 YAML 文件:apiVersion: v1 kind: Secret metadata: name: auto-import-secret stringData: # the following value to specify the retry times when your cluster failed to import autoImportRetry: "5" # If you are using the kubeconfig file, add the following value for the kubeconfig file # that has the current context set to the cluster to import: kubeconfig: |- <kubeconfig_file> # If you are using the server/token pair, add the following two values: server: <cluster_api_url> token: <Token to access the cluster> type: Opaque- 将文件保存为 auto-import-secret.yaml
使用您要导入的集群的
kubeconfig文件,在${CLUSTER_NAME}命名空间中生成导入 secret。使用kubeconfig和CLUSTER_NAME的路径运行以下命令:oc apply -f auto-import-secret.yaml注: 自动导入 secret 只使用一次,在导入过程完成后会被删除。
验证您的导入集群的
JOINED和AVAILABLE状态。从 Kubernetes 集群的多集群引擎运行以下命令:oc get managedcluster ${CLUSTER_NAME}在您要导入的独立集群中继续执行以下步骤:
登录到您要导入的集群。运行以下命令:
oc login验证您要导入的集群中的 pod 状态。运行以下命令:
oc get pod -n open-cluster-management-agent导入的集群将安装附加组件是
AVAILABLE。验证集群中附加组件的 Pod 状态。运行以下命令:oc get pod -n open-cluster-management-agent-addon
集群现已导入。