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

vars cannot be resolved in 3.9.0: vars are not found in corresponding resource #3377

Closed
binepedia opened this issue Dec 21, 2020 · 0 comments · Fixed by #3484
Closed

vars cannot be resolved in 3.9.0: vars are not found in corresponding resource #3377

binepedia opened this issue Dec 21, 2020 · 0 comments · Fixed by #3484
Assignees
Labels
area/plugin issues for plugins kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@binepedia
Copy link

binepedia commented Dec 21, 2020

When using kustomize 3.8.8 everythings works just fine. in 3.9.0 however I'll get the error

Error: field specified in var '{SERVICE_A_DNS_NAME networking.k8s.io_v1_Ingress {spec.rules[0].host}}' not found in corresponding resource

Files that can reproduce the issue

kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - service-a/service-a.yaml
  - service-b/service-b.yaml

patchesJson6902:
  - path: service-a/patch-service-a-ingress.yaml
    target:
      version: v1
      group: networking.k8s.io
      kind: Ingress
      name: service-a
  - path: service-b/patch-service-b-ingress.yaml
    target:
      version: v1
      group: networking.k8s.io
      kind: Ingress
      name: service-b
vars:
  - name: SERVICE_A_DNS_NAME
    objref:
      apiVersion: networking.k8s.io/v1
      kind: Ingress
      name: service-a
    fieldref:
      fieldpath: spec.rules[0].host
  - name: SERVICE_B_DNS_NAME
    objref:
      apiVersion: networking.k8s.io/v1
      kind: Ingress
      name: service-b
    fieldref:
      fieldpath: spec.rules[0].host

service-a/service-a.yaml

---
apiVersion: apps/v1
kind: Deployment
metadata:
   name: service-a
spec:
   replicas: 1
   selector:
      matchLabels:
         app.kubernetes.io/component: service-a
   template:
      metadata:
         labels:
            app.kubernetes.io/component: service-a
      spec:
         containers:
            -  image: repository/service-a:v1
               imagePullPolicy: Always
               name: service-b
               ports:
                  -  containerPort: 8080
               env:
                  -  name: REDIRECT_URI
                     value: "http://$(SERVICE_B_DNS_NAME):80/oauth_redir"

---
apiVersion: v1
kind: Service
metadata:
   name: service-a
   labels:
      app.kubernetes.io/component: service-a
spec:
   type: LoadBalancer
   ports:
      -  port: 8080
   selector:
      app.kubernetes.io/component: service-a
             
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
   name: service-a
spec:
   rules:
      - host: service-a.k8s.com
        http:
           paths:
              -  path: /
                 pathType: Prefix
                 backend:
                    service:
                       name: service-a
                       port:
                          number: 8080

service-a/patch-service-a-ingress.yaml

- op: replace
  path: /spec/rules/0/host
  value: new-service-a.k8s.com

service-b/service-b.yaml

---
apiVersion: apps/v1
kind: Deployment
metadata:
   name: service-b
spec:
   replicas: 1
   selector:
      matchLabels:
         app.kubernetes.io/component: service-b
   template:
      metadata:
         labels:
            app.kubernetes.io/component: service-b
      spec:
         containers:
            -  image: repository/service-b:v1
               imagePullPolicy: Always
               name: service-b
               ports:
                  -  containerPort: 8080
               env:
                  -  name: REDIRECT_URI
                     value: "http://$(SERVICE_A_DNS_NAME):80/oauth_redir"

---
apiVersion: v1
kind: Service
metadata:
   name: service-b
   labels:
      app.kubernetes.io/component: service-b
spec:
   type: LoadBalancer
   ports:
      -  port: 8080
   selector:
      app.kubernetes.io/component: service-b
             
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
   name: service-b
spec:
   rules:
      - host: service-b.k8s.com
        http:
           paths:
              -  path: /
                 pathType: Prefix
                 backend:
                    service:
                       name: service-b
                       port:
                          number: 8080

service-b/patch-service-b-ingress.yaml

- op: replace
  path: /spec/rules/0/host
  value: new-service-b.k8s.com

Expected output
This output was generated with kustomize 3.8.8 with command kustomize build .
The vars are replaced by the url from the patch files.

apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/component: service-a
  name: service-a
spec:
  ports:
  - port: 8080
  selector:
    app.kubernetes.io/component: service-a
  type: LoadBalancer
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/component: service-b
  name: service-b
spec:
  ports:
  - port: 8080
  selector:
    app.kubernetes.io/component: service-b
  type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: service-a
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/component: service-a
  template:
    metadata:
      labels:
        app.kubernetes.io/component: service-a
    spec:
      containers:
      - env:
        - name: REDIRECT_URI
          value: http://new-service-b.k8s.com:80/oauth_redir
        image: repository/service-a:v1
        imagePullPolicy: Always
        name: service-b
        ports:
        - containerPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: service-b
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/component: service-b
  template:
    metadata:
      labels:
        app.kubernetes.io/component: service-b
    spec:
      containers:
      - env:
        - name: REDIRECT_URI
          value: http://new-service-a.k8s.com:80/oauth_redir
        image: repository/service-b:v1
        imagePullPolicy: Always
        name: service-b
        ports:
        - containerPort: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: service-a
spec:
  rules:
  - host: new-service-a.k8s.com
    http:
      paths:
      - backend:
          service:
            name: service-a
            port:
              number: 8080
        path: /
        pathType: Prefix
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: service-b
spec:
  rules:
  - host: new-service-b.k8s.com
    http:
      paths:
      - backend:
          service:
            name: service-b
            port:
              number: 8080
        path: /
        pathType: Prefix

Actual output
This output is printed, when using kustomize 3.9.0 with command kustomize build .

Error: field specified in var '{SERVICE_A_DNS_NAME networking.k8s.io_v1_Ingress {spec.rules[0].host}}' not found in corresponding resource

Kustomize version

kustomize version not working:
{Version:kustomize/v3.9.0 GitCommit:826b5d9792fb67c4d8f8cd59747698ebf0b22720 BuildDate:2020-12-10T21:52:58+00:00 GoOs:darwin GoArch:amd64}

kustomize version working:
{Version:kustomize/v3.8.8 GitCommit:72262c5e7135045ed51b01e417a7e72f558a22b0 BuildDate:2020-12-10T18:44:34+00:00 GoOs:darwin GoArch:amd64}

Platform
macOS 10.15.7

@Shell32-Natsu Shell32-Natsu added area/plugin issues for plugins kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Dec 21, 2020
@binepedia binepedia changed the title vars cannot be resolved in 3.9.0: vars are not found in ccorresponding resource vars cannot be resolved in 3.9.0: vars are not found in corresponding resource Dec 22, 2020
@monopole monopole self-assigned this Jan 20, 2021
monopole added a commit that referenced this issue Jan 20, 2021
monopole added a commit that referenced this issue Jan 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/plugin issues for plugins kind/bug Categorizes issue or PR as related to a bug. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants