Skip to content

Instantly share code, notes, and snippets.

View pivotaljohn's full-sized avatar
💭
🌤

John S. Ryan pivotaljohn

💭
🌤
View GitHub Profile
@pivotaljohn
pivotaljohn / example.yaml
Created April 1, 2022 18:00
Last annotation wins.
#@ load("@ytt:overlay", "overlay")
---
kind: Deployment
---
kind: Service
---
#@overlay/match by=overlay.subset({"kind": "Deployment"})
#@overlay/match by=overlay.all, expects=2
@pivotaljohn
pivotaljohn / add-caching.yaml
Last active March 22, 2022 20:15
Endgame of the ytt Overlay Primer
#@ load("@ytt:overlay", "overlay")
#@overlay/match by=overlay.subset({"kind": "Deployment"})
---
spec:
template:
spec:
containers:
- name: redis
image: redis:5.0.4
@pivotaljohn
pivotaljohn / upstream-frontend.yaml
Created March 22, 2022 19:57
Starting point for the ytt Overlay Primer
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend-deployment
labels:
app: frontend
spec:
replicas: 3
selector:
#! add-namespace.yaml
#@ load("@ytt:overlay", "overlay")
#@overlay/match by=overlay.all, expects="1+"
---
metadata:
#@overlay/match missing_ok=True
namespace: my-namespace
@pivotaljohn
pivotaljohn / config.yml
Last active February 22, 2022 17:39
matching on map items, regardless of key name
kind: Foo
spec:
github:
event1:
apple: 1
event2:
banana: 2
event3:
cherry: 3
---
@pivotaljohn
pivotaljohn / overlay.yml
Last active January 5, 2022 18:27
Applying an overlay to a string-encoded YAML value (and then returning it to a string)
#@ load("@ytt:overlay", "overlay")
#@ load("@ytt:yaml", "yaml")
#@ def edit_secret(name):
names:
defaultTLSCertificateSecret: #@ name
#@ end
#@overlay/match by=overlay.subset({"kind": "MyKind"})
---
@pivotaljohn
pivotaljohn / deployment.yml
Last active November 30, 2021 01:03
Testing ytt output
#@ load("@ytt:data", "data")
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
@pivotaljohn
pivotaljohn / base-schema.yml
Last active November 29, 2021 22:13
Default values from schema
#@data/values-schema
---
#@schema/type any=True
other_keys: ""
#@schema/type any=True
test: {}
@pivotaljohn
pivotaljohn / config.yml
Last active November 29, 2021 21:38
Overlaying disjoint user values on default values
#@ load("@ytt:data", "data")
#@ load("@ytt:yaml", "yaml")
#@ load("@ytt:overlay", "overlay")
#@ def default_values():
---
item1: test
item2: test
#@ end
@pivotaljohn
pivotaljohn / template.yaml
Last active November 2, 2021 13:42
Evolving the metrics config
#@ load("@ytt:data", "data")
#@ load("@ytt:template", "template")
#@ load("@ytt:struct", "struct")
#@ def path_to_key(name, metric):
#@ return name.replace("/", "_") + "_" + metric
#@ end
#@ def config_headers(route, metric):
#@ return {path_to_key(route, metric): metric + "_defaulttemplate.json"}