Referencing the namespace using variables reports the following warning:
couldn't resolve v: {NAMESPACE noGroup_v1_NAMESPACE {metadata.name}}
When defining the namespace as a resource, the warning is omitted, though the variable not substituted (both cases). Does referencing a name require a special transformer configuration?
This is maybe related to this issue: #401
_kustomization.yaml_
namespace: somename # including or omitting this doesn't seem to make any difference
vars:
- name: NAMEPSPACE
objref:
apiVersion: v1
kind: Namespace
name: somename
resources:
- statefulSet.yaml
- namespace.yaml # omit this for the warning
_statefulSet.yaml_
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: example
spec:
template:
metadata:
name: example
spec:
containers:
- name: proxy
image: openshift/oauth-proxy:v1.0.0
args:
- -client-id=system:serviceaccount:$(NAMESPACE):somename
- '-openshift-sar={"namespace": "$(NAMESPACE)"}'
_namespace.yaml_
apiVersion: apps/v1beta1
kind: Namespace
metadata:
name: somename
@emanuelbuholzer The statefulSet.yaml you pasted here is not valid. The image should be inside an containers array, which is missing.
@Liujingfang1 Oh yes I didn't check the example good enough. I've updated the example, though the issue still remains.
@emanuelbuholzer It should work. If you are on a previous version, can you try 1.0.11?
@lichuqiang I've tested with 1.0.11 and just retried it. The issue remains.
Based on the varreference.go the kind: namespace is not yet supported. @Liujingfang1 Why do you expect it to work?
@emanuelbuholzer you should try this, works with bin from head:
kustomization.yaml
vars:
- name: NAMESPACE
objref:
apiVersion: apps/v1beta1
kind: Namespace
name: somename
From the original description, the variable is NAMEPSPACE with an extra P. Maybe that's the reason.
@Liujingfang1 - does this work ? I tried with the following vars
vars:
- name: NAMESPACE
objref:
kind: Namespace
apiVersion: v1
name: demos-2
And I get the same error like
Error: var '{NAMESPACE ~G_v1_Namespace {metadata.name}}' cannot be mapped to a field in the set of known resources
Most helpful comment
From the original description, the variable is
NAMEPSPACEwith an extraP. Maybe that's the reason.