Uploaded image for project: 'Red Hat Advanced Cluster Management'
  1. Red Hat Advanced Cluster Management
  2. ACM-2156

"lookup" functionality for included or current namespace

XMLWordPrintable

    • Icon: Feature Feature
    • Resolution: Done
    • Icon: Major Major
    • ACM 2.7.3
    • None
    • GRC
    • False
    • None
    • False
    • Not Selected

      Customer is using a "Policy" object to create Kubernetes objects in certain clusters. The customer is looking for a way to access the name of the namespace where the Kubernetes object is created in.

      So for example if they set the "namespaceSelector" to include some namespaces. The customer would like to access the names of the included namespaces in the "lookup" query. See the example policy below.

      Alternatively, this requests looks at a way (variables or similar) to refer to the currently defined namespace in a "Policy".

      apiVersion: policy.open-cluster-management.io/v1
      kind: Policy
      ...
      spec:
        policy-templates:
          - objectDefinition:
          ...
              spec:
                namespaceSelector:
                  include:
                    - poi-accos-dev
                    - poi-ebilling-dev
                object-templates:
                  - complianceType: musthave
                    objectDefinition:
                      apiVersion: networking.k8s.io/v1
                      kind: NetworkPolicy
                      metadata:
                        name: allow-from-accos-ebilling-dev-projects
                      spec:
                        ingress:
                        - from:
                          - namespaceSelector:
                              matchLabels:
                                poi-network-access:  '{{ (lookup "v1" "Namespace" "<NAMESPACE_NAME>" "<NAMESPACE_NAME>").metadata.labels.poi-network-access }}'
                        podSelector: {}
                        policyTypes:
                        - Ingress

            rhn-support-cstark Christian Stark
            rhn-support-skrenger Simon Krenger
            Derek Ho Derek Ho
            Christian Stark Christian Stark
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: