Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The config.kubernetes.io/local-config: "true" is too strict #4124

Closed
kferrone opened this issue Aug 17, 2021 · 4 comments · Fixed by #4180
Closed

The config.kubernetes.io/local-config: "true" is too strict #4124

kferrone opened this issue Aug 17, 2021 · 4 comments · Fixed by #4180
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@kferrone
Copy link

Describe the bug

When using the annotation config.kubernetes.io/local-config: "true"; you can not reference the resource. It is completely ignored. I would still like to have it as a referenced resource up until the final output when all with the annotation is removed.

Files that can reproduce the issue

pod.yaml

apiVersion: v1
kind: Pod
metadata:
  name: buildup
  annotations:
    config.kubernetes.io/local-config: "true"
spec:
  containers:
    - name: app
      image: nginx
  restartPolicy: Always

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: buildup

replacement.yaml

apiVersion: builtin
kind: ReplacementTransformer
metadata:
  name: buildup
replacements:
- source: 
    kind: Pod
    fieldPath: spec
  targets:
  - select:
      kind: Deployment
    fieldPaths: 
    - spec.template.spec
    options:
      create: true

kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
commonLabels:
  app.kubernetes.io/name: buildup
resources:
- pod.yaml
- deployment.yaml
transformers:
- replacement.yaml

Expected output

I expect only the deployment to be displayed with the values which were replaced from the Pod. The annotation is working in the sense it is excluding the resource in the final output, however it seems it was removed too soon as I can't reference it in the replacement.

here is what the result should be:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/managed-by: kustomize-v4.2.0
    app.kubernetes.io/name: buildup
  name: buildup
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: buildup
  template:
    metadata:
      labels:
        app.kubernetes.io/name: buildup
    spec:
      containers:
      - image: nginx
        name: app
      restartPolicy: Always

Actual output

Basically the replacement transformer failed to find the Pod I told it to target.

Error: nothing selected by ~G_~V_Pod|~X|~N:spec

Kustomize version

{Version:kustomize/v4.2.0 GitCommit:d53a2ad45d04b0264bcee9e19879437d851cb778 BuildDate:2021-07-01T00:44:28+01:00 GoOs:darwin GoArch:amd64}

Platform

all

Additional context

I can add the annotation after the replacement but then kustomize doesn't actually remove the resource from the output

@kferrone kferrone added the kind/bug Categorizes issue or PR as related to a bug. label Aug 17, 2021
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Aug 17, 2021
@natasha41575
Copy link
Contributor

I am in favor of keeping local-config annotated resources available to be used by transformers in the same kustomization layer, and see little reason why this would be undesirable. Unless other maintainers disagree, I am inclined to accept this as a feature request.

@natasha41575 natasha41575 added the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Sep 1, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Sep 1, 2021
@natasha41575
Copy link
Contributor

/assign @yuwenma

@k8s-ci-robot
Copy link
Contributor

@natasha41575: GitHub didn't allow me to assign the following users: yuwenma.

Note that only kubernetes-sigs members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @yuwenma

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.

@yuwenma
Copy link
Contributor

yuwenma commented Sep 8, 2021

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants