gatekeeper icon indicating copy to clipboard operation
gatekeeper copied to clipboard

Mutate pod spec with its namespace in dnsConfig.searches

Open prabhatsingh014 opened this issue 10 months ago • 1 comments

I have a use case where I would like to mutate a pod spec with dnsConfig and dnsPolicy with following during creation or update when:

  • It is not present on the pod spec (could be a part of deployment or statefulset).
  • Or, it is set to something else on the pod spec.
  dnsPolicy: "None"
  dnsConfig:
    nameservers:
      - 192.0.2.1
    searches:
      - <namespace>.svc.cluster-domain.example
      - svc.cluster-domain.example
      - cluster-domain.example
    options:
      - name: ndots
        value: "1"

I was able to achieve the following with current support provided by Assign and ModifySet as explained here.

  dnsPolicy: "None"
  dnsConfig:
    nameservers:
      - 192.0.2.1
    searches:
      - svc.cluster-domain.example
      - cluster-domain.example
    options:
      - name: ndots
        value: "1"

But I am unable to mutate <namespace>.svc.cluster.local , here is <namespace> would be pod's namespace on which mutation is going to be applied. I was trying to search through the documentation and came to know that fetching namespace metadata dynamically is not possible with the existing support on Assign or ModifySet objects. Is there any other alternate I can use to implement this?

prabhatsingh014 avatar May 26 '25 15:05 prabhatsingh014

@prabhatsingh014 Curretnly this is not a usecase supported by GK mutations. However you should be able to satisfy this use case with MAP. We are currently tracking all MAP support and different mutations usecases here - https://github.com/open-policy-agent/gatekeeper/issues/3477. Feel free to upvote or leave any comments/feedback on there.

JaydipGabani avatar Jun 09 '25 19:06 JaydipGabani

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 08 '25 19:08 stale[bot]