Created
December 2, 2024 07:51
-
-
Save mamachanko/ed60e8e88190d11b77d9065cad4560fa to your computer and use it in GitHub Desktop.
Reference overlayed resources https://github.com/carvel-dev/ytt/issues/933
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: app1 | |
labels: | |
app: app1 | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: app1 | |
template: | |
metadata: | |
labels: | |
app: capp1 | |
spec: | |
containers: | |
- image: nginx:alpine | |
name: nginx | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: app2 | |
labels: | |
app: app1 | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: app2 | |
template: | |
metadata: | |
labels: | |
app: app2 | |
spec: | |
containers: | |
- image: nginx:alpine | |
name: nginx |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#@ load("@ytt:overlay", "overlay") | |
#@ def with_labels(left_metadata, right_metadata): | |
#@ """ | |
#@ Returns the lhs metadata with additional labels. | |
#@ """ | |
#@ metadata = dict(left_metadata) | |
#@ labels = dict(metadata["labels"]) | |
#@ labels["metadata.name"] = metadata["name"] | |
#@ metadata["labels"] = labels | |
#@ return metadata | |
#@ end | |
#@overlay/match expects="0+", by=overlay.subset({"kind": "Deployment"}) | |
--- | |
#@overlay/replace via=with_labels | |
metadata: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment