搜索

3.3. 安装自定义指标自动扩展

download PDF

您可以使用 OpenShift Container Platform Web 控制台安装自定义 Metrics Autoscaler Operator。

安装会创建以下五个 CRD:

  • ClusterTriggerAuthentication
  • KedaController
  • ScaledJob
  • ScaledObject
  • TriggerAuthentication

3.3.1. 安装自定义指标自动扩展

您可以使用以下步骤安装自定义 Metrics Autoscaler Operator。

先决条件

  • 删除之前安装的 Cluster Metrics Autoscaler Operator 的技术预览版本。
  • 删除基于社区的 KEDA 的任何版本。

    另外,运行以下命令来删除 KEDA 1.x 自定义资源定义:

    $ oc delete crd scaledobjects.keda.k8s.io
    $ oc delete crd triggerauthentications.keda.k8s.io
  • 可选:如果您需要自定义 Metrics Autoscaler Operator 连接到非集群服务,如外部 Kafka 集群或外部 Prometheus 服务,请将任何所需的服务 CA 证书放在配置映射中。配置映射必须存在于安装 Operator 的同一命名空间中。例如:

    $ oc create configmap -n openshift-keda thanos-cert  --from-file=ca-cert.pem

流程

  1. 在 OpenShift Container Platform Web 控制台中,点击 Operators OperatorHub
  2. 从可用的 Operator 列表中选择 Custom Metrics Autoscaler,然后点 Install
  3. Install Operator 页面中,确保为 Installation Mode 选择 All namespaces on the cluster(default) 选项。这会在所有命名空间中安装 Operator。
  4. 确保为 Installed Namespace 选择了 openshift-keda 命名空间。如果集群中不存在命名空间,OpenShift Container Platform 会创建命名空间。
  5. Install
  6. 列出自定义 Metrics Autoscaler Operator 组件来验证安装:

    1. 导航到 Workloads Pods
    2. 从下拉菜单中选择 openshift-keda 项目,并验证 custom-metrics-autoscaler-operator-* pod 正在运行。
    3. 进入到 Workloads Deployments 以验证 custom-metrics-autoscaler-operator 部署是否正在运行。
  7. 可选:使用以下命令在 OpenShift CLI 中验证安装:

    $ oc get all -n openshift-keda

    输出结果类似如下:

    输出示例

    NAME                                                      READY   STATUS    RESTARTS   AGE
    pod/custom-metrics-autoscaler-operator-5fd8d9ffd8-xt4xp   1/1     Running   0          18m
    
    NAME                                                 READY   UP-TO-DATE   AVAILABLE   AGE
    deployment.apps/custom-metrics-autoscaler-operator   1/1     1            1           18m
    
    NAME                                                            DESIRED   CURRENT   READY   AGE
    replicaset.apps/custom-metrics-autoscaler-operator-5fd8d9ffd8   1         1         1       18m

  8. 安装 KedaController 自定义资源,该资源创建所需的 CRD:

    1. 在 OpenShift Container Platform web 控制台中,点击 Operators Installed Operators
    2. Custom Metrics Autoscaler
    3. Operator Details 页面中,点 KedaController 选项卡。
    4. KedaController 选项卡中,点 Create KedaController 并编辑文件。

      kind: KedaController
      apiVersion: keda.sh/v1alpha1
      metadata:
        name: keda
        namespace: openshift-keda
      spec:
        watchNamespace: '' 1
        operator:
          logLevel: info 2
          logEncoder: console 3
          caConfigMaps: 4
          - thanos-cert
          - kafka-cert
        metricsServer:
          logLevel: '0' 5
          auditConfig: 6
            logFormat: "json"
            logOutputVolumeClaim: "persistentVolumeClaimName"
            policy:
              rules:
              - level: Metadata
              omitStages: ["RequestReceived"]
              omitManagedFields: false
            lifetime:
              maxAge: "2"
              maxBackup: "1"
              maxSize: "50"
        serviceAccount: {}
      1
      指定自定义 Metrics Autoscaler Operator 应该在其中扩展应用程序的单个命名空间。将它留空,或将其留空,以便在所有命名空间中扩展应用程序。此字段应具有命名空间或为空。默认值为空。
      2
      指定自定义 Metrics Autoscaler Operator 日志消息的详细程度。允许的值有 debuginfoerror。默认为 info
      3
      指定 Custom Metrics Autoscaler Operator 日志消息的日志记录格式。允许的值是 consolejson。默认为 console
      4
      可选:使用 CA 证书指定一个或多个配置映射,自定义 Metrics Autoscaler Operator 可以使用它们安全地连接到启用了 TLS 的指标源。
      5
      指定自定义 Metrics Autoscaler Metrics 服务器的日志记录级别。允许的值是 0(用于 info)和 4(用于 debug )。默认值为 0
      6
      激活自定义 Metrics Autoscaler Operator 的审计日志记录,并指定要使用的审计策略,如"配置审计日志记录"部分中所述。
    5. Create 创建 KEDA 控制器。
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

© 2024 Red Hat, Inc.