mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 09:24:23 +00:00
doc: add varReference example
This commit is contained in:
@@ -15,13 +15,17 @@ k8s Secret object in a container's environment variable,
|
|||||||
so that the following would work:
|
so that the following would work:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
# consider it is a deployment
|
||||||
containers:
|
containers:
|
||||||
- image: myimage
|
- image: myimage
|
||||||
command: ["start", "--host", "$(MY_SERVICE_NAME)"]
|
command: ["start", "--host", "$(MY_SERVICE_NAME)"]
|
||||||
env:
|
env:
|
||||||
- name: SECRET_TOKEN
|
- name: SECRET_TOKEN
|
||||||
value: $(SOME_SECRET_NAME)
|
value: $(SOME_SECRET_NAME)
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /healthz
|
||||||
|
port: $(APP_PORT)
|
||||||
```
|
```
|
||||||
|
|
||||||
To do so, add an entry to `vars:` as follows:
|
To do so, add an entry to `vars:` as follows:
|
||||||
@@ -30,6 +34,11 @@ To do so, add an entry to `vars:` as follows:
|
|||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
|
|
||||||
|
configMapGenerator:
|
||||||
|
- name: my-config
|
||||||
|
literals:
|
||||||
|
- MY_PORT=8080
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
- name: SOME_SECRET_NAME
|
- name: SOME_SECRET_NAME
|
||||||
objref:
|
objref:
|
||||||
@@ -50,6 +59,25 @@ vars:
|
|||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
fieldref:
|
fieldref:
|
||||||
fieldpath: spec.template.spec.restartPolicy
|
fieldpath: spec.template.spec.restartPolicy
|
||||||
|
- name: APP_PORT
|
||||||
|
objref:
|
||||||
|
kind: ConfigMap
|
||||||
|
name: my-config
|
||||||
|
apiVersion: v1
|
||||||
|
fieldref:
|
||||||
|
fieldpath: data.MY_PORT
|
||||||
|
|
||||||
|
configurations:
|
||||||
|
- linkage.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
Define the linkage of the consuming resource(s) and the field(s) inside.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# linkage.yaml
|
||||||
|
varReference:
|
||||||
|
- path: spec/template/spec/containers/livenessProbe/httpGet/port
|
||||||
|
kind: Deployment
|
||||||
```
|
```
|
||||||
|
|
||||||
A var is a tuple of variable name, object
|
A var is a tuple of variable name, object
|
||||||
|
|||||||
Reference in New Issue
Block a user