$ docker build -t quay.io/my-repositroy/my-plugin:latest .
您可以将插件部署到 OpenShift Dedicated 集群。
要在集群上部署插件,您需要先构建镜像并将其推送到镜像注册表。
使用以下命令构建镜像
$ docker build -t quay.io/my-repositroy/my-plugin:latest .
可选:如果要测试镜像,请运行以下命令
$ docker run -it --rm -d -p 9001:80 quay.io/my-repository/my-plugin:latest
运行以下命令推送镜像
$ docker push quay.io/my-repository/my-plugin:latest
将包含更改的镜像推送到注册表后,您可以使用 Helm chart 将插件部署到集群。
您必须拥有先前已推送的包含插件的镜像的位置。
您可以根据插件的需求指定其他参数。 |
要将插件部署到集群,请使用插件名称作为 Helm 发布名称,将 Helm chart 安装到新的命名空间或由 -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
参数中指定镜像的位置。
如果您在 OpenShift Dedicated 4.10 及更高版本上部署,建议通过添加参数 |
可选:您可以使用 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
通过从**管理** → **集群设置** → **配置** → **控制台** operator.openshift.io
→ **控制台插件** 导航,或访问**概述**页面来查看已启用插件的列表。
新的插件配置可能需要几分钟才能显示。如果您没有看到您的插件,如果最近启用了插件,您可能需要刷新浏览器。如果您在运行时收到任何错误,请检查浏览器开发者工具中的 JS 控制台以查找插件代码中的任何错误。 |
如果需要从插件向集群内服务发出 HTTP 请求,则可以通过使用 spec.proxy
数组字段在 ConsolePlugin
资源中声明服务代理。控制台后端公开 /api/proxy/plugin/<plugin-name>/<proxy-alias>/<request-path>?<optional-query-parameters>
端点以代理插件和服务之间的通信。代理请求默认使用 *服务 CA 捆绑包*。服务必须使用 HTTPS。
插件必须使用 |
对于每个条目,您必须在 endpoint
和 alias
字段下指定代理的端点和别名。对于服务代理类型,您必须将端点 type
字段设置为 Service
,并且 service
必须包含 name
、namespace
和 port
字段的值。例如,/api/proxy/plugin/helm/helm-charts/releases?limit=10
是来自具有 helm-charts
服务的 helm
插件的代理请求路径,该服务列出十个 Helm 发布。
apiVersion: console.openshift.io/v1
kind: ConsolePlugin
metadata:
name:<plugin-name>
spec:
proxy:
- alias: helm-charts (1)
authorization: UserToken (2)
caCertificate: '-----BEGIN CERTIFICATE-----\nMIID....'en (3)
endpoint: (4)
service:
name: <service-name>
namespace: <service-namespace>
port: <service-port>
type: Service
1 | 代理的别名。 | ||
2 | 如果服务代理请求必须包含已登录用户的 OpenShift Dedicated 访问令牌,则必须将授权字段设置为 UserToken 。
|
||
3 | 如果服务使用自定义服务 CA,则 caCertificate 字段必须包含证书捆绑包。 |
||
4 | 代理的端点。 |