Skip to content

Instantly share code, notes, and snippets.

View pivotaljohn's full-sized avatar
💭
🌤

John S. Ryan pivotaljohn

💭
🌤
View GitHub Profile
#@ load("@ytt:overlay", "overlay")
#@ load("@ytt:toml", "toml")
#@ def app_config_secret():
kind: Secret
metedata:
name: app-config
#@ end
#@ def add_locale(conf_str):
kind: Secret
metedata:
name: app-config
stringData:
app.conf: |
[Global]
user = FOO\bar
@pivotaljohn
pivotaljohn / config.yaml
Created April 19, 2023 16:38
Purge labels from multiple paths
kind: Widget
metadata:
name: foo-with-more-than-all-labels
labels:
label0: value0
label1: value1
label2: value2
label3: value3
label4: value4
---
kind: Widget
metadata:
name: foo-with-more-than-all-labels
labels:
label0: value0
label1: value1
label2: value2
label3: value3
label4: value4
---
@pivotaljohn
pivotaljohn / configmap.yaml
Last active March 31, 2023 17:13
Ensuring no embedded spaces in multiline string
apiVersion: v1
kind: ConfigMap
metadata:
name: fluent-bit-config
namespace: fluent-bit
labels:
k8s-app: fluent-bit
data:
@pivotaljohn
pivotaljohn / overlay-child-key-missing-ok.yaml
Last active March 2, 2023 18:16
Example of how one could overlay a specific child node of some YAML with an ad-hoc set of values (e.g. a ConfigMap's payload).
#! Example of how one could overlay a specific child node of some YAML with an ad-hoc
#! set of values (e.g. a ConfigMap's payload).
#!
#! Features:
#! - custom/overlaying value can introduce new keys
#! - detects if the value of the named key is a string or YAML (and retains that format
#! after the edit.
#! - regardless of the format of the value of "key", parses as YAML and overlays on that.
#@ load("@ytt:overlay", "overlay")
@pivotaljohn
pivotaljohn / apply-custom-values.yaml
Last active March 2, 2023 01:38
Overlaying a configmap that's fully populated
#@ load("@ytt:overlay", "overlay")
#@ load("@ytt:data", "data")
#@ def tekton_pipeline_configmap():
apiVersion: v1
kind: ConfigMap
metadata:
name: feature-flags
namespace: tekton-pipelines
#@ end
#@ load("@ytt:data", "data")
---
foo: #@ data.values
@pivotaljohn
pivotaljohn / _data.yaml
Created November 16, 2022 21:32
Rename a key within a map without modifying the rest of its contents.
---
id: 1
type: book
meta:
format: .mobi
modified: false
---
id: 2
type: book
meta:
@pivotaljohn
pivotaljohn / assert-has-resource-meow.yaml
Created November 11, 2022 21:30
Writing assertion without modifying target using an overlay.
#@ load("@ytt:overlay", "overlay")
#@overlay/match by=overlay.subset({"kind": "ClusterRole", "metadata":{"name":"my-meow"}})
---
rules:
#@overlay/match by=overlay.all
-
#@overlay/assert via=lambda given,expects: (given[0]==expects[0], "Given '{}', expects '{}'".format(given[0],expects[0]))
resourceNames:
#@overlay/match by=overlay.all