Skip to content

Instantly share code, notes, and snippets.

@rosenhouse
Created June 2, 2023 20:14
Show Gist options
  • Save rosenhouse/4d63204868ff2c1a56f2827759e6ca2e to your computer and use it in GitHub Desktop.
Save rosenhouse/4d63204868ff2c1a56f2827759e6ca2e 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 with_component_name(old):
#@ x = dict(**old())
#@ x["metadata"]["labels"]["app.kubernetes.io/component"] = x["metadata"]["name"]
#@ return x
#@ end
#@overlay/match by=overlay.subset({"metadata":{"namespace":"pl"}}), expects="1+"
#@overlay/replace via=lambda resource, _: with_component_name(resource)
---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment