kustomize icon indicating copy to clipboard operation
kustomize copied to clipboard

Support for selector and rejects in replacements source

Open morix1500 opened this issue 2 years ago • 7 comments

Support for selector and rejects in replacements source. Related issue: https://github.com/kubernetes-sigs/kustomize/issues/4763

Example

In this example, Replace the pod's configMapRef.name with the Secret's metadata.name selected in the label.

resource.yaml

apiVersion: v1
kind: Secret
metadata:
  name: test1
  labels:
    name: test1
    type: secret
---
apiVersion: v1
kind: Secret
metadata:
  name: test2
  labels:
    name: test2
    type: secret
---
apiVersion: v1
kind: Pod
metadata:
  name: test
spec:
  containers:
    - name: nginx
      image: nginx
      envFrom:
        - configMapRef:
            name: TO_BE_REPLACED

kustomization.yaml

resources:
  - resource.yaml

replacements:
  - source:
      select:
        labelSelector: "type=secret"
      reject:
        - labelSelector: "name=test1"
      fieldPath: metadata.name
    targets:
      - select:
          version: v1
          kind: Pod
          name: test
        fieldPaths:
          - spec.containers.0.envFrom.0.configMapRef.name

output:

apiVersion: v1
kind: Secret
metadata:
  labels:
    name: test1
    type: secret
  name: test1
---
apiVersion: v1
kind: Secret
metadata:
  labels:
    name: test2
    type: secret
  name: test2
---
apiVersion: v1
kind: Pod
metadata:
  name: test
spec:
  containers:
  - envFrom:
    - configMapRef:
        name: test2
    image: nginx
    name: nginx

morix1500 avatar Jul 07 '23 12:07 morix1500

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: morix1500 Once this PR has been reviewed and has the lgtm label, please assign knverey for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

k8s-ci-robot avatar Jul 07 '23 12:07 k8s-ci-robot

Hi @morix1500. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Jul 07 '23 12:07 k8s-ci-robot

/ok-to-test

natasha41575 avatar Aug 18 '23 17:08 natasha41575

@morix1500: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
kustomize-presubmit-master 72efc06993882a6e91ce8d4da81dcdb38056f714 link true /test kustomize-presubmit-master

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

k8s-ci-robot avatar Aug 18 '23 17:08 k8s-ci-robot

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Jan 21 '24 22:01 k8s-triage-robot

Hopefully I'm doing the right thing here. We've run into a need for this PR to get wrapped up. If I cannot get in touch with the original writers I'll see if I can take it on.

/remove-lifecycle stale

avosepp avatar Jan 26 '24 20:01 avosepp

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Apr 25 '24 20:04 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle rotten
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar May 25 '24 21:05 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

k8s-triage-robot avatar Jun 24 '24 21:06 k8s-triage-robot

@k8s-triage-robot: Closed this PR.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Reopen this PR with /reopen
  • Mark this PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

k8s-ci-robot avatar Jun 24 '24 21:06 k8s-ci-robot

Any news? Thanks

jsolana avatar Sep 06 '24 09:09 jsolana