Skip to content

Instantly share code, notes, and snippets.

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