搜索

9.3. 使用自动导入 secret 导入

download PDF

在仍登录到您的引擎集群时继续执行以下步骤:

  1. 检索您要导入的集群的 kubeconfig 文件,或者您要导入的集群的 kube API 服务器和令牌。请参阅 Kubernetes 集群的文档,以了解在什么位置找到 kubeconfig 文件或 kube api 服务器和令牌
  2. 使用您的 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
  3. 将文件保存为 auto-import-secret.yaml
  4. 使用您要导入的集群的 kubeconfig 文件,在 ${CLUSTER_NAME} 命名空间中生成导入 secret。使用 kubeconfigCLUSTER_NAME 的路径运行以下命令:

    oc apply -f auto-import-secret.yaml

    注: 自动导入 secret 只使用一次,在导入过程完成后会被删除。

  5. 验证您的导入集群的 JOINEDAVAILABLE 状态。从 Kubernetes 集群的多集群引擎运行以下命令:

    oc get managedcluster ${CLUSTER_NAME}

    在您要导入的独立集群中继续执行以下步骤:

  6. 登录到您要导入的集群。运行以下命令:

    oc login
  7. 验证您要导入的集群中的 pod 状态。运行以下命令:

    oc get pod -n open-cluster-management-agent
  8. 导入的集群将安装附加组件是 AVAILABLE。验证集群中附加组件的 Pod 状态。运行以下命令:

    oc get pod -n open-cluster-management-agent-addon

集群现已导入。

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.