portworx / helm

Repository for Portworx Helm assets
Apache License 2.0
48 stars 63 forks source link

PWX-37566 | Add missing fields for monitoring #593

Closed hitesh-wani-px closed 1 month ago

hitesh-wani-px commented 2 months ago

What this PR does / why we need it: Add editable missing fields for monitoring in the storageCluster template. Which issue(s) this PR fixes (optional) Closes #https://purestorage.atlassian.net/browse/PWX-37566

Special notes for your reviewer:

hitesh-wani-px commented 2 months ago

Testing Notes: Followed following steps for testing

  1. Create alert manager secret (https://docs.portworx.com/portworx-enterprise/install-portworx/monitoring/monitor-portworx-cluster#set-up-alertmanager)
  2. Add all the possible values for monitoring in the values.yaml Note: Enable CSI for using pvc for the Prometheus
    internalKVDB: true
    csi: true 
    monitoring:
    prometheus:
    enabled: true
    exportMetrics: true
    alertManager: true
    resources:
      requests:
        memory: "64Mi"
        cpu: "250m"
      limits:
        memory: "128Mi"
        cpu: "500m"
    replicas: 5
    retention: "24h"
    retentionSize: "10GiB"
    storage:
      volumeClaimTemplate:
        spec:
          storageClassName: px-csi-db
          accessModes: ["ReadWriteOnce"]
          resources:
            requests:
              storage: 2Gi
    volumes:
      - name: additional-volume
        hostPath:
          path: /mountdata
    volumeMounts:
      - mountPath: /data/prometheus
        name: additional-volume
    securityContext:
      runAsNonRoot: false
    telemetry: true
    grafana: true
  3. Install PX using helm
    helm install my-release --set internalKVDB=true,clusterName=$(uuidgen) ./charts/portworx/ -n portworx --debug
  4. The generated storageCluster template should incorporate all specified values.

    # Source: portworx/templates/storage-cluster.yaml
    kind: StorageCluster
    apiVersion: core.libopenstorage.org/v1
    metadata:
    name: "mycluster"
    namespace: kube-system
    annotations:
    labels:
    heritage: "Helm"
    release: "my-release"
    chart: "portworx-3.1.0"
    app.kubernetes.io/managed-by: "Helm"
    app.kubernetes.io/instance: "my-release"
    spec:
    image: portworx/oci-monitor:3.1.0
    imagePullPolicy: Always
    
    kvdb:
    internal: true
    storage:
    useAll: true
    secretsProvider: k8s
    
    env:
    - name: PX_SECRETS_NAMESPACE
    value: portworx
    
    stork:
    enabled: true
    monitoring:
    prometheus:
      enabled: true
      exportMetrics: true
      alertManager:
        enabled: true
      replicas: 2
      retention: 24h
      retentionSize: 10GiB
      resources:
        limits:
          cpu: 500m
          memory: 128Mi
        requests:
          cpu: 250m
          memory: 64Mi
      storage:
        volumeClaimTemplate:
          spec:
            accessModes:
            - ReadWriteOnce
            resources:
              requests:
                storage: 2Gi
            storageClassName: px-csi-db
      volumes:
      - hostPath:
          path: /mountdata
        name: additional-volume
      volumeMounts:
      - mountPath: /data/prometheus
        name: additional-volume
    telemetry:
      enabled: true
    grafana:
      enabled: true
    csi:
    enabled: false
  5. We should be able to see the following configurations reflected on the cluster:
    1. Telemetry pods should be running.
    2. Grafana pods should be deployed and running.
    3. Alert manager pods must be running on the cluster.
    4. The Prometheus configuration specified in values.yaml should be reflected in the Prometheus CRD. Use the command:
      kubectl get prometheus -n portworx -o yaml
      1. We should able to see equal no of Prometheus replicas as specified in the prometheus.replicas of values.yaml
      2. We should able to see pods deployed with same configuration (volume,volumemount,resources,storage) and retention and retentionSize values should be pass as args for Prometheus container

Unit test cases Results:

--- PASS: TestStorageClusterHelmTemplate (0.00s)
    --- PASS: TestStorageClusterHelmTemplate/TestExternalETCD (0.07s)
    --- PASS: TestStorageClusterHelmTemplate/TestPlacementTolerations (0.08s)
    --- PASS: TestStorageClusterHelmTemplate/TestMonitoringConditionByEnablingTelemetry (0.08s)
    --- PASS: TestStorageClusterHelmTemplate/TestMonitoringWithAllValues (0.08s)
    --- PASS: TestStorageClusterHelmTemplate/TestCustomRegistry (0.08s)
    --- PASS: TestStorageClusterHelmTemplate/TestAllComponentsEnabled (0.09s)
    --- PASS: TestStorageClusterHelmTemplate/TestDefaultChartValues (0.09s)
PASS
ok      github.com/portworx/helm/test/portworx  0.122s