2.3. 使用 CLI 安装 Red Hat OpenShift GitOps Operator
您可以使用 CLI 从 OperatorHub 安装 Red Hat OpenShift GitOps Operator。
对于 GitOps 版本 1.10 及更新的版本,默认命名空间从 openshift-operators
改为 openshift-gitops operator
。
流程
创建
openshift-gitops-operator
命名空间:$ oc create ns openshift-gitops-operator
输出示例
namespace/openshift-gitops-operator created
注意您可以通过应用
openshift.io/cluster-monitoring=true
标签,在openshift-gitops-operator
或任何命名空间上启用集群监控:$ oc label namespace <namespace> openshift.io/cluster-monitoring=true
输出示例
namespace/<namespace> labeled
创建
OperatorGroup
对象 YAML 文件,例如gitops-operator-group.yaml
:OperatorGroup 示例
apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: name: openshift-gitops-operator namespace: openshift-gitops-operator spec: upgradeStrategy: Default
将
OperatorGroup
应用到集群:$ oc apply -f gitops-operator-group.yaml
输出示例
operatorgroup.operators.coreos.com/openshift-gitops-operator created
创建一个
Subscription
对象 YAML 文件,以便为 Red Hat OpenShift GitOps Operator 订阅一个命名空间,如openshift-gitops-sub.yaml
:订阅示例
apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: name: openshift-gitops-operator namespace: openshift-gitops-operator spec: channel: latest 1 installPlanApproval: Automatic name: openshift-gitops-operator 2 source: redhat-operators 3 sourceNamespace: openshift-marketplace 4
将
订阅
应用到集群:$ oc apply -f openshift-gitops-sub.yaml
输出示例
subscription.operators.coreos.com/openshift-gitops-operator created
安装完成后,验证
openshift-gitops
命名空间中的所有 pod 是否正在运行:$ oc get pods -n openshift-gitops
输出示例
NAME READY STATUS RESTARTS AGE cluster-b5798d6f9-zr576 1/1 Running 0 65m kam-69866d7c48-8nsjv 1/1 Running 0 65m openshift-gitops-application-controller-0 1/1 Running 0 53m openshift-gitops-applicationset-controller-6447b8dfdd-5ckgh 1/1 Running 0 65m openshift-gitops-dex-server-569b498bd9-vf6mr 1/1 Running 0 65m openshift-gitops-redis-74bd8d7d96-49bjf 1/1 Running 0 65m openshift-gitops-repo-server-c999f75d5-l4rsg 1/1 Running 0 65m openshift-gitops-server-5785f7668b-wj57t 1/1 Running 0 53m
验证
openshift-gitops-operator
命名空间中的 pod 是否正在运行:$ oc get pods -n openshift-gitops-operator
输出示例
NAME READY STATUS RESTARTS AGE openshift-gitops-operator-controller-manager-664966d547-vr4vb 2/2 Running 0 65m