Skip to content

Instantly share code, notes, and snippets.

@making
Last active February 28, 2021 13:00
Show Gist options
  • Save making/159651d21cc9d412cebfe08fa05e47a5 to your computer and use it in GitHub Desktop.
Save making/159651d21cc9d412cebfe08fa05e47a5 to your computer and use it in GitHub Desktop.
コンテナイメージ名を変換したい
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: demo
name: demo
spec:
replicas: 1
selector:
matchLabels:
app: demo
template:
metadata:
labels:
app: demo
spec:
containers:
- image: making/hello-tanzu
name: hello-tanzu
- image: making/sidecar
name: sidecar
#@ load("@ytt:overlay", "overlay")
#@ def replace_image(x):
#@ container = dict(**x)
#@ image = container["image"]
#@ rest = image.split("/")[-2:]
#@ container["image"] = "/".join(["harbor.example.com"] + rest)
#@ return container
#@ end
#@overlay/match by=overlay.subset({"kind":"Deployment","metadata":{"name":"demo"}})
---
spec:
template:
spec:
containers:
#@overlay/match by=overlay.all, expects="1+"
- #@overlay/replace via=lambda a,b: replace_image(a)
image:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment