Deploy the Percona PMM via helm compatibility with non root

Description:

We are not able to deploy the PMM-server via Helm with non-root. As in Production we would not get and privileged SCC.

So the helm chart should be compatible with non-root.

Steps to Reproduce:

  1. Download the PMM helm chart.
    # helm repo add percona Percona Helm Charts | percona-helm-charts
    # helm repo update
    # helm pull percona/pmm --version 1.8.1 --debug
  2. Untar the folder.
    # tar xvzf pmm-1.8.1.tgz
  3. the existing values .yaml in this helm chart is not compatible to run with non-root user.

Version:

# oc get pod pmm-server-0 -o jsonpath='{.spec.containers[*].image}{"\n"}'
percona/pmm-server:3.8.1

Logs:

Expected Result:

pmm-server pod should get deployed.

Actual Result:

The statefulset is not ready and pmm-server pods gos in crashloopbackoff.

Additional Information:

Below values.yaml worked for us to deploy the pmm-server.

# cat values.yaml
## @section Percona Monitoring and Management (PMM) parameters
## Default values for PMM.
## This is a YAML-formatted file.
## Declare variables to be passed into your templates.

## PMM image version
## ref: https://hub.docker.com/r/percona/pmm-server/tags
## @param image.repository PMM image repository
## @param image.pullPolicy PMM image pull policy
## @param image.tag PMM image tag (immutable tags are recommended)
## @param image.imagePullSecrets /lobal Docker registry secret names as an array
##
image:
  repository: percona/pmm-server
  pullPolicy: IfNotPresent
  # Overrides the image tag whose default is the chart appVersion.
  tag: "3.8.1"
  imagePullSecrets: []

## PMM environment variables
## ref: https://docs.percona.com/percona-monitoring-and-management/setting-up/server/docker.html#environment-variables
##
pmmEnv:
  ## @param pmmEnv.PMM_ENABLE_UPDATES: '0' Disables a periodic check for new PMM versions as well as ability to apply upgrades using the UI (need to be disabled in k8s environment as updates rolled with helm/container update)
  ##
  PMM_ENABLE_UPDATES: '0'
  PMM_DATA_RETENTION: "2160h" # 90 days
#  optional variables to integrate Grafana with internal iDP, see also secret part
#  GF_AUTH_GENERIC_OAUTH_ENABLED: '1'
#  GF_AUTH_GENERIC_OAUTH_SCOPES: ''
#  GF_AUTH_GENERIC_OAUTH_AUTH_URL: ''
#  GF_AUTH_GENERIC_OAUTH_TOKEN_URL: ''
#  GF_AUTH_GENERIC_OAUTH_API_URL: ''
#  GF_AUTH_GENERIC_OAUTH_ALLOWED_DOMAINS: ''

## @param pmmResources optional [Resources](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/) requested for [PMM container](https://docs.percona.com/percona-monitoring-and-management/setting-up/server/index.html#set-up-pmm-server)
pmmResources:
   requests:
     memory: "32Gi"
     cpu: "8"
   limits:
     memory: "32Gi"
     cpu: "8"
#pmmResources: {}

## Probe Configurations
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes

## Startup probe configuration
## @param startupProbeConf.initialDelaySeconds Number of seconds after the container has started before startup probes is initiated
## @param startupProbeConf.periodSeconds How often (in seconds) to perform the probe
## @param startupProbeConf.failureThreshold When a probe fails, Kubernetes will try failureThreshold times before giving up
## @param startupProbeConf.timeoutSeconds Number of seconds after which the probe times out
##
startupProbeConf:
  initialDelaySeconds: 60
  periodSeconds: 15
  failureThreshold: 20
  timeoutSeconds: 10

## Readiness probe configuration
## @param readyProbeConf.initialDelaySeconds  Number of seconds after the container has started before readiness probes is initiated
## @param readyProbeConf.periodSeconds How often (in seconds) to perform the probe
## @param readyProbeConf.failureThreshold When a probe fails, Kubernetes will try failureThreshold times before giving up
## @param readyProbeConf.timeoutSeconds Number of seconds after which the probe times out
##
readyProbeConf:
  initialDelaySeconds: 30
  periodSeconds: 10
  failureThreshold: 30
  timeoutSeconds: 5

## Liveness probe configuration
## @param livenessProbeConf.initialDelaySeconds Number of seconds after the container has started before liveness probes is initiated
## @param livenessProbeConf.periodSeconds How often (in seconds) to perform the probe
## @param livenessProbeConf.failureThreshold When a probe fails, Kubernetes will try failureThreshold times before giving up
## @param livenessProbeConf.timeoutSeconds Number of seconds after which the probe times out
##
livenessProbeConf:
  initialDelaySeconds: 120
  periodSeconds: 30
  failureThreshold: 10
  timeoutSeconds: 10

