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

namespace needed in variable declaration for disambiguation #1298

Closed
jbrette opened this issue Jul 2, 2019 · 1 comment
Closed

namespace needed in variable declaration for disambiguation #1298

jbrette opened this issue Jul 2, 2019 · 1 comment

Comments

@jbrette
Copy link
Contributor

jbrette commented Jul 2, 2019

There is a need for to update the variable declaration in the kustomization.yaml by adding an optional namespace field.

The following setup causes an error and would not if the user had the ability to specify the namespace

resources:
- elasticsearch-test-service.yaml
- elasticsearch-dev-service.yaml
vars:
- name: elasticsearch-test-service-name
  objref:
    kind: Service
    name: elasticsearch
    apiVersion: v1
  fieldref:
    fieldpath: metadata.name
- name: elasticsearch-test-protocol
  objref:
    kind: Service
    name: elasticsearch
    apiVersion: v1
  fieldref:
    fieldpath: spec.ports[0].protocol
- name: elasticsearch-dev-service-name
  objref:
    kind: Service
    name: elasticsearch
    apiVersion: v1
  fieldref:
    fieldpath: metadata.name
- name: elasticsearch-dev-protocol
  objref:
    kind: Service
    name: elasticsearch
    apiVersion: v1
  fieldref:
    fieldpath: spec.ports[0].protocol
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: elasticsearch
  namespace: dev
spec:
  template:
    spec:
      containers:
        - name: elasticsearch
          env:
            - name: DISCOVERY_SERVICE
              value: "$(elasticsearch-dev-service-name).monitoring.svc.cluster.local"
            - name: DISCOVERY_PROTOCOL
              value: "$(elasticsearch-dev-protocol)"
---
apiVersion: v1
kind: Service
metadata:
  name: elasticsearch
  namespace: dev
spec:
  ports:
    - name: transport
      port: 9300
      protocol: TCP
  clusterIP: None
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: elasticsearch
  namespace: test
spec:
  template:
    spec:
      containers:
        - name: elasticsearch
          env:
            - name: DISCOVERY_SERVICE
              value: "$(elasticsearch-test-service-name).monitoring.svc.cluster.local"
            - name: DISCOVERY_PROTOCOL
              value: "$(elasticsearch-test-protocol)"
---
apiVersion: v1
kind: Service
metadata:
  name: elasticsearch
  namespace: test
spec:
  ports:
    - name: transport
      port: 9300
      protocol: UDP
  clusterIP: None

The output is:

Error: merging vars [{elasticsearch-test-service-name ~G_~V_Service {metadata.name}} {elasticsearch-test-protocol ~G_~V_Service {spec.ports[0].protocol}} {elasticsearch-dev-service-name ~G_~V_Service {metadata.name}} {elasticsearch-dev-protocol ~G_~V_Service {spec.ports[0].protocol}}]: found 2 resId matches for var {elasticsearch-test-service-name ~G_v1_Service {metadata.name}} (unable to disambiguate)
@jbrette
Copy link
Contributor Author

jbrette commented Jul 24, 2019

The following PR has been merged

@jbrette jbrette closed this as completed Jul 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant