Skip to content

Commit 80e7811

Browse files
authored
Generate /kustomize/base/ YAMLs inside release automation (#1134)
* Generate ./kustomize/base YAMLs during release * Update hack/README.md * Avoid use of gcr.io/google-samples...redis:vX.Y.Z
1 parent ae16720 commit 80e7811

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

hack/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## `hack/`
1+
## `hack/`
22

33
This directory contains the scripts for creating a new `microservices-demo` release.
44

@@ -14,19 +14,19 @@ This directory contains the scripts for creating a new `microservices-demo` rele
1414
#### 4. Set the following environment variables:
1515

1616
- `TAG` - This is the new version (e.g., `v0.3.5`).
17-
- `REPO_PREFIX` - This is the Docker repository.
18-
##### Example:
17+
- `REPO_PREFIX` - This is the Docker repository.
18+
##### Example:
1919
```
2020
export TAG=v0.3.5
2121
export REPO_PREFIX=gcr.io/google-samples/microservices-demo
2222
```
2323

2424
#### 5. Run `./hack/make-release.sh`.
2525

26-
- Make sure you run `./hack/make-release.sh` from this project's root folder — **not** from inside the `hack/` folder.
26+
- Make sure you run `./hack/make-release.sh` from this project's root folder — **not** from inside the `hack/` folder.
2727
- This script:
2828
1. uses `make-docker-images.sh` to build and push a Docker image for each microservice to the previously specified repository.
29-
1. uses `make-release-artifacts.sh` to regenerates (and update the image $TAGS) YAML file at `./release/kubernetes-manifests.yaml`.
29+
1. uses `make-release-artifacts.sh` to regenerates (and update the image $TAGS) YAML file at `./release/kubernetes-manifests.yaml` and `./kustomize/base/`.
3030
1. runs `git tag` and pushes a new branch (e.g., `release/v0.3.5`) with the changes to `release/kubernetes-manifests.yaml`.
3131

3232
#### 6. Make sure the new Docker images were created and pushed.

hack/make-release-artifacts.sh

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ read_manifests() {
5252

5353
while IFS= read -d $'\0' -r file; do
5454
echo "---"
55-
55+
5656
# strip license headers (pattern "^# ")
5757
awk '
5858
/^[^# ]/ { found = 1 }
@@ -89,6 +89,26 @@ mk_istio_manifests() {
8989
echo '# [END servicemesh_release_istio_manifests_microservices_demo]'
9090
}
9191

92+
mk_kustomize_base() {
93+
for file_to_copy in ./kubernetes-manifests/*.yaml
94+
do
95+
cp ${file_to_copy} ./kustomize/base/
96+
97+
service_name="$(basename "${file_to_copy}" .yaml)"
98+
image="$REPO_PREFIX/$service_name:$TAG"
99+
100+
# Inside redis.yaml, we use the official `redis:alpine` Docker image.
101+
# We don't use an image from `gcr.io/google-samples/microservices-demo`.
102+
if [[ $service_name == "redis" ]]; then
103+
continue
104+
fi
105+
106+
pattern="^(\s*)image:\s.*${service_name}(.*)(\s*)"
107+
replace="\1image: ${image}\3"
108+
gsed --in-place --regexp-extended "s|${pattern}|${replace}|g" ./kustomize/base/${service_name}.yaml
109+
done
110+
}
111+
92112
main() {
93113
mkdir -p "${OUT_DIR}"
94114
local k8s_manifests_file istio_manifests_file
@@ -102,6 +122,9 @@ main() {
102122
istio_manifests_file="${OUT_DIR}/istio-manifests.yaml"
103123
mk_istio_manifests > "${istio_manifests_file}"
104124
log "Written ${istio_manifests_file}"
125+
126+
mk_kustomize_base
127+
log "Written Kustomize base"
105128
}
106129

107130
main

hack/make-release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fi
4343
# create git release / push to new branch
4444
git checkout -b "release/${TAG}"
4545
git add "${SCRIPTDIR}/../release/"
46-
git add "${SCRIPTDIR}/../kustomize/"
46+
git add "${SCRIPTDIR}/../kustomize/base/"
4747
git commit --allow-empty -m "Release $TAG"
4848
log "Pushing k8s manifests to release/${TAG}..."
4949
git tag "$TAG"

0 commit comments

Comments
 (0)