## @section PMM secrets
##
secret:
  ## @param secret.name Defines the name of the k8s secret that holds passwords and other secrets
  ##
  name: pmm-secret
  ## @param secret.annotations -- Secret annotations configuration
  annotations: {}
  ## @param secret.create If true then secret will be generated by Helm chart. Otherwise it is expected to be created by user.
  ##
  create: true
  ## @param secret.pmm_password Initial PMM password - it changes only on the first deployment, ignored if PMM was already provisioned and just restarted. If PMM admin password is not set, it will be generated.
  ## E.g.
  ## pmm_password: admin
  ##
  ## To get password execute `kubectl get secret pmm-secret -o jsonpath='{.data.PMM_ADMIN_PASSWORD}' | base64 --decode`
  ##
  pmm_password: "admin"
  ##
  # GF_AUTH_GENERIC_OAUTH_CLIENT_ID optional client ID to integrate Grafana with internal iDP, requires other env defined as well under pmmEnv
  # GF_AUTH_GENERIC_OAUTH_CLIENT_ID:
  # GF_AUTH_GENERIC_OAUTH_CLIENT_SECRET optional secret to integrate Grafana with internal iDP, requires other env defined as well under pmmEnv
  # GF_AUTH_GENERIC_OAUTH_CLIENT_SECRET:

## @param certs Optional certificates, if not provided PMM would use generated self-signed certificates,
##   please provide your own signed ssl certificates like this in base 64 format:
## certs:
  ## name: pmm-certs
  ## files:
  ##  certificate.crt:
  ##  certificate.key:
  ##  ca-certs.pem:
  ##  dhparam.pem:
  ##  certificate.conf:
certs: {}

## @section PMM upgrade configuration
## Upgrade strategy for StatefulSet-based deployments
##
upgrade:
  ## @param upgrade.strategy Strategy to use when upgrading from StatefulSet-based deployments
  ## Options: "rolling" (default), "recreate"
  ## Use "recreate" if you encounter StatefulSet upgrade conflicts
  strategy: "rolling"

  ## @param upgrade.force Force upgrade by recreating StatefulSet if needed
  ## This will cause a brief downtime but ensures upgrade compatibility
  ## Set to true only if you encounter StatefulSet field conflicts
  force: false

## @section PMM network configuration
## Service configuration
##
service:
  ## @param service.name Service name that is dns name monitoring services would send data to. `monitoring-service` used by default by pmm-client in Percona operators.
  ##
  name: monitoring-service
  ## @param service.type Kubernetes Service type
  ##
  type: ClusterIP

  ## Ports 443 and/or 80
  ##
  ports:
    ## @param service.ports[0].port https port number
    - port: 443
      ## @param service.ports[0].targetPort target port to map for statefulset and ingress
      targetPort: https
      ## @param service.ports[0].protocol protocol for https
      protocol: TCP
      ## @param service.ports[0].name port name
      name: https
    ## @param service.ports[1].port http port number
    - port: 80
      ## @param service.ports[1].targetPort target port to map for statefulset and ingress
      targetPort: http
      ## @param service.ports[1].protocol protocol for http
      protocol: TCP
      ## @param service.ports[1].name port name
      name: http

## Ingress controller configuration
##
ingress:
  ## @param ingress.enabled -- Enable ingress controller resource
  enabled: false
  ## @param ingress.nginxInc -- Using ingress controller from NGINX Inc
  nginxInc: false
  ## @param ingress.annotations -- Ingress annotations configuration
  annotations: {}
    ## kubernetes.io/ingress.class: nginx
    ## kubernetes.io/tls-acme: "true"
    ###  nginx proxy to https
    ## nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
  ## @param ingress.community.annotations -- Ingress annotations configuration for community managed ingress (nginxInc = false)
  community:
    annotations: {}
      ## kubernetes.io/ingress.class: nginx
      ## kubernetes.io/tls-acme: "true"
  ## @param ingress.ingressClassName -- Sets the ingress controller class name to use.
  ingressClassName: ""

  ## Ingress resource hostnames and path mappings
  hosts:
    ## @param ingress.hosts[0].host hostname
    - host: chart-example.local
    ## @param ingress.hosts[0].paths path mapping
      paths: []

  ## @param ingress.pathType -- How ingress paths should be treated.
  pathType: Prefix

  ## @param ingress.tls -- Ingress TLS configuration
  tls: []
  ##  - secretName: chart-example-tls
  ##    hosts:
  ##      - chart-example.local

