Red Hat Camel K is deprecated
Red Hat Camel K is deprecated and the End of Life date for this product is June 30, 2025. For help migrating to the current go-to solution, Red Hat build of Apache Camel, see the Migration Guide.第 2 章 准备 OpenShift 集群
本章介绍了如何在 OpenShift 上安装 Red Hat Integration - Camel K 和 OpenShift Serverless,以及如何在开发环境中安装所需的 Camel K 和 OpenShift Serverless 命令行客户端工具。
2.1. 安装 Camel K
您可以从 OperatorHub 在 OpenShift 集群上安装 Red Hat Integration - Camel K Operator。OperatorHub 位于 OpenShift Container Platform Web 控制台中,为集群管理员提供用于发现和安装 Operator 的界面。
安装 Camel K Operator 后,您可以安装 Camel K CLI 工具,以便命令行访问所有 Camel K 功能。
先决条件
您可以访问具有正确访问级别的 OpenShift 4.6 (或更新版本)集群、创建项目和安装 Operator 的功能,以及在本地系统上安装 CLI 工具的功能。
注意Copy to Clipboard Copied! Toggle word wrap Toggle overflow You do not need to create a pull secret when installing Camel K from the OpenShift OperatorHub. The Camel K Operator automatically reuses the OpenShift cluster-level authentication to pull the Camel K image from `registry.redhat.io`.
You do not need to create a pull secret when installing Camel K from the OpenShift OperatorHub. The Camel K Operator automatically reuses the OpenShift cluster-level authentication to pull the Camel K image from `registry.redhat.io`.
-
已安装 OpenShift CLI 工具(
oc
),以便可以在命令行中与 OpenShift 集群交互。有关如何安装 OpenShift CLI 的详细信息,请参阅安装 OpenShift CLI。
流程
- 在 OpenShift Container Platform Web 控制台中,使用具有集群管理员特权的帐户登录。
创建新的 OpenShift 项目:
- 在左侧导航菜单中,点击 Home > Project > Create Project。
-
输入项目名称,如
my-camel-k-project
,然后单击 Create。
- 在左侧导航菜单中,点 Operators > OperatorHub。
-
在 Filter by keyword 文本框中,键入
Camel K
,然后点击 Red Hat Integration - Camel K Operator 卡。 - 阅读有关操作器的信息,然后单击 Install。Operator 安装页面将打开。
选择以下订阅设置:
- Update Channel > latest
在以下两个选项中选择:
- Installation Mode > A specific namespace on the cluster > my-camel-k-project
- Installation Mode > All namespaces on the cluster (default) > Openshift operator
注意Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you do not choose among the above two options, the system by default chooses a global namespace on the cluster then leading to openshift operator.
If you do not choose among the above two options, the system by default chooses a global namespace on the cluster then leading to openshift operator.
Approval Strategy > Automatic
注意如果您的环境需要,还可以使用 Installation mode > All namespaces on the cluster and Approval Strategy > Manual 设置。
- 点 Install,等待片刻,直到 Camel K Operator 准备就绪。
下载并安装 Camel K CLI 工具:
- 从 OpenShift Web 控制台顶部的 帮助菜单(?),选择 Command line tools。
- 向下滚动到 kamel - Red Hat Integration - Camel K - 命令行界面 部分。
- 点链接为您的本地操作系统(Linux、Mac、Windows)下载二进制文件。
- 在您的系统路径中解压并安装 CLI。
要验证您可以访问 Kamel K CLI,请打开一个命令窗口,然后键入以下内容:
kamel --help
此命令显示有关 Camel K CLI 命令的信息。
如果您使用 OLM 从 OperatorHub 卸载 Camel K Operator,则不会删除 CRD。要切回到以前的 Camel K operator,您必须使用以下命令手动删除 CRD。
oc get crd -l app=camel-k -o name | xargs oc delete
后续步骤
(可选) 指定 Camel K 资源限值
2.1.1. 一致的集成平台设置
您可以创建命名空间本地集成 Platform 资源来覆盖 Operator 中使用的设置。
这些命名空间本地平台设置必须从 Operator 默认使用的 Integration Platform 中派生出来。也就是说,只有明确指定的设置会覆盖 Operator 中使用的平台默认值。
因此,您必须使用一致的平台设置层次结构,其中全局 operator 平台设置始终代表用户指定平台设置的基础。
- 对于全局 Camel K operator,如果 IntegrationPlatform 指定非默认 spec.build.buildStrategy,这个值也会传播到命名空间 Camel-K operator。
buildStrategy 的默认值为 routine。
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc get itp camel-k -o yaml -n openshift-operators
$ oc get itp camel-k -o yaml -n openshift-operators apiVersion: camel.apache.org/v1 kind: IntegrationPlatform metadata: labels: app: camel-k name: camel-k namespace: openshift-operators spec: build: buildStrategy: pod
全局 Operator 集成平台的参数 buildStrategy 可以通过以下任一方式编辑:
从仪表板中
-
Administrator 视图: Operators
Installed operators in namespace openshift-operators (即全局安装的 operator),选择 Red Hat Integration - Camel K Integration Platform YAML - 现在添加或编辑(如果已存在)spec.build.buildStrategy: pod
- 点 Save
-
Administrator 视图: Operators
使用以下命令:之后安装的任何命名空间 Camel K operator 都会继承全局集成平台中的设置。
Copy to Clipboard Copied! Toggle word wrap Toggle overflow oc patch itp/camel-k -p '{"spec":{"build":{"buildStrategy": "pod"}}}' --type merge -n openshift-operators
oc patch itp/camel-k -p '{"spec":{"build":{"buildStrategy": "pod"}}}' --type merge -n openshift-operators
2.1.2. 指定 Camel K 资源限值
安装 Camel K 时,Camel K 的 OpenShift pod 不会为 CPU 和内存(RAM)资源设置任何限制。如果要为 Camel K 定义资源限值,您必须编辑在安装过程中创建的 Camel K 订阅资源。
前提条件
- 具有安装 Camel K Operator 的 OpenShift 项目的集群管理员访问权限,如 安装 Camel K 所述。
您知道要应用到 Camel K 订阅的资源限值。有关资源限值的更多信息,请参阅以下文档:
流程
- 登录 OpenShift Web 控制台。
- 选择 Operators > Installed Operators > Operator Details > Subscription。
选择 Actions > Edit Subscription。
订阅的文件在 YAML 编辑器中打开。
在
spec
部分,添加一个config.resources
部分,并为 memory 和 cpu 提供值,如下例所示:Copy to Clipboard Copied! Toggle word wrap Toggle overflow spec: channel: default config: resources: limits: memory: 512Mi cpu: 500m requests: cpu: 200m memory: 128Mi
spec: channel: default config: resources: limits: memory: 512Mi cpu: 500m requests: cpu: 200m memory: 128Mi
- 保存您的更改。
OpenShift 更新订阅并应用您指定的资源限值。
我们建议您只通过 全局 安装安装 Camel K Operator。