Created
February 28, 2021 05:28
-
-
Save making/8af4ab7ac2272a750ef8579f3b0a2784 to your computer and use it in GitHub Desktop.
コンテナイメージのtagをdigestに変更したい
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: ghcr.io/making/hello-tanzu | |
name: hello-tanzu |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#@ load("@ytt:overlay", "overlay") | |
#@ load("@ytt:data", "data") | |
#@ def replace_image(x): | |
#@ container = dict(**x) | |
#@ image = container["image"] | |
#@ rest = image.split(":")[0] | |
#@ container["image"] = rest + "@" + data.values.image.digest | |
#@ return container | |
#@ end | |
#@overlay/match by=overlay.subset({"kind":"Deployment","metadata":{"name":"demo"}}) | |
--- | |
spec: | |
template: | |
spec: | |
containers: | |
#@overlay/match by=overlay.index(0) | |
- #@overlay/replace via=lambda a,b: replace_image(a) | |
image: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#@data/values | |
--- | |
image: | |
digest: sha256:360fee0f052e97f71a9c65e6bc8750a139575df8b90f0fb44a2d0fc4d7954748 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment