Skip to content

Instantly share code, notes, and snippets.

@rosenhouse
Last active June 2, 2023 22:16
Show Gist options
  • Save rosenhouse/17c0701ebc43c7134b30c2afbb23ab4e to your computer and use it in GitHub Desktop.
Save rosenhouse/17c0701ebc43c7134b30c2afbb23ab4e to your computer and use it in GitHub Desktop.
#! See https://kubernetes.slack.com/archives/CH8KCCKA5/p1685663088982309
#@ load("@ytt:overlay", "overlay")
---
apiVersion: v1
kind: Service
metadata:
labels:
foo: bar
name: some-name
namespace: pl
---
#@ def set_label_component_name(name):
labels:
#@overlay/match missing_ok=True
app.kubernetes.io/component: #@ name
#@ end
#@ def component_from_name(left, right):
#@ x = dict(**left)
#@ name = x["name"]
#@ return overlay.apply(left, set_label_component_name(name))
#@ end
#@overlay/match by=overlay.subset({"metadata":{"namespace":"pl"}}), expects="1+"
---
#@overlay/replace via=component_from_name
metadata:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment