mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-14 10:30:59 +00:00
support var ref in deployment template annotations
This commit is contained in:
@@ -87,6 +87,9 @@ varReference:
|
|||||||
- path: spec/template/spec/volumes/nfs/server
|
- path: spec/template/spec/volumes/nfs/server
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
|
|
||||||
|
- path: spec/template/metadata/annotations
|
||||||
|
kind: Deployment
|
||||||
|
|
||||||
- path: spec/rules/host
|
- path: spec/rules/host
|
||||||
kind: Ingress
|
kind: Ingress
|
||||||
|
|
||||||
|
|||||||
@@ -1969,3 +1969,70 @@ spec:
|
|||||||
server: kustomized-nfs-server-service.default.srv.cluster.local
|
server: kustomized-nfs-server-service.default.srv.cluster.local
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDeploymentAnnotations(t *testing.T) {
|
||||||
|
th := kusttest_test.MakeHarness(t)
|
||||||
|
th.WriteK("/app", `
|
||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
|
||||||
|
configMapGenerator:
|
||||||
|
- name: testConfigMap
|
||||||
|
envs:
|
||||||
|
- test.properties
|
||||||
|
|
||||||
|
vars:
|
||||||
|
- name: FOO
|
||||||
|
objref:
|
||||||
|
kind: ConfigMap
|
||||||
|
name: testConfigMap
|
||||||
|
apiVersion: v1
|
||||||
|
fieldref:
|
||||||
|
fieldpath: data.foo
|
||||||
|
|
||||||
|
commonAnnotations:
|
||||||
|
foo: $(FOO)
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- deployment.yaml
|
||||||
|
`)
|
||||||
|
|
||||||
|
th.WriteF("/app/deployment.yaml", `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: test
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: test
|
||||||
|
`)
|
||||||
|
th.WriteF("/app/test.properties", `foo=bar`)
|
||||||
|
m := th.Run("/app", th.MakeDefaultOptions())
|
||||||
|
th.AssertActualEqualsExpected(m, `
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
foo: bar
|
||||||
|
name: test
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
foo: bar
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: test
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
foo: bar
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
foo: bar
|
||||||
|
name: testConfigMap-798k5k7g9f
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user