mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-14 10:30:59 +00:00
Merge pull request #196 from Liujingfang1/cr
Add docs and demo for imageTags
This commit is contained in:
@@ -184,3 +184,19 @@ vars:
|
|||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
fieldref:
|
fieldref:
|
||||||
fieldpath: spec.template.spec.restartPolicy
|
fieldpath: spec.template.spec.restartPolicy
|
||||||
|
|
||||||
|
# ImageTags modify the tags for images without creating patches.
|
||||||
|
# E.g. Given this fragment of a Deployment:
|
||||||
|
# ```
|
||||||
|
# containers:
|
||||||
|
# - name: myapp
|
||||||
|
# image: mycontainerregistry/myimage:v0
|
||||||
|
# - name: nginxapp
|
||||||
|
# image: nginx:1.7.9
|
||||||
|
#```
|
||||||
|
# one can change the tag of myimage to v1 and the tag of nginx to 1.8.0 with the following:
|
||||||
|
imageTags:
|
||||||
|
- name: mycontainerregistry/myimage
|
||||||
|
newTag: v1
|
||||||
|
- name: nginx
|
||||||
|
newTag: 1.8.0
|
||||||
|
|||||||
@@ -31,3 +31,5 @@ go get github.com/kubernetes-sigs/kustomize
|
|||||||
Alice and Bob.
|
Alice and Bob.
|
||||||
|
|
||||||
* [container args](wordpress/README.md) - Injecting k8s runtime data into container arguments (e.g. to point wordpress to a SQL service).
|
* [container args](wordpress/README.md) - Injecting k8s runtime data into container arguments (e.g. to point wordpress to a SQL service).
|
||||||
|
|
||||||
|
* [image tags](imageTags.md) - Updating image tags without applying a patch.
|
||||||
|
|||||||
75
examples/imageTags.md
Normal file
75
examples/imageTags.md
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
# Demo: change image tags
|
||||||
|
|
||||||
|
|
||||||
|
Define a place to work:
|
||||||
|
|
||||||
|
<!-- @makeWorkplace @test -->
|
||||||
|
```
|
||||||
|
DEMO_HOME=$(mktemp -d)
|
||||||
|
```
|
||||||
|
|
||||||
|
Make a `kustomization` containing a pod resource
|
||||||
|
|
||||||
|
<!-- @createKustomization @test -->
|
||||||
|
```
|
||||||
|
cat <<EOF >$DEMO_HOME/kustomization.yaml
|
||||||
|
resources:
|
||||||
|
- pod.yaml
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
|
||||||
|
Declare the pod resource
|
||||||
|
|
||||||
|
<!-- @createDeployment @test -->
|
||||||
|
```
|
||||||
|
cat <<EOF >$DEMO_HOME/pod.yaml
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: myapp-pod
|
||||||
|
labels:
|
||||||
|
app: myapp
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: myapp-container
|
||||||
|
image: busybox:1.29.0
|
||||||
|
command: ['sh', '-c', 'echo The app is running! && sleep 3600']
|
||||||
|
initContainers:
|
||||||
|
- name: init-mydb
|
||||||
|
image: busybox:1.29.0
|
||||||
|
command: ['sh', '-c', 'until nslookup mydb; do echo waiting for mydb; sleep 2; done;']
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
|
||||||
|
The `myapp-pod` resource declares an initContainer and a container, both use the image `busybox:1.29.0`.
|
||||||
|
The tag `1.29.0` can be changed by adding `imageTags` in `kustomization.yaml`.
|
||||||
|
|
||||||
|
|
||||||
|
Add `imageTags`:
|
||||||
|
<!-- @addImageTags @test -->
|
||||||
|
```
|
||||||
|
cd $DEMO_HOME
|
||||||
|
kustomize edit set imagetag busybox:1.29.1
|
||||||
|
```
|
||||||
|
|
||||||
|
The `kustomization.yaml` will be added following `imageTags`.
|
||||||
|
> ```
|
||||||
|
> imageTags:
|
||||||
|
> - name: busybox
|
||||||
|
> newTag: 1.29.1
|
||||||
|
> ```
|
||||||
|
|
||||||
|
Now build this `kustomization`
|
||||||
|
<!-- @kustomizeBuild @test -->
|
||||||
|
```
|
||||||
|
kustomize build $DEMO_HOME
|
||||||
|
```
|
||||||
|
|
||||||
|
Confirm that this replaces _both_ busybox tags:
|
||||||
|
|
||||||
|
<!-- @confirmTags @test -->
|
||||||
|
```
|
||||||
|
test 2 == \
|
||||||
|
$(kustomize build $DEMO_HOME | grep busybox:1.29.1 | wc -l); \
|
||||||
|
echo $?
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user