第 1 章 在基础架构节点上运行 GitOps control plane 工作负载
对于两个主要目的,您可以使用基础架构节点隔离基础架构工作负载:
- 要防止与订阅数量相关的计费成本
- 分隔维护和管理
您可以使用 OpenShift Container Platform 在基础架构节点上运行 GitOps control plane 工作负载。默认情况下,包括 Operator pod 和由 openshift-gitops
命名空间中的 Red Hat OpenShift GitOps Operator 创建的 control plane 工作负载,包括此命名空间中的默认 Argo CD 实例。
使用 GitOps control plane 工作负载,您可以通过在集群中创建多个隔离的 Argo CD 实例来安全地和声明性地隔离基础架构工作负载,并完全控制 Argo CD 实例的功能。另外,您可以在多个开发人员命名空间中以声明性方式管理这些 Argo CD 实例。通过使用污点,您可以确保只有基础架构组件在这些节点上运行。
在用户命名空间中安装的所有其他 Argo CD 实例都无法在基础架构节点上运行。
1.1. 将 GitOps control plane 工作负载移到基础架构节点
您可以将 Red Hat OpenShift GitOps 安装的 GitOps control plane 工作负载移到基础架构节点。以下是您可以移动的 control plane 工作负载:
-
集群部署
(后端服务) -
openshift-gitops-applicationset-controller 部署
-
openshift-gitops-dex-server 部署
-
openshift-gitops-redis 部署
-
openshift-gitops-redis-ha-haproxy 部署
-
openshift-gitops-repo-sever 部署
-
openshift-gitops-server 部署
-
openshift-gitops-application-controller statefulset
-
openshift-gitops-redis-server statefulset
流程
运行以下命令,将现有节点标记为基础架构:
$ oc label node <node-name> node-role.kubernetes.io/infra=
编辑
GitOpsService
自定义资源(CR)以添加基础架构节点选择器:$ oc edit gitopsservice -n openshift-gitops
在
GitOpsService
CR 文件中,将runOnInfra
字段添加到spec
部分,并将其设置为true
。此字段将openshift-gitops
命名空间中的 control plane 工作负载移到基础架构节点:apiVersion: pipelines.openshift.io/v1alpha1 kind: GitopsService metadata: name: cluster spec: runOnInfra: true
可选:在基础架构节点上应用污点并隔离工作负载,并防止其他工作负载调度到这些节点上。
$ oc adm taint nodes -l node-role.kubernetes.io/infra infra=reserved:NoSchedule infra=reserved:NoExecute
可选: 如果您将污点应用到节点,您可以在
GitOpsService
CR 中添加容限:spec: runOnInfra: true tolerations: - effect: NoSchedule key: infra value: reserved - effect: NoExecute key: infra value: reserved
要验证工作负载是否已调度到 Red Hat OpenShift GitOps 命名空间中的基础架构节点上,请点击任何 pod 名称,并确保已添加了 Node selector 和 Tolerations。
在默认 Argo CD CR 中手动添加节点选择器和 Tolerations 都会被 GitOpsService
CR 中的切换和容限覆盖。