搜索

7.3. 在集群中部署插件

download PDF

您可以将插件部署到 OpenShift Container Platform 集群。

7.3.1. 使用 Docker 构建镜像

要在集群中部署插件,您需要构建镜像并将其推送到镜像 registry。

流程

  1. 使用以下命令构建镜像:

    $ docker build -t quay.io/my-repositroy/my-plugin:latest .
  2. 可选:如果要测试您的镜像,请运行以下命令:

    $ docker run -it --rm -d -p 9001:80 quay.io/my-repository/my-plugin:latest
  3. 运行以下命令推送镜像:

    $ docker push quay.io/my-repository/my-plugin:latest

7.3.2. 在集群中部署插件

在将镜像推送到 registry 后,您可以将插件部署到集群中。

流程

  1. 使用插件名称作为 Helm 发行版本名称安装 Helm chart,作为 Helm 发行版本名称,或由 -n 命令行选项指定的现有命名空间。使用以下命令,提供 plugin.image 参数中镜像的位置:

    $ helm upgrade -i  my-plugin charts/openshift-console-plugin -n my-plugin-namespace --create-namespace --set plugin.image=my-plugin-image-location

    其中:

    n <my-plugin-namespace>
    指定要将插件部署到的现有命名空间。
    --create-namespace
    可选:如果部署到新命名空间,请使用此参数。
    --set plugin.image=my-plugin-image-location
    指定 plugin.image 参数中镜像的位置。
  2. 可选: 您可以使用 charts/openshift-console-plugin/values.yaml 文件中的一组支持的参数来指定任何其他参数。
plugin:
  name: ""
  description: ""
  image: ""
  imagePullPolicy: IfNotPresent
  replicas: 2
  port: 9443
  securityContext:
    enabled: true
  podSecurityContext:
    enabled: true
    runAsNonRoot: true
    seccompProfile:
      type: RuntimeDefault
  containerSecurityContext:
    enabled: true
    allowPrivilegeEscalation: false
    capabilities:
      drop:
        - ALL
  resources:
    requests:
      cpu: 10m
      memory: 50Mi
  basePath: /
  certificateSecretName: ""
  serviceAccount:
    create: true
    annotations: {}
    name: ""
  patcherServiceAccount:
    create: true
    annotations: {}
    name: ""
  jobs:
    patchConsoles:
      enabled: true
      image: "registry.redhat.io/openshift4/ose-tools-rhel8@sha256:e44074f21e0cca6464e50cb6ff934747e0bd11162ea01d522433a1a1ae116103"
      podSecurityContext:
        enabled: true
        runAsNonRoot: true
        seccompProfile:
          type: RuntimeDefault
      containerSecurityContext:
        enabled: true
        allowPrivilegeEscalation: false
        capabilities:
          drop:
            - ALL
      resources:
        requests:
          cpu: 10m
          memory: 50Mi

验证

您可以在 Overview 页中看到启用的插件列表,或者通过 Administration Cluster Settings Configuration Console operator.openshift.io Console plugins

注意

显示新插件配置可能需要几分钟时间。如果没有看到插件,则在最近启用了插件时,可能需要刷新浏览器。如果您在运行时收到任何错误,请在浏览器开发人员工具中检查 JS 控制台,以查看插件代码中的任何错误。

7.3.3. 在浏览器中禁用您的插件

控制台用户可以使用 disable-plugins 查询参数来禁用通常会在运行时加载的特定或所有动态插件。

流程

  • 要禁用特定的插件,请从以逗号分隔的插件名称列表中删除您要禁用的插件。
  • 要禁用所有插件,请在 disable-plugins 查询参数中有一个空字符串。
注意

集群管理员可以在 web 控制台的 Cluster Settings 页面中禁用插件

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

© 2024 Red Hat, Inc.