{{ if ne .Environment "production" }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: kube-janitor
  namespace: kube-system
data:
  rules.yaml: |-
    # example rules configuration to set TTL for arbitrary objects
    # see https://github.com/hjacobs/kube-janitor for details
    rules:
      - id: require-application-label
        # remove deployments and statefulsets without a label "application"
        resources:
          - deployments
          - statefulsets
        # see http://jmespath.org/specification.html
        jmespath: "!(spec.template.metadata.labels.application) && metadata.creationTimestamp > '2019-04-15'"
        ttl: 7d
      - id: temporary-cdp-namespaces
        # delete all temporary e2e namespaces (created by CDP) with a name starting with "d-*"
        resources:
          - namespaces
        # this uses JMESPath's built-in "starts_with" function
        # see http://jmespath.org/specification.html#starts-with
        jmespath: "starts_with(metadata.name, 'd-')"
        ttl: 24h
{{ end }}

{{ if ne .Environment "production" }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: kube-janitor
  namespace: kube-system
data:
  rules.yaml: |-
    # example rules configuration to set TTL for arbitrary objects
    # see https://github.com/hjacobs/kube-janitor for details
    rules:
      - id: require-application-label
        # remove deployments and statefulsets without a label "application"
        resources:
          - deployments
          - statefulsets
        # see http://jmespath.org/specification.html
        jmespath: "!(spec.template.metadata.labels.application) && metadata.creationTimestamp > '2019-04-15'"
        ttl: 7d
      - id: temporary-cdp-namespaces
        # delete all temporary e2e namespaces (created by CDP) with a name starting with "d-*"
        resources:
          - namespaces
        # this uses JMESPath's built-in "starts_with" function
        # see http://jmespath.org/specification.html#starts-with
        jmespath: "starts_with(metadata.name, 'd-')"
        ttl: 24h
      - id: cleanup-resources-from-pull-requests
        # delete all resources in namespaces matching .*-pr-.* which allows to put resources build from
        # pull requests into a namespace like my-project-pr-123 which get automatically cleaned up after 24h
        # and don't mess up the cluster, see #2930.
        resources:
          - namespaces  
        jmespath: "contains(metadata.name, '-pr-')"
        ttl: 24h   
{{ end }}

Introduce new rule to cleanup resources from pullrequests
Introduce new rule to cleanup resources from pullrequests

The rule cleans up resources in namespaces matching `*.-pr-.*` like `my-app-pr-123`. 
TODO:  we need to inform the developers as we cannot check whether the part after `-pr-` is a number. `my-pr-app` would match, too and would get cleaned up!