## @section PMM storage configuration
## Claiming storage for PMM using Persistent Volume Claims (PVC)
## ref: https://kubernetes.io/docs/user-guide/persistent-volumes/
##
storage:
  ## @param storage.name name of PVC
  name: pmm-storage
  ## @param storage.storageClassName optional PMM data Persistent Volume Storage Class
  ## If defined, storageClassName: <storageClass>
  ## If set to "-", storageClassName: "", which disables dynamic provisioning
  ## If undefined (the default) or set to null, no storageClassName spec is
  ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
  ##   GKE, AWS & OpenStack)
  ##
  storageClassName: "ocs-storagecluster-ceph-rbd"
  ##
  ## @param storage.size size of storage [depends](https://docs.percona.com/percona-monitoring-and-management/setting-up/server/index.html#set-up-pmm-server) on number of monitored services and data retention
  ##
  size: 50Gi
  ##
  ## @param storage.dataSource VolumeSnapshot to start from
  ##
  dataSource: {}
    ## name: before-vX.Y.Z-upgrade
    ## kind: VolumeSnapshot
    ## apiGroup: snapshot.storage.k8s.io
  ##
  ## @param storage.selector select existing PersistentVolume
  ##
  selector: {}
  ##   matchLabels:
  ##     release: "stable"
  ##   matchExpressions:
  ##     - key: environment
  ##       operator: In
  ##       values:
  ##         - dev

## @section PMM kubernetes configurations
## @param nameOverride String to partially override common.names.fullname template with a string (will prepend the release name)
##
nameOverride: ""

## @param namespaceOverride String to override namespace. Defaults to the value of .Release.Namespace.
##
namespaceOverride: ""

## @param extraLabels Labels to add to all deployed objects
##
extraLabels: {}

## Pods Service Account
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/
## @param serviceAccount.create Specifies whether a ServiceAccount should be created
## @param serviceAccount.annotations Annotations for service account. Evaluated as a template. Only used if `create` is `true`.
## @param serviceAccount.name Name of the service account to use. If not set and create is true, a name is generated using the fullname template.
##
serviceAccount:
  create: true
  annotations: {}
  name: "pmm-sa"

## @param podAnnotations Pod annotations
## ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/
##
podAnnotations: {}

## @param podSecurityContext Configure Pods Security Context
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
## E.g
podSecurityContext:
  runAsUser: 1001020200
  runAsGroup: 1001020000
  fsGroup: 1001020000
  fsGroupChangePolicy: OnRootMismatch
  runAsNonRoot: true
  seccompProfile:
    type: RuntimeDefault


## @param securityContext Configure Container Security Context
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
## securityContext.capabilities The capabilities to add/drop when running containers
## securityContext.runAsUser Set pmm containers' Security Context runAsUser
## securityContext.runAsNonRoot Set pmm container's Security Context runAsNonRoot
## E.g.
## securityContext:
  ## capabilities:
  ##   drop:
  ##   - ALL
  ## readOnlyRootFilesystem: true
  ## runAsNonRoot: true
  ## runAsUser: 1000
securityContext:
  capabilities:
    drop:
    - ALL
  allowPrivilegeEscalation: false

## @param nodeSelector Node labels for pod assignment
## Ref: https://kubernetes.io/docs/user-guide/node-selection/
##
nodeSelector: {}

## @param tolerations Tolerations for pod assignment
## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
##
tolerations: []

## @param affinity Affinity for pod assignment
## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
##
affinity: {}

## @param extraVolumes Optionally specify extra list of additional volumes
##
extraVolumes:
  - name: pmm-config
    emptyDir: {}
  - name: nginx-run
    emptyDir: {}
  - name: supervisord-config
    emptyDir: {}
  - name: pmm-maintenance
    emptyDir: {}

## @param extraVolumeMounts Optionally specify extra list of additional volumeMounts
##
extraVolumeMounts:
  - name: pmm-config
    mountPath: /usr/local/percona/pmm/config
  - name: nginx-run
    mountPath: /run
  - name: supervisord-config
    mountPath: /etc/supervisord.d
  - name: pmm-maintenance
    mountPath: /usr/share/pmm-server/maintenance

## @param initContainers Optionally specify extra list of init containers
##
initContainers:
  - name: seed-supervisord-config
    image: percona/pmm-server:3.8.1
    imagePullPolicy: IfNotPresent
    command: ["/bin/sh", "-ec"]
    args:
      - |
        mkdir -p /work/run/postgresql /work/run/supervisor
        mkdir -p /work/supervisord.d
        cp -R /etc/supervisord.d/. /work/supervisord.d/
        find /work/supervisord.d -mindepth 1 -exec chmod u+rwX {} +
    securityContext:
      allowPrivilegeEscalation: false
      capabilities:
        drop:
          - ALL
    volumeMounts:
      - name: nginx-run
        mountPath: /work/run
      - name: supervisord-config
        mountPath: /work/supervisord.d