operator:
  name: metering-operator

  disableOCPFeatures: false

  reconcileIntervalSeconds: 30
  targetNamespace: ""
  useTargetNamespacesDownwardAPIValueFrom: false
  labels: {}
  annotations: {}

  image:
    repository: quay.io/openshift/origin-metering-ansible-operator
    tag: "4.6"
    pullPolicy: Always

  imagePullSecrets: []

  serviceAccountName: metering-operator
  resources:
    requests:
      memory: "400Mi"
      cpu: "750m"
    limits:
      memory: "500Mi"
      cpu: "1500m"

  rbac:
    clusterRoleName: metering-operator
    clusterRoleRules:
    # grants access to the metering-ansible-operator to create a servicemonitor
    - apiGroups: [""]
      resources:
      - services/finalizers
      - deployments/finalizers
      verbs:
      - update
    # grants access to metrics data
    - apiGroups:
      - ""
      resources:
      - namespaces
      verbs:
      - get
      - list
    # grants access to view the proxy config
    - apiGroups:
      - config.openshift.io
      resources:
      - proxies
      verbs:
      - list
      - get
    # grants access to view the networking config
    - apiGroups:
      - config.openshift.io
      resources:
      - networks
      verbs:
      - list
      - get
    # used by openshift auth-proxy
    - apiGroups:
      - authorization.k8s.io
      resources:
      - subjectaccessreviews
      verbs:
      - create
    # used by openshift auth-proxy
    - apiGroups:
      - authentication.k8s.io
      resources:
      - tokenreviews
      verbs:
      - create
    # grants access to creating clusterroles and clusterrolebindings for
    # reporting-operator
    - apiGroups:
      - rbac.authorization.k8s.io
      resources:
      - clusterrolebindings
      - clusterroles
      verbs: ["*"]

    roleName: metering-operator
    rules:
    # grant access to metering resources
    - apiGroups: ["metering.openshift.io"]
      resources: ["*"]
      verbs: ["*"]
    # grant access to monitoring resources for optional monitoring integration
    - apiGroups: ["monitoring.coreos.com"]
      resources:
      - servicemonitors
      verbs: ["*"]
    # access to most core resources that can be created by metering
    - apiGroups:
      - ""
      resources:
      - pods
      - pods/attach
      - pods/exec
      - pods/portforward
      - pods/proxy
      verbs: ["*"]
    - apiGroups:
      - ""
      resources:
      - configmaps
      - endpoints
      - persistentvolumeclaims
      - secrets
      - serviceaccounts
      - services
      - services/proxy
      verbs: ["*"]
    - apiGroups:
      - ""
      resources:
      - events
      - namespaces/status
      - pods/log
      - pods/status
      verbs:
      - get
      - list
      - watch
    - apiGroups:
      - ""
      resources:
      - events
      verbs:
      - create
      - update
      - patch
    - apiGroups:
      - ""
      resources:
      - namespaces
      verbs:
      - get
      - list
      - watch
    - apiGroups:
      - apps
      resources:
      - daemonsets
      - deployments
      - deployments/finalizers
      - deployments/rollback
      - deployments/scale
      - replicasets
      - replicasets/scale
      - statefulsets
      verbs: ["*"]
    - apiGroups:
      - batch
      resources:
      - cronjobs
      - jobs
      verbs: ["*"]
    - apiGroups:
      - extensions
      resources:
      - daemonsets
      - deployments
      - deployments/rollback
      - deployments/scale
      - replicasets
      - replicasets/scale
      verbs: ["*"]
    - apiGroups:
      - rbac.authorization.k8s.io
      - authorization.openshift.io
      resources:
      - rolebindings
      - roles
      verbs: ["*"]
    - apiGroups:
      - route.openshift.io
      resources:
      - routes
      verbs: ["*"]

olm:
  packageName: metering-ocp
  channels:
  - name: "4.6"
    currentCSV: metering-operator.v4.6.0

  skipARTPackage: false

  imageTags:
  - name: metering-ansible-operator
    from:
      kind: DockerImage
      name: quay.io/openshift/origin-metering-ansible-operator:4.6
  - name: metering-reporting-operator
    from:
      kind: DockerImage
      name: quay.io/openshift/origin-metering-reporting-operator:4.6
  - name: metering-presto
    from:
      kind: DockerImage
      name: quay.io/openshift/origin-metering-presto:4.6
  - name: metering-hive
    from:
      kind: DockerImage
      name: quay.io/openshift/origin-metering-hive:4.6
  - name: metering-hadoop
    from:
      kind: DockerImage
      name: quay.io/openshift/origin-metering-hadoop:4.6
  - name: ghostunnel
    from:
      kind: DockerImage
      name: quay.io/openshift/origin-ghostunnel:4.6
  - name: oauth-proxy
    from:
      kind: DockerImage
      name: quay.io/openshift/origin-oauth-proxy:4.6

  csv:
    name : metering-operator.v4.6.0
    version: "4.6.0"
    skipRange: ">=4.3.0 <4.6.0"
    minKubeVersion: 1.18.3
    displayName: Metering
    description: |
      The Metering Operator is a generic reporting tool to provide accountability for how resources are used across a cluster cherry-picking and storing information from different sources. Cluster admins can schedule reports based on historical usage data by Pod, Namespace, and Cluster for storage. The Metering Operator is a part of the [Kubernetes Reporting organization](https://github.com/kube-reporting).

      Read the user guide for more details on [running and viewing your first report](https://docs.openshift.com/container-platform/4.6/metering/metering-using-metering.html).

      ### Core capabilities

      * **Long term storage** - Break down the reserved and utlized resources requested by applications and store the information as long as needed.

      * **Pod, Namespace & Cluster Reports** - Built in reports exist to break down CPU and RAM in any way you desire.

      * **Scheduled Reports** - Schedule reports to run on a standard interval, eg. daily or monthly. Use these reports, for instance, as the basis for chargeback and showback.

      * **Post-Processing** - Reports are generated in either CSV, JSON, or tabular formatting and stored in persistent storage for further post-processing. Use this to send reminder emails, integrate into your ERP system, or graph on a dashboard.

      * **Roll-up reports** - Reports can be used as a source for other reports, allowing for more complex queries that span longer periods than those supported by the data source.

      * **HTTP API** - Reports can be queried from an in-cluster HTTP API in addition to reading from persistent storage.

      * **Integration with AWS EC2 billing** - Connect metering to AWS to calculate the EC2 costs of your resources.

      ### Before you start

      Metering runs a big data stack to crunch your data and requires at least 4GB of RAM and 4 CPU cores.
      At least one Node should have 2GB of RAM and 2 CPU cores.
      Memory and CPU consumption may often be lower, but will spike when running reports, or collecting data for larger clusters.

      Metering requires configuring storage, please review the [configuring persistent storage documentation](https://docs.openshift.com/container-platform/4.6/metering/configuring-metering/metering-configure-persistent-storage.html) before proceeding.

      ### Common Configurations

      * **Store data in object storage or in a PersistentVolume** - Store your report output [in an object storage bucket or in a PersistentVolume](https://docs.openshift.com/container-platform/4.6/metering/configuring-metering/metering-configure-persistent-storage.html).

      * **Configure AWS Billing Data Source** - Assign Pod $$ costs on using your [AWS billing reports stored in S3](https://docs.openshift.com/container-platform/4.6/metering/configuring-metering/metering-configure-aws-billing-correlation.html).

      * **Use Reports** - Customize what how you process data. [Specify what you want to report on, set the schedule, and reporting time period](https://docs.openshift.com/container-platform/4.6/metering/reports/metering-about-reports.html#metering-reports_metering-about-reports).

    keywords: ['metering', 'metrics', 'reporting', 'prometheus', 'chargeback']
    icon:
      - base64data: PHN2ZyBpZD0iYmI5OWY3NGMtM2VkOS00OWU2LWE0OWQtNDI3ODA5NWU5ZWI4IiBkYXRhLW5hbWU9IkxheWVyIDEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDcyMS4xNSA3MjEuMTUiPgogIDxkZWZzPgogICAgPHN0eWxlPgogICAgICAuYjdmMDIwYzgtMjFkMS00NWVmLWE0NTktNzJhNWE0MmE5MjJlIHsKICAgICAgICBmaWxsOiAjZGIzOTI3OwogICAgICB9CgogICAgICAuZjM0NTNmYmYtODk1My00NjE3LWJlNTEtMWZkZDJiOTdiMDBlIHsKICAgICAgICBmaWxsOiAjY2IzNjI4OwogICAgICB9CgogICAgICAuYjFhNGZjNTMtYWFlNS00ZWI5LTliN2ItYTAxYmMxYTU0ZmFjIHsKICAgICAgICBmaWxsOiAjZmZmOwogICAgICB9CgogICAgICAuYTc4NTliZDQtYjA1My00YzVmLTk5MGQtYzRmNzFkNDgwZTM4IHsKICAgICAgICBmaWxsOiAjZTNlM2UyOwogICAgICB9CiAgICA8L3N0eWxlPgogIDwvZGVmcz4KICA8dGl0bGU+UHJvZHVjdF9JY29uLVJlZF9IYXQtTWV0ZXJpbmctUkdCPC90aXRsZT4KICA8Y2lyY2xlIGNsYXNzPSJiN2YwMjBjOC0yMWQxLTQ1ZWYtYTQ1OS03MmE1YTQyYTkyMmUiIGN4PSIzNjAuNTc1IiBjeT0iMzYwLjU3NSIgcj0iMzU4LjU3NiIvPgogIDxwYXRoIGNsYXNzPSJmMzQ1M2ZiZi04OTUzLTQ2MTctYmU1MS0xZmRkMmI5N2IwMGUiIGQ9Ik02MTUuNTMsMTA4LjkxNiwxMDguNDY0LDYxNS45ODNjMTQwLjE0MywxMzguNjE3LDM2Ni4xMTEsMTM4LjE2NCw1MDUuNjcxLTEuNFM3NTQuMTQ5LDI0OS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BjOC0yMWQxLTQ1ZWYtYTQ1OS03MmE1YTQyYTkyMmUiIHBvaW50cz0iMjg2LjQ4OCAyNjkuMTM0IDI5My4zMDQgMjY0LjczMiAzNzMuOTAxIDMxMS4yNjUgMzY3LjA4NSAzMTUuNjY3IDI4Ni40ODggMjY5LjEzNCIvPgogIDxwb2x5Z29uIGNsYXNzPSJiN2YwMjBjOC0yMWQxLTQ1ZWYtYTQ1OS03MmE1YTQyYTkyMmUiIHBvaW50cz0iMzAwLjIyNSAyNjkuMTM0IDM0NS43OTIgMjQyLjA3NCAzNjAuNTgxIDI1MC42OTkgMzE1LjAxNCAyNzcuNzU4IDMwMC4yMjUgMjY5LjEzNCIvPgogIDxwb2x5Z29uIGNsYXNzPSJiN2YwMjBjOC0yMWQxLTQ1ZWYtYTQ1OS03MmE1YTQyYTkyMmUiIHBvaW50cz0iMzIzLjAwOCAyODIuMTYgMzk4LjU2MyAyMzUuODY2IDQxMy4zNTIgMjQ0LjQ5IDMzNy43OTggMjkwLjc4NSAzMjMuMDA4IDI4Mi4xNiIvPgogIDxwb2x5Z29uIGNsYXNzPSJiN2YwMjBjOC0yMWQxLTQ1ZWYtYTQ1OS03MmE1YTQyYTkyMmUiIHBvaW50cz0iMzQ1Ljc5MiAyOTUuMTg3IDQwNi44NCAyNTkuMzQ3IDQyMS42MyAyNjcuOTcyIDM2MC41ODEgMzAzLjgxMSAzNDUuNzkyIDI5NS4xODciLz4KPC9zdmc+Cg==
        mediatype: image/svg+xml
    maturity: stable
    maintainers:
    - name: Red Hat
      email: sd-operator-metering@redhat.com
    provider:
      name: Red Hat
    links:
    - name: Documentation
      url: https://docs.openshift.com/container-platform/4.6/metering/metering-about-metering.html
    labels:
      operator-metering: "true"
    matchLabels:
      operator-metering: "true"
    installModes:
    - type: OwnNamespace
      supported: true
    - type: SingleNamespace
      supported: true
    - type: MultiNamespace
      supported: false
    - type: AllNamespaces
      supported: false

    customresourcedefinitions:
      owned:
      - description: An instance of Metering with high-level configuration
        displayName: Metering Configuration
        kind: MeteringConfig
        name: meteringconfigs.metering.openshift.io
        version: v1
      - description: A scheduled or on-off Metering Report summarizes data based on the
          query specified.
        displayName: Metering Report
        kind: Report
        name: reports.metering.openshift.io
        version: v1
      - description: A SQL query used by Metering to generate reports.
        displayName: Metering Report Query
        kind: ReportQuery
        name: reportqueries.metering.openshift.io
        version: v1
      - description: Used under-the-hood. A resource representing a database table in Presto.
          Used by ReportQueries to determine what tables exist, and by the HTTP API to
          determine how to query a table.
        displayName: Metering Data Source
        kind: ReportDataSource
        name: reportdatasources.metering.openshift.io
        version: v1
      - description: Represents a configurable storage location for Metering to store metering
          and report data.
        displayName: Metering Storage Location
        kind: StorageLocation
        name: storagelocations.metering.openshift.io
        version: v1
      - description: Used under-the-hood. A resource describing a source of data for usage
          by Report Queries.
        displayName: Metering Presto Table
        kind: PrestoTable
        name: prestotables.metering.openshift.io
        version: v1
      - description: Used under-the-hood. A resource representing a database table in Hive.
        displayName: Metering Hive Table
        kind: HiveTable
        name: hivetables.metering.openshift.io
        version: v1

    annotations:
      operators.openshift.io/capability: '["fips", "cluster-proxy"]'
      operatorframework.io/suggested-namespace: openshift-metering
      operatorframework.io/cluster-monitoring: "true"
      categories: "OpenShift Optional, Monitoring"
      certified: "false"
      capabilities: Seamless Upgrades
      support: Red Hat, Inc.
      createdAt: "2019-01-01T11:59:59Z"
      containerImage: "quay.io/openshift/origin-metering-ansible-operator:4.6"
      description: 'Chargeback and reporting tool to provide accountability for how resources are used across a cluster'
      repository: https://github.com/kube-reporting/metering-operator
      alm-examples: |-
        [
          {
            "apiVersion": "metering.openshift.io/v1",
            "kind": "MeteringConfig",
            "metadata": {
              "name": "operator-metering"
            },
            "spec": {
              "storage": {
                "hive": {
                  "s3": {
                    "bucket": "bucketname/path/",
                    "createBucket": true,
                    "region": "us-west-1",
                    "secretName": "my-aws-secret"
                  },
                  "type": "s3"
                },
                "type": "hive"
              }
            }
          },
          {
            "apiVersion": "metering.openshift.io/v1",
            "kind": "Report",
            "metadata": {
              "name": "unready-deployment-replicas-hourly"
            },
            "spec": {
              "query": "unready-deployment-replicas",
              "schedule": {
                "period": "hourly"
              }
            }
          },
          {
            "apiVersion": "metering.openshift.io/v1",
            "kind": "ReportQuery",
            "metadata": {
              "name": "unready-deployment-replicas"
            },
            "spec": {
              "columns": [
                {
                  "name": "period_start",
                  "type": "timestamp"
                },
                {
                  "name": "period_end",
                  "type": "timestamp"
                },
                {
                  "name": "namespace",
                  "type": "varchar"
                },
                {
                  "name": "deployment",
                  "type": "varchar"
                },
                {
                  "name": "total_replica_unready_seconds",
                  "type": "double"
                },
                {
                  "name": "avg_replica_unready_seconds",
                  "type": "double"
                }
              ],
              "inputs": [
                {
                  "name": "ReportingStart",
                  "type": "time"
                },
                {
                  "name": "ReportingEnd",
                  "type": "time"
                },
                {
                  "default": "unready-deployment-replicas",
                  "name": "UnreadyDeploymentReplicasDataSourceName",
                  "type": "ReportDataSource"
                }
              ],
              "query": "SELECT\n    timestamp '{| default .Report.ReportingStart .Report.Inputs.ReportingStart | prestoTimestamp |}' AS period_start,\n    timestamp '{| default .Report.ReportingEnd .Report.Inputs.ReportingEnd | prestoTimestamp |}' AS period_end,\n    labels['namespace'] AS namespace,\n    labels['deployment'] AS deployment,\n    sum(amount * \"timeprecision\") AS total_replica_unready_seconds,\n    avg(amount * \"timeprecision\") AS avg_replica_unready_seconds\nFROM {| dataSourceTableName .Report.Inputs.UnreadyDeploymentReplicasDataSourceName |}\nWHERE \"timestamp\" >= timestamp '{| default .Report.ReportingStart .Report.Inputs.ReportingStart | prestoTimestamp |}'\nAND \"timestamp\" < timestamp '{| default .Report.ReportingEnd .Report.Inputs.ReportingEnd | prestoTimestamp |}'\nGROUP BY labels['namespace'], labels['deployment']\nORDER BY total_replica_unready_seconds DESC, avg_replica_unready_seconds DESC, namespace ASC, deployment ASC\n"
            }
          },
          {
            "apiVersion": "metering.openshift.io/v1",
            "kind": "ReportDataSource",
            "metadata": {
              "name": "unready-deployment-replicas"
            },
            "spec": {
              "prometheusMetricsImporter": {
                "query": "sum(kube_deployment_status_replicas_unavailable) by (namespace, deployment)\n"
              }
            }
          },
          {
            "apiVersion": "metering.openshift.io/v1",
            "kind": "StorageLocation",
            "metadata": {
              "name": "s3-storage-example"
            },
            "spec": {
              "hive": {
                "databaseName": "metering-s3",
                "location": "s3a://bucketName/pathInBucket",
                "unmanagedDatabase": true
              }
            }
          },
          {
            "apiVersion": "metering.openshift.io/v1",
            "kind": "PrestoTable",
            "metadata": {
              "name": "example-baremetal-cost"
            },
            "spec": {
              "catalog": "hive",
              "columns": [
                {
                  "name": "cost_per_gigabyte_hour",
                  "type": "double"
                },
                {
                  "name": "cost_per_cpu_hour",
                  "type": "double"
                },
                {
                  "name": "currency",
                  "type": "varchar"
                }
              ],
              "createTableAs": true,
              "query": "SELECT * FROM (\n  VALUES (10.00, 50.00, 'USD')\n) AS t (cost_per_gigabyte_hour, cost_per_cpu_hour, currency)\n",
              "schema": "default",
              "tableName": "example_baremetal_cost"
            }
          },
          {
            "apiVersion": "metering.openshift.io/v1",
            "kind": "HiveTable",
            "metadata": {
              "name": "apache-log",
              "annotations": {
                "reference": "based on the RegEx example from https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-RowFormats&SerDe"
              }
            },
            "spec": {
              "columns": [
                {
                  "name": "host",
                  "type": "string"
                },
                {
                  "name": "identity",
                  "type": "string"
                },
                {
                  "name": "user",
                  "type": "string"
                },
                {
                  "name": "time",
                  "type": "string"
                },
                {
                  "name": "request",
                  "type": "string"
                },
                {
                  "name": "status",
                  "type": "string"
                },
                {
                  "name": "size",
                  "type": "string"
                },
                {
                  "name": "referer",
                  "type": "string"
                },
                {
                  "name": "agent",
                  "type": "string"
                }
              ],
              "databaseName": "default",
              "external": true,
              "fileFormat": "TEXTFILE",
              "location": "s3a://my-bucket/apache_logs",
              "rowFormat": "SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe'\nWITH SERDEPROPERTIES (\n  \"input.regex\" = \"([^ ]*) ([^ ]*) ([^ ]*) (-|\\\\[[^\\\\]]*\\\\]) ([^ \\\"]*|\\\"[^\\\"]*\\\") (-|[0-9]*) (-|[0-9]*)(?: ([^ \\\"]*|\\\"[^\\\"]*\\\") ([^ \\\"]*|\\\"[^\\\"]*\\\"))?\"\n)\n",
              "tableName": "apache_log"
            }
          }
        ]

  subscriptionName: metering-ocp
  subscriptionChannel: "4.6"
  subscriptionNamespace: openshift-metering
  catalogSourceConfigMapName: metering-ocp
  catalogSourceName: metering-ocp-dev
  catalogSourceNamespace: openshift-metering
  catalogSourceTargetNamespace: openshift-metering
  operatorGroupName: metering-operators
  operatorGroupNamespace: openshift-metering
  operatorGroupTargetNamespaces: ["openshift-metering"]
  telemeterManifestGeneration: false
