kustomization.yaml 1.09 KB
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component

configMapGenerator:
  - name: deployment-config
    options:
      disableNameSuffixHash: true
#    behavior: merge
    envs:
      - deployment-config.env

replacements:
  - source:
      kind: ConfigMap
      version: v1
      name: deployment-config
      fieldPath: data.PARENT_POD_NAME
    targets:
      - select:
          kind: Pod
          name: postgresql-server-
        fieldPaths:
          - metadata.ownerReferences.0.name
      - select:
          kind: Service
          name: postgresql-server-
        fieldPaths:
          - metadata.ownerReferences.0.name
  - source:
      kind: ConfigMap
      version: v1
      name: deployment-config
      fieldPath: data.PARENT_POD_UID
    targets:
      - select:
          kind: Pod
          name: postgresql-server-
        fieldPaths:
          - metadata.ownerReferences.0.uid
          - metadata.labels.owner-uid
      - select:
          kind: Service
          name: postgresql-server-
        fieldPaths:
          - metadata.ownerReferences.0.uid
          - spec.selector.owner-uid