mercedes-benz / garm-operator

a k8s operator to run garm
MIT License
19 stars 2 forks source link

Add kube-state-metric config #58

Closed rafalgalaw closed 7 months ago

rafalgalaw commented 9 months ago

What is the feature you would like to have?

To provid meaningful metrics on the state of garm-operator owned resources one can deploy the kube-state-metrics chart like:

$ helm repo add prometheus-community https://prometheus-community.github.io/helm-charts && helm repo update

followed by a

helm upgrade --install garm prometheus-community/kube-state-metrics -f ./helm/kube-state-metrics/values.yaml -n kube-state-metrics --create-namespace

It would be nice, if garm-operator adds the kube-state-metrics config-map as a release manifest to observe all CRs:

apiVersion: v1
kind: ConfigMap
metadata:
  name: garm-kube-state-metrics-customresourcestate-config
  namespace: kube-state-metrics
  labels:    
    helm.sh/chart: kube-state-metrics-5.15.2
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: metrics
    app.kubernetes.io/part-of: kube-state-metrics
    app.kubernetes.io/name: kube-state-metrics
    app.kubernetes.io/instance: garm
    app.kubernetes.io/version: "2.10.1"
data:
  config.yaml: |
    kind: CustomResourceStateMetrics
    spec:
      resources:
      - commonLabels:
          crd_type: enterprise
        groupVersionKind:
          group: garm-operator.mercedes-benz.com
          kind: Enterprise
          version: v1alpha1
        labelsFromPath:
          name:
          - metadata
          - name
        metricNamePrefix: garm_operator
        metrics:
        - each:
            gauge:
              path:
              - metadata
              - creationTimestamp
            type: Gauge
          help: Unix creation timestamp.
          name: enterprise_created
        - each:
            gauge:
              nilIsZero: true
              path:
              - status
              - poolManagerIsRunning
            type: Gauge
          help: Whether the enterprises poolManager is running.
          name: enterprise_pool_manager_running
        - each:
            info:
              labelsFromPath:
                credentialsName:
                - spec
                - credentialsName
                id:
                - status
                - id
                webhookSecretRefKey:
                - spec
                - webhookSecretRef
                - key
                webhookSecretRefName:
                - spec
                - webhookSecretRef
                - name
            type: Info
          help: Information about an enterprise.
          name: enterprise_info
        - each:
            info:
              labelsFromPath:
                paused_value: []
              path:
              - metadata
              - annotations
              - garm-operator.mercedes-benz.com/paused
            type: Info
          help: Whether the enterprise reconciliation is paused.
          name: enterprise_annotation_paused_info
        namespace:
        - metadata
        - namespace
      - commonLabels:
          crd_type: organization
        groupVersionKind:
          group: garm-operator.mercedes-benz.com
          kind: Organization
          version: v1alpha1
        labelsFromPath:
          name:
          - metadata
          - name
        metricNamePrefix: garm_operator
        metrics:
        - each:
            gauge:
              path:
              - metadata
              - creationTimestamp
            type: Gauge
          help: Unix creation timestamp.
          name: org_created
        - each:
            gauge:
              nilIsZero: true
              path:
              - status
              - poolManagerIsRunning
            type: Gauge
          help: Whether the orgs poolManager is running.
          name: org_pool_manager_running
        - each:
            info:
              labelsFromPath:
                credentialsName:
                - spec
                - credentialsName
                id:
                - status
                - id
                webhookSecretRefKey:
                - spec
                - webhookSecretRef
                - key
                webhookSecretRefName:
                - spec
                - webhookSecretRef
                - name
            type: Info
          help: Information about an enterprise.
          name: org_info
        - each:
            info:
              labelsFromPath:
                paused_value: []
              path:
              - metadata
              - annotations
              - garm-operator.mercedes-benz.com/paused
            type: Info
          help: Whether the org reconciliation is paused.
          name: org_annotation_paused_info
        namespace:
        - metadata
        - namespace
      - commonLabels:
          crd_type: repository
        groupVersionKind:
          group: garm-operator.mercedes-benz.com
          kind: Repository
          version: v1alpha1
        labelsFromPath:
          name:
          - metadata
          - name
        metricNamePrefix: garm_operator
        metrics:
        - each:
            gauge:
              path:
              - metadata
              - creationTimestamp
            type: Gauge
          help: Unix creation timestamp.
          name: repo_created
        - each:
            gauge:
              nilIsZero: true
              path:
              - status
              - poolManagerIsRunning
            type: Gauge
          help: Whether the repositories poolManager is running.
          name: repo_pool_manager_running
        - each:
            info:
              labelsFromPath:
                credentialsName:
                - spec
                - credentialsName
                id:
                - status
                - id
                owner:
                - spec
                - owner
                webhookSecretRefKey:
                - spec
                - webhookSecretRef
                - key
                webhookSecretRefName:
                - spec
                - webhookSecretRef
                - name
            type: Info
          help: Information about a repository.
          name: repo_info
        - each:
            info:
              labelsFromPath:
                paused_value: []
              path:
              - metadata
              - annotations
              - garm-operator.mercedes-benz.com/paused
            type: Info
          help: Whether the repo reconciliation is paused.
          name: repo_annotation_paused_info
        namespace:
        - metadata
        - namespace
      - commonLabels:
          crd_type: pool
        groupVersionKind:
          group: garm-operator.mercedes-benz.com
          kind: Pool
          version: v1alpha1
        labelsFromPath:
          name:
          - metadata
          - name
        metricNamePrefix: garm_operator
        metrics:
        - each:
            gauge:
              path:
              - metadata
              - creationTimestamp
            type: Gauge
          help: Unix creation timestamp.
          name: pool_created
        - each:
            gauge:
              path:
              - status
              - creationTimestamp
            type: Gauge
          help: Unix creation timestamp.
          name: pool_min_idle_runner
        - each:
            info:
              labelsFromPath:
                enabled:
                - spec
                - enabled
                githubRunnerGroup:
                - spec
                - githubRunnerGroup
                id:
                - status
                - id
                imageName:
                - spec
                - imageName
                maxRunners:
                - spec
                - maxRunners
                minIdleRunners:
                - spec
                - minIdleRunners
                osArch:
                - spec
                - osArch
                osType:
                - spec
                - osType
                providerName:
                - spec
                - providerName
                runnerBootstrapTimeout:
                - spec
                - runnerBootstrapTimeout
                runnerPrefix:
                - spec
                - runnerPrefix
                scopeKind:
                - spec
                - githubScopeRef
                - kind
                scopeName:
                - spec
                - githubScopeRef
                - name
                tags:
                - spec
                - tags
            type: Info
          help: Information about a pool.
          name: pool_info
        - each:
            info:
              labelsFromPath:
                paused_value: []
              path:
              - metadata
              - annotations
              - garm-operator.mercedes-benz.com/paused
            type: Info
          help: Whether the pool reconciliation is paused.
          name: pool_annotation_paused_info
        namespace:
        - metadata
        - namespace
      - commonLabels:
          crd_type: image
        groupVersionKind:
          group: garm-operator.mercedes-benz.com
          kind: Image
          version: v1alpha1
        labelsFromPath:
          name:
          - metadata
          - name
        metricNamePrefix: garm_operator
        metrics:
        - each:
            gauge:
              path:
              - metadata
              - creationTimestamp
            type: Gauge
          help: Unix creation timestamp.
          name: image_created
        - each:
            info:
              labelsFromPath:
                tag:
                - spec
                - tag
            type: Info
          help: Information about an image.
          name: image_info
        namespace:
        - metadata
        - namespace

Anything else you would like to add?

Is it enough to just add the config map? Or should we provide ready to install kube-state-metrics deploy manifests? Where in the repo should this be maintained?

bavarianbidi commented 7 months ago

closed with https://github.com/mercedes-benz/garm-operator/pull/92 and https://github.com/mercedes-benz/garm-operator/pull/75