From f3e6ef7d9b34ae408dbde9ed1c483bcc38993588 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 27 Sep 2022 10:48:34 -0400 Subject: [PATCH 01/25] without-grpc-health-probe-bin --- src/adservice/Dockerfile | 19 ++++++++++--------- src/cartservice/src/Dockerfile | 10 ++++++---- src/checkoutservice/Dockerfile | 10 ++++++---- src/currencyservice/Dockerfile | 12 +++++++----- src/emailservice/Dockerfile | 9 ++++++--- src/paymentservice/Dockerfile | 12 +++++++----- src/productcatalogservice/Dockerfile | 10 ++++++---- src/recommendationservice/Dockerfile | 6 ++++-- src/shippingservice/Dockerfile | 11 +++++++---- 9 files changed, 59 insertions(+), 40 deletions(-) diff --git a/src/adservice/Dockerfile b/src/adservice/Dockerfile index 7878a9dc3a3..8df797b18fb 100644 --- a/src/adservice/Dockerfile +++ b/src/adservice/Dockerfile @@ -25,23 +25,24 @@ COPY . . RUN chmod +x gradlew RUN ./gradlew installDist -FROM openjdk:18-slim +FROM openjdk:18-alpine as without-grpc-health-probe-bin + +RUN apk add --no-cache ca-certificates # Download Stackdriver Profiler Java agent -RUN apt-get -y update && apt-get install -qqy \ - wget \ - && rm -rf /var/lib/apt/lists/* RUN mkdir -p /opt/cprof && \ - wget -q -O- https://storage.googleapis.com/cloud-profiler/java/latest/profiler_java_agent.tar.gz \ + wget -q -O- https://storage.googleapis.com/cloud-profiler/java/latest/profiler_java_agent_alpine.tar.gz \ | tar xzv -C /opt/cprof && \ rm -rf profiler_java_agent.tar.gz -RUN GRPC_HEALTH_PROBE_VERSION=v0.4.12 && \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ - chmod +x /bin/grpc_health_probe - WORKDIR /app COPY --from=builder /app . EXPOSE 9555 ENTRYPOINT ["/app/build/install/hipstershop/bin/AdService"] + +FROM without-grpc-health-probe-bin + +RUN GRPC_HEALTH_PROBE_VERSION=v0.4.12 && \ + wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ + chmod +x /bin/grpc_health_probe \ No newline at end of file diff --git a/src/cartservice/src/Dockerfile b/src/cartservice/src/Dockerfile index 349e8dc10e4..b2f40ef9af2 100644 --- a/src/cartservice/src/Dockerfile +++ b/src/cartservice/src/Dockerfile @@ -21,10 +21,7 @@ COPY . . RUN dotnet publish cartservice.csproj -p:PublishSingleFile=true -r linux-musl-x64 --self-contained true -p:PublishTrimmed=True -p:TrimMode=Link -c release -o /cartservice --no-restore # https://mcr.microsoft.com/v2/dotnet/runtime-deps/tags/list -FROM mcr.microsoft.com/dotnet/runtime-deps:7.0.0-rc.1-alpine3.16-amd64 -RUN GRPC_HEALTH_PROBE_VERSION=v0.4.12 && \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ - chmod +x /bin/grpc_health_probe +FROM mcr.microsoft.com/dotnet/runtime-deps:7.0.0-rc.1-alpine3.16-amd64 as without-grpc-health-probe-bin WORKDIR /app COPY --from=builder /cartservice . EXPOSE 7070 @@ -32,3 +29,8 @@ ENV DOTNET_EnableDiagnostics=0 \ ASPNETCORE_URLS=http://*:7070 USER 1000 ENTRYPOINT ["/app/cartservice"] + +FROM without-grpc-health-probe-bin +RUN GRPC_HEALTH_PROBE_VERSION=v0.4.12 && \ + wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ + chmod +x /bin/grpc_health_probe \ No newline at end of file diff --git a/src/checkoutservice/Dockerfile b/src/checkoutservice/Dockerfile index 5b53162d400..8554f797469 100644 --- a/src/checkoutservice/Dockerfile +++ b/src/checkoutservice/Dockerfile @@ -27,11 +27,8 @@ COPY . . ARG SKAFFOLD_GO_GCFLAGS RUN go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" -o /checkoutservice . -FROM alpine as release +FROM alpine as without-grpc-health-probe-bin RUN apk add --no-cache ca-certificates -RUN GRPC_HEALTH_PROBE_VERSION=v0.4.12 && \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ - chmod +x /bin/grpc_health_probe WORKDIR /src COPY --from=builder /checkoutservice /src/checkoutservice @@ -42,3 +39,8 @@ ENV GOTRACEBACK=single EXPOSE 5050 ENTRYPOINT ["/src/checkoutservice"] + +FROM without-grpc-health-probe-bin +RUN GRPC_HEALTH_PROBE_VERSION=v0.4.12 && \ + wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ + chmod +x /bin/grpc_health_probe \ No newline at end of file diff --git a/src/currencyservice/Dockerfile b/src/currencyservice/Dockerfile index 7c268f79254..b43e09a720b 100644 --- a/src/currencyservice/Dockerfile +++ b/src/currencyservice/Dockerfile @@ -29,11 +29,7 @@ COPY package*.json ./ RUN npm install --only=production -FROM base - -RUN GRPC_HEALTH_PROBE_VERSION=v0.4.12 && \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ - chmod +x /bin/grpc_health_probe +FROM base as without-grpc-health-probe-bin WORKDIR /usr/src/app @@ -44,3 +40,9 @@ COPY . . EXPOSE 7000 ENTRYPOINT [ "node", "server.js" ] + +FROM without-grpc-health-probe-bin + +RUN GRPC_HEALTH_PROBE_VERSION=v0.4.12 && \ + wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ + chmod +x /bin/grpc_health_probe \ No newline at end of file diff --git a/src/emailservice/Dockerfile b/src/emailservice/Dockerfile index 315014a6d38..5570b71f30c 100644 --- a/src/emailservice/Dockerfile +++ b/src/emailservice/Dockerfile @@ -22,7 +22,7 @@ RUN apt-get -qq update \ && rm -rf /var/lib/apt/lists/* # Download the grpc health probe -RUN GRPC_HEALTH_PROBE_VERSION=v0.4.11 && \ +RUN GRPC_HEALTH_PROBE_VERSION=v0.4.12 && \ wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ chmod +x /bin/grpc_health_probe @@ -30,7 +30,7 @@ RUN GRPC_HEALTH_PROBE_VERSION=v0.4.11 && \ COPY requirements.txt . RUN pip install -r requirements.txt -FROM base as final +FROM base as without-grpc-health-probe-bin # Enable unbuffered logging ENV PYTHONUNBUFFERED=1 # Enable Profiler @@ -40,10 +40,13 @@ WORKDIR /email_server # Grab packages from builder COPY --from=builder /usr/local/lib/python3.9/ /usr/local/lib/python3.9/ -COPY --from=builder /bin/grpc_health_probe /bin/grpc_health_probe # Add the application COPY . . EXPOSE 8080 ENTRYPOINT [ "python", "email_server.py" ] + +FROM without-grpc-health-probe-bin + +COPY --from=builder /bin/grpc_health_probe /bin/grpc_health_probe \ No newline at end of file diff --git a/src/paymentservice/Dockerfile b/src/paymentservice/Dockerfile index 2f2b3d2a10f..f84604952a6 100644 --- a/src/paymentservice/Dockerfile +++ b/src/paymentservice/Dockerfile @@ -29,11 +29,7 @@ COPY package*.json ./ RUN npm install --only=production -FROM base - -RUN GRPC_HEALTH_PROBE_VERSION=v0.4.12 && \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ - chmod +x /bin/grpc_health_probe +FROM base as without-grpc-health-probe-bin WORKDIR /usr/src/app @@ -44,3 +40,9 @@ COPY . . EXPOSE 50051 ENTRYPOINT [ "node", "index.js" ] + +FROM without-grpc-health-probe-bin + +RUN GRPC_HEALTH_PROBE_VERSION=v0.4.12 && \ + wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ + chmod +x /bin/grpc_health_probe \ No newline at end of file diff --git a/src/productcatalogservice/Dockerfile b/src/productcatalogservice/Dockerfile index 931632a1cfc..af55f2f7d85 100644 --- a/src/productcatalogservice/Dockerfile +++ b/src/productcatalogservice/Dockerfile @@ -26,11 +26,9 @@ COPY . . ARG SKAFFOLD_GO_GCFLAGS RUN go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" -o /productcatalogservice . -FROM alpine AS release +FROM alpine AS without-grpc-health-probe-bin RUN apk add --no-cache ca-certificates -RUN GRPC_HEALTH_PROBE_VERSION=v0.4.12 && \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ - chmod +x /bin/grpc_health_probe + WORKDIR /src COPY --from=builder /productcatalogservice ./server COPY products.json . @@ -43,3 +41,7 @@ ENV GOTRACEBACK=single EXPOSE 3550 ENTRYPOINT ["/src/server"] +FROM without-grpc-health-probe-bin +RUN GRPC_HEALTH_PROBE_VERSION=v0.4.12 && \ + wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ + chmod +x /bin/grpc_health_probe \ No newline at end of file diff --git a/src/recommendationservice/Dockerfile b/src/recommendationservice/Dockerfile index 0a37e997260..4a6721db76b 100644 --- a/src/recommendationservice/Dockerfile +++ b/src/recommendationservice/Dockerfile @@ -30,7 +30,7 @@ RUN GRPC_HEALTH_PROBE_VERSION=v0.4.12 && \ COPY requirements.txt . RUN pip install -r requirements.txt -FROM base as final +FROM base as without-grpc-health-probe-bin # Enable unbuffered logging ENV PYTHONUNBUFFERED=1 @@ -39,7 +39,6 @@ WORKDIR /recommendationservice # Grab packages from builder COPY --from=builder /usr/local/lib/python3.9/ /usr/local/lib/python3.9/ -COPY --from=builder /bin/grpc_health_probe /bin/grpc_health_probe # Add the application COPY . . @@ -49,3 +48,6 @@ ENV PORT "8080" EXPOSE 8080 ENTRYPOINT ["python", "recommendation_server.py"] + +FROM without-grpc-health-probe-bin +COPY --from=builder /bin/grpc_health_probe /bin/grpc_health_probe \ No newline at end of file diff --git a/src/shippingservice/Dockerfile b/src/shippingservice/Dockerfile index 19d03358039..8aa1bd0128c 100644 --- a/src/shippingservice/Dockerfile +++ b/src/shippingservice/Dockerfile @@ -26,11 +26,9 @@ COPY . . ARG SKAFFOLD_GO_GCFLAGS RUN go build -gcflags="${SKAFFOLD_GO_GCFLAGS}" -o /go/bin/shippingservice . -FROM alpine as release +FROM alpine as without-grpc-health-probe-bin RUN apk add --no-cache ca-certificates -RUN GRPC_HEALTH_PROBE_VERSION=v0.4.12 && \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ - chmod +x /bin/grpc_health_probe + WORKDIR /src COPY --from=builder /go/bin/shippingservice /src/shippingservice ENV APP_PORT=50051 @@ -42,3 +40,8 @@ ENV GOTRACEBACK=single EXPOSE 50051 ENTRYPOINT ["/src/shippingservice"] + +FROM without-grpc-health-probe-bin +RUN GRPC_HEALTH_PROBE_VERSION=v0.4.12 && \ + wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ + chmod +x /bin/grpc_health_probe \ No newline at end of file From f458993e113fba9b4c1d41aa9dccb8addbf904be Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Wed, 28 Sep 2022 23:32:41 -0400 Subject: [PATCH 02/25] fix docker build for cartservice --- src/cartservice/src/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cartservice/src/Dockerfile b/src/cartservice/src/Dockerfile index b2f40ef9af2..6fe989aa449 100644 --- a/src/cartservice/src/Dockerfile +++ b/src/cartservice/src/Dockerfile @@ -31,6 +31,8 @@ USER 1000 ENTRYPOINT ["/app/cartservice"] FROM without-grpc-health-probe-bin +USER root RUN GRPC_HEALTH_PROBE_VERSION=v0.4.12 && \ wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ - chmod +x /bin/grpc_health_probe \ No newline at end of file + chmod +x /bin/grpc_health_probe +USER 1000 \ No newline at end of file From 8d1bd03f2ef8bbcf637b8dcba37b20e54f1a6b69 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Wed, 28 Sep 2022 23:33:17 -0400 Subject: [PATCH 03/25] kustomize - add container-image-registry --- .../kustomization.yaml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 kustomize/components/container-images-registry/kustomization.yaml diff --git a/kustomize/components/container-images-registry/kustomization.yaml b/kustomize/components/container-images-registry/kustomization.yaml new file mode 100644 index 00000000000..70f95e00d4b --- /dev/null +++ b/kustomize/components/container-images-registry/kustomization.yaml @@ -0,0 +1,39 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component +images: +- name: gcr.io/google-samples/microservices-demo/adservice + tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} +- name: gcr.io/google-samples/microservices-demo/cartservice + tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} +- name: gcr.io/google-samples/microservices-demo/checkoutservice + tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} +- name: gcr.io/google-samples/microservices-demo/currencyservice + tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} +- name: gcr.io/google-samples/microservices-demo/emailservice + tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} +- name: gcr.io/google-samples/microservices-demo/frontend + tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} +- name: gcr.io/google-samples/microservices-demo/loadgenerator + tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} +- name: gcr.io/google-samples/microservices-demo/paymentservice + tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} +- name: gcr.io/google-samples/microservices-demo/productcatalogservice + tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} +- name: gcr.io/google-samples/microservices-demo/recommendationservice + tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} +- name: gcr.io/google-samples/microservices-demo/shippingservice + tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} From 9c31b94a1b51e1fe2e05d830318c7d175afdcc87 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Wed, 28 Sep 2022 23:33:24 -0400 Subject: [PATCH 04/25] kustomize - add container-image-tag --- .../container-images-tag/kustomization.yaml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 kustomize/components/container-images-tag/kustomization.yaml diff --git a/kustomize/components/container-images-tag/kustomization.yaml b/kustomize/components/container-images-tag/kustomization.yaml new file mode 100644 index 00000000000..25cb9ae9c3e --- /dev/null +++ b/kustomize/components/container-images-tag/kustomization.yaml @@ -0,0 +1,39 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component +images: +- name: gcr.io/google-samples/microservices-demo/adservice + tagSuffix: {{CONTAINER_IMAGES_TAG}} +- name: gcr.io/google-samples/microservices-demo/cartservice + tagSuffix: {{CONTAINER_IMAGES_TAG}} +- name: gcr.io/google-samples/microservices-demo/checkoutservice + tagSuffix: {{CONTAINER_IMAGES_TAG}} +- name: gcr.io/google-samples/microservices-demo/currencyservice + tagSuffix: {{CONTAINER_IMAGES_TAG}} +- name: gcr.io/google-samples/microservices-demo/emailservice + tagSuffix: {{CONTAINER_IMAGES_TAG}} +- name: gcr.io/google-samples/microservices-demo/frontend + tagSuffix: {{CONTAINER_IMAGES_TAG}} +- name: gcr.io/google-samples/microservices-demo/loadgenerator + tagSuffix: {{CONTAINER_IMAGES_TAG}} +- name: gcr.io/google-samples/microservices-demo/paymentservice + tagSuffix: {{CONTAINER_IMAGES_TAG}} +- name: gcr.io/google-samples/microservices-demo/productcatalogservice + tagSuffix: {{CONTAINER_IMAGES_TAG}} +- name: gcr.io/google-samples/microservices-demo/recommendationservice + tagSuffix: {{CONTAINER_IMAGES_TAG}} +- name: gcr.io/google-samples/microservices-demo/shippingservice + tagSuffix: {{CONTAINER_IMAGES_TAG}} From 921a04ca5e2898e953caa908682d6a5272ac1bc5 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Wed, 28 Sep 2022 23:33:37 -0400 Subject: [PATCH 05/25] kustomize - add container-image-tag-suffix --- .../kustomization.yaml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 kustomize/components/container-images-tag-suffix/kustomization.yaml diff --git a/kustomize/components/container-images-tag-suffix/kustomization.yaml b/kustomize/components/container-images-tag-suffix/kustomization.yaml new file mode 100644 index 00000000000..d7012643117 --- /dev/null +++ b/kustomize/components/container-images-tag-suffix/kustomization.yaml @@ -0,0 +1,39 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component +images: +- name: gcr.io/google-samples/microservices-demo/adservice + tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} +- name: gcr.io/google-samples/microservices-demo/cartservice + tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} +- name: gcr.io/google-samples/microservices-demo/checkoutservice + tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} +- name: gcr.io/google-samples/microservices-demo/currencyservice + tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} +- name: gcr.io/google-samples/microservices-demo/emailservice + tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} +- name: gcr.io/google-samples/microservices-demo/frontend + tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} +- name: gcr.io/google-samples/microservices-demo/loadgenerator + tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} +- name: gcr.io/google-samples/microservices-demo/paymentservice + tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} +- name: gcr.io/google-samples/microservices-demo/productcatalogservice + tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} +- name: gcr.io/google-samples/microservices-demo/recommendationservice + tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} +- name: gcr.io/google-samples/microservices-demo/shippingservice + tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} \ No newline at end of file From 1f4d26163f1cb9a8f93361c5c61ef6744710e5ab Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Wed, 28 Sep 2022 23:36:02 -0400 Subject: [PATCH 06/25] fix container-images-registry --- .../kustomization.yaml | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/kustomize/components/container-images-registry/kustomization.yaml b/kustomize/components/container-images-registry/kustomization.yaml index 70f95e00d4b..711290ce077 100644 --- a/kustomize/components/container-images-registry/kustomization.yaml +++ b/kustomize/components/container-images-registry/kustomization.yaml @@ -16,24 +16,24 @@ apiVersion: kustomize.config.k8s.io/v1alpha1 kind: Component images: - name: gcr.io/google-samples/microservices-demo/adservice - tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} + newName: {{CONTAINER_IMAGES_REGISTRY}}/adservice - name: gcr.io/google-samples/microservices-demo/cartservice - tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} + newName: {{CONTAINER_IMAGES_REGISTRY}}/cartservice - name: gcr.io/google-samples/microservices-demo/checkoutservice - tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} + newName: {{CONTAINER_IMAGES_REGISTRY}}/checkoutservice - name: gcr.io/google-samples/microservices-demo/currencyservice - tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} + newName: {{CONTAINER_IMAGES_REGISTRY}}/currencyservice - name: gcr.io/google-samples/microservices-demo/emailservice - tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} + newName: {{CONTAINER_IMAGES_REGISTRY}}/emailservice - name: gcr.io/google-samples/microservices-demo/frontend - tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} + newName: {{CONTAINER_IMAGES_REGISTRY}}/frontend - name: gcr.io/google-samples/microservices-demo/loadgenerator - tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} + newName: {{CONTAINER_IMAGES_REGISTRY}}/loadgenerator - name: gcr.io/google-samples/microservices-demo/paymentservice - tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} + newName: {{CONTAINER_IMAGES_REGISTRY}}/paymentservice - name: gcr.io/google-samples/microservices-demo/productcatalogservice - tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} + newName: {{CONTAINER_IMAGES_REGISTRY}}/productcatalogservice - name: gcr.io/google-samples/microservices-demo/recommendationservice - tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} + newName: {{CONTAINER_IMAGES_REGISTRY}}/recommendationservice - name: gcr.io/google-samples/microservices-demo/shippingservice - tagSuffix: {{CONTAINER_IMAGES_REGISTRY}} + newName: {{CONTAINER_IMAGES_REGISTRY}}/shippingservice From c146e00c822246027e2176cd49d480a791521feb Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Wed, 28 Sep 2022 23:37:31 -0400 Subject: [PATCH 07/25] fix container-images-tag --- .../container-images-tag/kustomization.yaml | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/kustomize/components/container-images-tag/kustomization.yaml b/kustomize/components/container-images-tag/kustomization.yaml index 25cb9ae9c3e..780ba433a35 100644 --- a/kustomize/components/container-images-tag/kustomization.yaml +++ b/kustomize/components/container-images-tag/kustomization.yaml @@ -16,24 +16,24 @@ apiVersion: kustomize.config.k8s.io/v1alpha1 kind: Component images: - name: gcr.io/google-samples/microservices-demo/adservice - tagSuffix: {{CONTAINER_IMAGES_TAG}} + newTag: {{CONTAINER_IMAGES_TAG}} - name: gcr.io/google-samples/microservices-demo/cartservice - tagSuffix: {{CONTAINER_IMAGES_TAG}} + newTag: {{CONTAINER_IMAGES_TAG}} - name: gcr.io/google-samples/microservices-demo/checkoutservice - tagSuffix: {{CONTAINER_IMAGES_TAG}} + newTag: {{CONTAINER_IMAGES_TAG}} - name: gcr.io/google-samples/microservices-demo/currencyservice - tagSuffix: {{CONTAINER_IMAGES_TAG}} + newTag: {{CONTAINER_IMAGES_TAG}} - name: gcr.io/google-samples/microservices-demo/emailservice - tagSuffix: {{CONTAINER_IMAGES_TAG}} + newTag: {{CONTAINER_IMAGES_TAG}} - name: gcr.io/google-samples/microservices-demo/frontend - tagSuffix: {{CONTAINER_IMAGES_TAG}} + newTag: {{CONTAINER_IMAGES_TAG}} - name: gcr.io/google-samples/microservices-demo/loadgenerator - tagSuffix: {{CONTAINER_IMAGES_TAG}} + newTag: {{CONTAINER_IMAGES_TAG}} - name: gcr.io/google-samples/microservices-demo/paymentservice - tagSuffix: {{CONTAINER_IMAGES_TAG}} + newTag: {{CONTAINER_IMAGES_TAG}} - name: gcr.io/google-samples/microservices-demo/productcatalogservice - tagSuffix: {{CONTAINER_IMAGES_TAG}} + newTag: {{CONTAINER_IMAGES_TAG}} - name: gcr.io/google-samples/microservices-demo/recommendationservice - tagSuffix: {{CONTAINER_IMAGES_TAG}} + newTag: {{CONTAINER_IMAGES_TAG}} - name: gcr.io/google-samples/microservices-demo/shippingservice - tagSuffix: {{CONTAINER_IMAGES_TAG}} + newTag: {{CONTAINER_IMAGES_TAG}} From e44a13891832d8817b3f23d338a04fb237dc4946 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Thu, 29 Sep 2022 10:15:26 -0400 Subject: [PATCH 08/25] complete native-grpc-health-check Kustomize variation --- .../kustomization.yaml | 206 ++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100644 kustomize/components/native-grpc-health-check/kustomization.yaml diff --git a/kustomize/components/native-grpc-health-check/kustomization.yaml b/kustomize/components/native-grpc-health-check/kustomization.yaml new file mode 100644 index 00000000000..acb83e195f0 --- /dev/null +++ b/kustomize/components/native-grpc-health-check/kustomization.yaml @@ -0,0 +1,206 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component +patchesStrategicMerge: +# adservice - remove the exec and add the grpc for liveness and readiness probes +- |- + apiVersion: apps/v1 + kind: Deployment + metadata: + name: adservice + spec: + template: + spec: + containers: + - name: server + readinessProbe: + exec: + $patch: delete + grpc: + port: 9555 + livenessProbe: + exec: + $patch: delete + grpc: + port: 9555 +# cartservice - remove the exec and add the grpc for liveness and readiness probes +- |- + apiVersion: apps/v1 + kind: Deployment + metadata: + name: cartservice + spec: + template: + spec: + containers: + - name: server + readinessProbe: + exec: + $patch: delete + grpc: + port: 7070 + livenessProbe: + exec: + $patch: delete + grpc: + port: 7070 +# checkoutservice - remove the exec and add the grpc for liveness and readiness probes +- |- + apiVersion: apps/v1 + kind: Deployment + metadata: + name: checkoutservice + spec: + template: + spec: + containers: + - name: server + readinessProbe: + exec: + $patch: delete + grpc: + port: 5050 + livenessProbe: + exec: + $patch: delete + grpc: + port: 5050 +# currencyservice - remove the exec and add the grpc for liveness and readiness probes +- |- + apiVersion: apps/v1 + kind: Deployment + metadata: + name: currencyservice + spec: + template: + spec: + containers: + - name: server + readinessProbe: + exec: + $patch: delete + grpc: + port: 7000 + livenessProbe: + exec: + $patch: delete + grpc: + port: 7000 +# emailservice - remove the exec and add the grpc for liveness and readiness probes +- |- + apiVersion: apps/v1 + kind: Deployment + metadata: + name: emailservice + spec: + template: + spec: + containers: + - name: server + readinessProbe: + exec: + $patch: delete + grpc: + port: 8080 + livenessProbe: + exec: + $patch: delete + grpc: + port: 8080 +# paymentservice - remove the exec and add the grpc for liveness and readiness probes +- |- + apiVersion: apps/v1 + kind: Deployment + metadata: + name: paymentservice + spec: + template: + spec: + containers: + - name: server + readinessProbe: + exec: + $patch: delete + grpc: + port: 50051 + livenessProbe: + exec: + $patch: delete + grpc: + port: 50051 +# productcatalogservice - remove the exec and add the grpc for liveness and readiness probes +- |- + apiVersion: apps/v1 + kind: Deployment + metadata: + name: productcatalogservice + spec: + template: + spec: + containers: + - name: server + readinessProbe: + exec: + $patch: delete + grpc: + port: 3550 + livenessProbe: + exec: + $patch: delete + grpc: + port: 3550 +# recommendationservice - remove the exec and add the grpc for liveness and readiness probes +- |- + apiVersion: apps/v1 + kind: Deployment + metadata: + name: recommendationservice + spec: + template: + spec: + containers: + - name: server + readinessProbe: + exec: + $patch: delete + grpc: + port: 8080 + livenessProbe: + exec: + $patch: delete + grpc: + port: 8080 +# shippingservice - remove the exec and add the grpc for liveness and readiness probes +- |- + apiVersion: apps/v1 + kind: Deployment + metadata: + name: shippingservice + spec: + template: + spec: + containers: + - name: server + readinessProbe: + exec: + $patch: delete + grpc: + port: 50051 + livenessProbe: + exec: + $patch: delete + grpc: + port: 50051 \ No newline at end of file From bd384927188a19869e105f60eb370656b75c46e2 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Thu, 29 Sep 2022 17:26:19 -0400 Subject: [PATCH 09/25] Review tokens in Kustomize files: $() instead of {{}} (issues with Kustomize otherwise) --- .../kustomization.yaml | 22 ++++++------ .../kustomization.yaml | 22 ++++++------ .../container-images-tag/kustomization.yaml | 22 ++++++------ kustomize/components/memorystore/README.md | 2 +- .../components/memorystore/kustomization.yaml | 2 +- .../native-grpc-health-check/README.md | 36 +++++++++++++++++++ kustomize/kustomization.yaml | 3 ++ terraform/memorystore.tf | 2 +- 8 files changed, 75 insertions(+), 36 deletions(-) create mode 100644 kustomize/components/native-grpc-health-check/README.md diff --git a/kustomize/components/container-images-registry/kustomization.yaml b/kustomize/components/container-images-registry/kustomization.yaml index 711290ce077..4184e37d5f1 100644 --- a/kustomize/components/container-images-registry/kustomization.yaml +++ b/kustomize/components/container-images-registry/kustomization.yaml @@ -16,24 +16,24 @@ apiVersion: kustomize.config.k8s.io/v1alpha1 kind: Component images: - name: gcr.io/google-samples/microservices-demo/adservice - newName: {{CONTAINER_IMAGES_REGISTRY}}/adservice + newName: $(CONTAINER_IMAGES_REGISTRY)/adservice - name: gcr.io/google-samples/microservices-demo/cartservice - newName: {{CONTAINER_IMAGES_REGISTRY}}/cartservice + newName: $(CONTAINER_IMAGES_REGISTRY)/cartservice - name: gcr.io/google-samples/microservices-demo/checkoutservice - newName: {{CONTAINER_IMAGES_REGISTRY}}/checkoutservice + newName: $(CONTAINER_IMAGES_REGISTRY)/checkoutservice - name: gcr.io/google-samples/microservices-demo/currencyservice - newName: {{CONTAINER_IMAGES_REGISTRY}}/currencyservice + newName: $(CONTAINER_IMAGES_REGISTRY)/currencyservice - name: gcr.io/google-samples/microservices-demo/emailservice - newName: {{CONTAINER_IMAGES_REGISTRY}}/emailservice + newName: $(CONTAINER_IMAGES_REGISTRY)/emailservice - name: gcr.io/google-samples/microservices-demo/frontend - newName: {{CONTAINER_IMAGES_REGISTRY}}/frontend + newName: $(CONTAINER_IMAGES_REGISTRY)/frontend - name: gcr.io/google-samples/microservices-demo/loadgenerator - newName: {{CONTAINER_IMAGES_REGISTRY}}/loadgenerator + newName: $(CONTAINER_IMAGES_REGISTRY)/loadgenerator - name: gcr.io/google-samples/microservices-demo/paymentservice - newName: {{CONTAINER_IMAGES_REGISTRY}}/paymentservice + newName: $(CONTAINER_IMAGES_REGISTRY)/paymentservice - name: gcr.io/google-samples/microservices-demo/productcatalogservice - newName: {{CONTAINER_IMAGES_REGISTRY}}/productcatalogservice + newName: $(CONTAINER_IMAGES_REGISTRY)/productcatalogservice - name: gcr.io/google-samples/microservices-demo/recommendationservice - newName: {{CONTAINER_IMAGES_REGISTRY}}/recommendationservice + newName: $(CONTAINER_IMAGES_REGISTRY)/recommendationservice - name: gcr.io/google-samples/microservices-demo/shippingservice - newName: {{CONTAINER_IMAGES_REGISTRY}}/shippingservice + newName: $(CONTAINER_IMAGES_REGISTRY)/shippingservice diff --git a/kustomize/components/container-images-tag-suffix/kustomization.yaml b/kustomize/components/container-images-tag-suffix/kustomization.yaml index d7012643117..d414c778c09 100644 --- a/kustomize/components/container-images-tag-suffix/kustomization.yaml +++ b/kustomize/components/container-images-tag-suffix/kustomization.yaml @@ -16,24 +16,24 @@ apiVersion: kustomize.config.k8s.io/v1alpha1 kind: Component images: - name: gcr.io/google-samples/microservices-demo/adservice - tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} + tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/cartservice - tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} + tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/checkoutservice - tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} + tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/currencyservice - tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} + tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/emailservice - tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} + tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/frontend - tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} + tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/loadgenerator - tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} + tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/paymentservice - tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} + tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/productcatalogservice - tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} + tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/recommendationservice - tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} + tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/shippingservice - tagSuffix: {{CONTAINER_IMAGES_TAG_SUFFIX}} \ No newline at end of file + tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) \ No newline at end of file diff --git a/kustomize/components/container-images-tag/kustomization.yaml b/kustomize/components/container-images-tag/kustomization.yaml index 780ba433a35..3bc684af67d 100644 --- a/kustomize/components/container-images-tag/kustomization.yaml +++ b/kustomize/components/container-images-tag/kustomization.yaml @@ -16,24 +16,24 @@ apiVersion: kustomize.config.k8s.io/v1alpha1 kind: Component images: - name: gcr.io/google-samples/microservices-demo/adservice - newTag: {{CONTAINER_IMAGES_TAG}} + newTag: $(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/cartservice - newTag: {{CONTAINER_IMAGES_TAG}} + newTag: $(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/checkoutservice - newTag: {{CONTAINER_IMAGES_TAG}} + newTag: $(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/currencyservice - newTag: {{CONTAINER_IMAGES_TAG}} + newTag: $(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/emailservice - newTag: {{CONTAINER_IMAGES_TAG}} + newTag: $(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/frontend - newTag: {{CONTAINER_IMAGES_TAG}} + newTag: $(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/loadgenerator - newTag: {{CONTAINER_IMAGES_TAG}} + newTag: $(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/paymentservice - newTag: {{CONTAINER_IMAGES_TAG}} + newTag: $(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/productcatalogservice - newTag: {{CONTAINER_IMAGES_TAG}} + newTag: $(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/recommendationservice - newTag: {{CONTAINER_IMAGES_TAG}} + newTag: $(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/shippingservice - newTag: {{CONTAINER_IMAGES_TAG}} + newTag: $(CONTAINER_IMAGES_TAG) diff --git a/kustomize/components/memorystore/README.md b/kustomize/components/memorystore/README.md index 1fa13027ea2..4df0b827358 100644 --- a/kustomize/components/memorystore/README.md +++ b/kustomize/components/memorystore/README.md @@ -39,7 +39,7 @@ Update current Kustomize manifest to target this Memorystore (Redis) instance. MEMORYSTORE_REGION=replace-with-the-region-of-your-memorystore-instance REDIS_IP=$(gcloud redis instances describe redis-cart --region=${MEMORYSTORE_REGION} --format='get(host)') REDIS_PORT=$(gcloud redis instances describe redis-cart --region=${MEMORYSTORE_REGION} --format='get(port)') -sed -i "s/{{REDIS_ADDR}}/${REDIS_IP}:${REDIS_PORT}/g" components/memorystore/kustomization.yaml +sed -i "s/$(REDIS_ADDR)/${REDIS_IP}:${REDIS_PORT}/g" components/memorystore/kustomization.yaml ``` You can locally render these manifests by running `kubectl kustomize .` as well as deploying them by running `kubectl apply -k .`. diff --git a/kustomize/components/memorystore/kustomization.yaml b/kustomize/components/memorystore/kustomization.yaml index 7c85aeec3aa..8a9920df636 100644 --- a/kustomize/components/memorystore/kustomization.yaml +++ b/kustomize/components/memorystore/kustomization.yaml @@ -28,7 +28,7 @@ patchesStrategicMerge: - name: server env: - name: REDIS_ADDR - value: "{{REDIS_ADDR}}" + value: "$(REDIS_ADDR)" # redis - remove the redis-cart Deployment - |- apiVersion: apps/v1 diff --git a/kustomize/components/native-grpc-health-check/README.md b/kustomize/components/native-grpc-health-check/README.md new file mode 100644 index 00000000000..c2038fc8db6 --- /dev/null +++ b/kustomize/components/native-grpc-health-check/README.md @@ -0,0 +1,36 @@ +# Integrate Online Boutique with native gRPC Healthcheck probes + +FIXME + +Kubernetes 1.24+ + +## Deploy Online Boutique connected to a Memorystore (Redis) instance + +To automate the deployment of Online Boutique integrated with Memorystore (Redis) you can leverage the following variation with [Kustomize](../..). + +From the `kustomize/` folder at the root level of this repository, execute this command: +``` +kustomize edit add components/container-images-tag-suffix +``` +_Note: this Kustomize component will also remove the `redis-cart` `Deployment` and `Service` not used anymore._ + +This will update the `kustomize/kustomization.yaml` file which could be similar to: +``` +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- base +components: +- components/container-images-tag-suffix +``` + +Update current Kustomize manifest to target the new container images tag (same tag as default tag but with the suffix `-native-grpc`). +```sh +sed -i "s/$(CONTAINER_IMAGES_TAG_SUFFIX)/-native-grpc/g" components/container-images-tag-suffix/kustomization.yaml +``` + +You can locally render these manifests by running `kubectl kustomize .` as well as deploying them by running `kubectl apply -k .`. + +## Resources + +- FIXME diff --git a/kustomize/kustomization.yaml b/kustomize/kustomization.yaml index d9640463788..a162f0eb2e0 100644 --- a/kustomize/kustomization.yaml +++ b/kustomize/kustomization.yaml @@ -22,3 +22,6 @@ components: # - components/memorystore # - components/network-policies # - components/service-accounts +# - components/container-images-tag +# - components/container-images-tag-suffix +- components/container-images-registry diff --git a/terraform/memorystore.tf b/terraform/memorystore.tf index 4009c2355f1..8697633650a 100644 --- a/terraform/memorystore.tf +++ b/terraform/memorystore.tf @@ -34,7 +34,7 @@ resource "google_redis_instance" "redis-cart" { resource "null_resource" "kustomization-update" { provisioner "local-exec" { interpreter = ["bash", "-exc"] - command = "sed -i \"s/{{REDIS_ADDR}}/${google_redis_instance.redis-cart[0].host}:${google_redis_instance.redis-cart[0].port}/g\" ../kustomize/components/memorystore/kustomization.yaml" + command = "sed -i \"s/$(REDIS_ADDR)/${google_redis_instance.redis-cart[0].host}:${google_redis_instance.redis-cart[0].port}/g\" ../kustomize/components/memorystore/kustomization.yaml" } # count specifies the number of instances to create; From 5ed543a315b82abb3e96661a6fe33ddb59912c46 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 30 Sep 2022 11:16:02 -0400 Subject: [PATCH 10/25] docker build -t "${image}-native-grpc" --- hack/make-docker-images.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hack/make-docker-images.sh b/hack/make-docker-images.sh index 9cff93701a4..cc850a51bea 100755 --- a/hack/make-docker-images.sh +++ b/hack/make-docker-images.sh @@ -38,9 +38,11 @@ while IFS= read -d $'\0' -r dir; do cd "${builddir}" log "Building: ${image}" docker build -t "${image}" . + docker build -t "${image}-native-grpc" . --target without-grpc-health-probe-bin log "Pushing: ${image}" docker push "${image}" + docker push "${image}-native-grpc" ) done < <(find "${SCRIPTDIR}/../src" -mindepth 1 -maxdepth 1 -type d -print0) From 0ca4a52a8aff13961aac2c238505f853f10974c5 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 30 Sep 2022 14:24:52 -0400 Subject: [PATCH 11/25] Bonify the custom test in Kustomize CI --- .github/workflows/kustomize-build-ci.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/kustomize-build-ci.yaml b/.github/workflows/kustomize-build-ci.yaml index 2a26999f274..4e2d168f36a 100644 --- a/.github/workflows/kustomize-build-ci.yaml +++ b/.github/workflows/kustomize-build-ci.yaml @@ -52,10 +52,18 @@ jobs: kustomize create --resources base kustomize edit add component components/cymbal-branding kustomize edit add component components/google-cloud-operations + sed -i "s/@(REDIS_ADDR)/0.0.0.0:6379/g" components/memorystore/kustomization.yaml kustomize edit add component components/memorystore kustomize edit add component components/network-policies kustomize edit add component components/service-accounts cd components/network-policies kustomize edit remove resource network-policy-redis.yaml cd ../.. + sed -i "s/@(CONTAINER_IMAGES_TAG)/v1.0.0/g" components/container-images-tag/kustomization.yaml + kustomize edit add component components/container-images-tag + sed -i "s/@(CONTAINER_IMAGES_TAG_SUFFIX)/-test/g" components/container-images-tag-suffix/kustomization.yaml + kustomize edit add component components/container-images-tag-suffix + sed -i "s/@(CONTAINER_IMAGES_REGISTRY)/my-registry/g" components/container-images-registry/kustomization.yaml + kustomize edit add component components/container-images-registry + kustomize edit add component components/native-grpc-health-check kustomize build . From 77a38a003afb998f3bde90e77d3b5071a30aea92 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 30 Sep 2022 14:25:20 -0400 Subject: [PATCH 12/25] Review token to avoid issue in bash with sed: @() instead of $() --- .../kustomization.yaml | 22 +++++++++---------- .../kustomization.yaml | 22 +++++++++---------- .../container-images-tag/kustomization.yaml | 22 +++++++++---------- kustomize/components/memorystore/README.md | 2 +- .../components/memorystore/kustomization.yaml | 2 +- kustomize/kustomization.yaml | 3 ++- terraform/memorystore.tf | 2 +- 7 files changed, 38 insertions(+), 37 deletions(-) diff --git a/kustomize/components/container-images-registry/kustomization.yaml b/kustomize/components/container-images-registry/kustomization.yaml index 4184e37d5f1..f8abd1e6a9d 100644 --- a/kustomize/components/container-images-registry/kustomization.yaml +++ b/kustomize/components/container-images-registry/kustomization.yaml @@ -16,24 +16,24 @@ apiVersion: kustomize.config.k8s.io/v1alpha1 kind: Component images: - name: gcr.io/google-samples/microservices-demo/adservice - newName: $(CONTAINER_IMAGES_REGISTRY)/adservice + newName: @(CONTAINER_IMAGES_REGISTRY)/adservice - name: gcr.io/google-samples/microservices-demo/cartservice - newName: $(CONTAINER_IMAGES_REGISTRY)/cartservice + newName: @(CONTAINER_IMAGES_REGISTRY)/cartservice - name: gcr.io/google-samples/microservices-demo/checkoutservice - newName: $(CONTAINER_IMAGES_REGISTRY)/checkoutservice + newName: @(CONTAINER_IMAGES_REGISTRY)/checkoutservice - name: gcr.io/google-samples/microservices-demo/currencyservice - newName: $(CONTAINER_IMAGES_REGISTRY)/currencyservice + newName: @(CONTAINER_IMAGES_REGISTRY)/currencyservice - name: gcr.io/google-samples/microservices-demo/emailservice - newName: $(CONTAINER_IMAGES_REGISTRY)/emailservice + newName: @(CONTAINER_IMAGES_REGISTRY)/emailservice - name: gcr.io/google-samples/microservices-demo/frontend - newName: $(CONTAINER_IMAGES_REGISTRY)/frontend + newName: @(CONTAINER_IMAGES_REGISTRY)/frontend - name: gcr.io/google-samples/microservices-demo/loadgenerator - newName: $(CONTAINER_IMAGES_REGISTRY)/loadgenerator + newName: @(CONTAINER_IMAGES_REGISTRY)/loadgenerator - name: gcr.io/google-samples/microservices-demo/paymentservice - newName: $(CONTAINER_IMAGES_REGISTRY)/paymentservice + newName: @(CONTAINER_IMAGES_REGISTRY)/paymentservice - name: gcr.io/google-samples/microservices-demo/productcatalogservice - newName: $(CONTAINER_IMAGES_REGISTRY)/productcatalogservice + newName: @(CONTAINER_IMAGES_REGISTRY)/productcatalogservice - name: gcr.io/google-samples/microservices-demo/recommendationservice - newName: $(CONTAINER_IMAGES_REGISTRY)/recommendationservice + newName: @(CONTAINER_IMAGES_REGISTRY)/recommendationservice - name: gcr.io/google-samples/microservices-demo/shippingservice - newName: $(CONTAINER_IMAGES_REGISTRY)/shippingservice + newName: @(CONTAINER_IMAGES_REGISTRY)/shippingservice diff --git a/kustomize/components/container-images-tag-suffix/kustomization.yaml b/kustomize/components/container-images-tag-suffix/kustomization.yaml index d414c778c09..11e0b38c7d1 100644 --- a/kustomize/components/container-images-tag-suffix/kustomization.yaml +++ b/kustomize/components/container-images-tag-suffix/kustomization.yaml @@ -16,24 +16,24 @@ apiVersion: kustomize.config.k8s.io/v1alpha1 kind: Component images: - name: gcr.io/google-samples/microservices-demo/adservice - tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/cartservice - tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/checkoutservice - tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/currencyservice - tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/emailservice - tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/frontend - tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/loadgenerator - tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/paymentservice - tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/productcatalogservice - tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/recommendationservice - tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) - name: gcr.io/google-samples/microservices-demo/shippingservice - tagSuffix: $(CONTAINER_IMAGES_TAG_SUFFIX) \ No newline at end of file + tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) \ No newline at end of file diff --git a/kustomize/components/container-images-tag/kustomization.yaml b/kustomize/components/container-images-tag/kustomization.yaml index 3bc684af67d..de4f7b1bf14 100644 --- a/kustomize/components/container-images-tag/kustomization.yaml +++ b/kustomize/components/container-images-tag/kustomization.yaml @@ -16,24 +16,24 @@ apiVersion: kustomize.config.k8s.io/v1alpha1 kind: Component images: - name: gcr.io/google-samples/microservices-demo/adservice - newTag: $(CONTAINER_IMAGES_TAG) + newTag: @(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/cartservice - newTag: $(CONTAINER_IMAGES_TAG) + newTag: @(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/checkoutservice - newTag: $(CONTAINER_IMAGES_TAG) + newTag: @(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/currencyservice - newTag: $(CONTAINER_IMAGES_TAG) + newTag: @(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/emailservice - newTag: $(CONTAINER_IMAGES_TAG) + newTag: @(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/frontend - newTag: $(CONTAINER_IMAGES_TAG) + newTag: @(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/loadgenerator - newTag: $(CONTAINER_IMAGES_TAG) + newTag: @(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/paymentservice - newTag: $(CONTAINER_IMAGES_TAG) + newTag: @(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/productcatalogservice - newTag: $(CONTAINER_IMAGES_TAG) + newTag: @(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/recommendationservice - newTag: $(CONTAINER_IMAGES_TAG) + newTag: @(CONTAINER_IMAGES_TAG) - name: gcr.io/google-samples/microservices-demo/shippingservice - newTag: $(CONTAINER_IMAGES_TAG) + newTag: @(CONTAINER_IMAGES_TAG) diff --git a/kustomize/components/memorystore/README.md b/kustomize/components/memorystore/README.md index 4df0b827358..20e6a2cd50f 100644 --- a/kustomize/components/memorystore/README.md +++ b/kustomize/components/memorystore/README.md @@ -39,7 +39,7 @@ Update current Kustomize manifest to target this Memorystore (Redis) instance. MEMORYSTORE_REGION=replace-with-the-region-of-your-memorystore-instance REDIS_IP=$(gcloud redis instances describe redis-cart --region=${MEMORYSTORE_REGION} --format='get(host)') REDIS_PORT=$(gcloud redis instances describe redis-cart --region=${MEMORYSTORE_REGION} --format='get(port)') -sed -i "s/$(REDIS_ADDR)/${REDIS_IP}:${REDIS_PORT}/g" components/memorystore/kustomization.yaml +sed -i "s/@(REDIS_ADDR)/${REDIS_IP}:${REDIS_PORT}/g" components/memorystore/kustomization.yaml ``` You can locally render these manifests by running `kubectl kustomize .` as well as deploying them by running `kubectl apply -k .`. diff --git a/kustomize/components/memorystore/kustomization.yaml b/kustomize/components/memorystore/kustomization.yaml index 8a9920df636..c8aac627c0a 100644 --- a/kustomize/components/memorystore/kustomization.yaml +++ b/kustomize/components/memorystore/kustomization.yaml @@ -28,7 +28,7 @@ patchesStrategicMerge: - name: server env: - name: REDIS_ADDR - value: "$(REDIS_ADDR)" + value: "@(REDIS_ADDR)" # redis - remove the redis-cart Deployment - |- apiVersion: apps/v1 diff --git a/kustomize/kustomization.yaml b/kustomize/kustomization.yaml index a162f0eb2e0..da270a50337 100644 --- a/kustomize/kustomization.yaml +++ b/kustomize/kustomization.yaml @@ -24,4 +24,5 @@ components: # - components/service-accounts # - components/container-images-tag # - components/container-images-tag-suffix -- components/container-images-registry +# - components/container-images-registry +# - components/native-grpc-health-check \ No newline at end of file diff --git a/terraform/memorystore.tf b/terraform/memorystore.tf index 8697633650a..95adf7e7b46 100644 --- a/terraform/memorystore.tf +++ b/terraform/memorystore.tf @@ -34,7 +34,7 @@ resource "google_redis_instance" "redis-cart" { resource "null_resource" "kustomization-update" { provisioner "local-exec" { interpreter = ["bash", "-exc"] - command = "sed -i \"s/$(REDIS_ADDR)/${google_redis_instance.redis-cart[0].host}:${google_redis_instance.redis-cart[0].port}/g\" ../kustomize/components/memorystore/kustomization.yaml" + command = "sed -i \"s/@(REDIS_ADDR)/${google_redis_instance.redis-cart[0].host}:${google_redis_instance.redis-cart[0].port}/g\" ../kustomize/components/memorystore/kustomization.yaml" } # count specifies the number of instances to create; From 403eb0b1c6d4c502064c0f1f639911b16b01f7be Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 30 Sep 2022 16:03:06 -0400 Subject: [PATCH 13/25] Fix token issues with Kustomize --- .github/workflows/kustomize-build-ci.yaml | 2 +- .../kustomization.yaml | 22 +++++++++---------- .../kustomization.yaml | 22 +++++++++---------- .../container-images-tag/kustomization.yaml | 22 +++++++++---------- kustomize/components/memorystore/README.md | 2 +- .../components/memorystore/kustomization.yaml | 2 +- terraform/memorystore.tf | 2 +- 7 files changed, 37 insertions(+), 37 deletions(-) diff --git a/.github/workflows/kustomize-build-ci.yaml b/.github/workflows/kustomize-build-ci.yaml index 4e2d168f36a..565fd2d1703 100644 --- a/.github/workflows/kustomize-build-ci.yaml +++ b/.github/workflows/kustomize-build-ci.yaml @@ -52,7 +52,7 @@ jobs: kustomize create --resources base kustomize edit add component components/cymbal-branding kustomize edit add component components/google-cloud-operations - sed -i "s/@(REDIS_ADDR)/0.0.0.0:6379/g" components/memorystore/kustomization.yaml + sed -i "s/\"REDIS_ADDR\"/0.0.0.0:6379/g" components/memorystore/kustomization.yaml kustomize edit add component components/memorystore kustomize edit add component components/network-policies kustomize edit add component components/service-accounts diff --git a/kustomize/components/container-images-registry/kustomization.yaml b/kustomize/components/container-images-registry/kustomization.yaml index f8abd1e6a9d..1331d1ca766 100644 --- a/kustomize/components/container-images-registry/kustomization.yaml +++ b/kustomize/components/container-images-registry/kustomization.yaml @@ -16,24 +16,24 @@ apiVersion: kustomize.config.k8s.io/v1alpha1 kind: Component images: - name: gcr.io/google-samples/microservices-demo/adservice - newName: @(CONTAINER_IMAGES_REGISTRY)/adservice + newName: CONTAINER_IMAGES_REGISTRY/adservice - name: gcr.io/google-samples/microservices-demo/cartservice - newName: @(CONTAINER_IMAGES_REGISTRY)/cartservice + newName: CONTAINER_IMAGES_REGISTRY/cartservice - name: gcr.io/google-samples/microservices-demo/checkoutservice - newName: @(CONTAINER_IMAGES_REGISTRY)/checkoutservice + newName: CONTAINER_IMAGES_REGISTRY/checkoutservice - name: gcr.io/google-samples/microservices-demo/currencyservice - newName: @(CONTAINER_IMAGES_REGISTRY)/currencyservice + newName: CONTAINER_IMAGES_REGISTRY/currencyservice - name: gcr.io/google-samples/microservices-demo/emailservice - newName: @(CONTAINER_IMAGES_REGISTRY)/emailservice + newName: CONTAINER_IMAGES_REGISTRY/emailservice - name: gcr.io/google-samples/microservices-demo/frontend - newName: @(CONTAINER_IMAGES_REGISTRY)/frontend + newName: CONTAINER_IMAGES_REGISTRY/frontend - name: gcr.io/google-samples/microservices-demo/loadgenerator - newName: @(CONTAINER_IMAGES_REGISTRY)/loadgenerator + newName: CONTAINER_IMAGES_REGISTRY/loadgenerator - name: gcr.io/google-samples/microservices-demo/paymentservice - newName: @(CONTAINER_IMAGES_REGISTRY)/paymentservice + newName: CONTAINER_IMAGES_REGISTRY/paymentservice - name: gcr.io/google-samples/microservices-demo/productcatalogservice - newName: @(CONTAINER_IMAGES_REGISTRY)/productcatalogservice + newName: CONTAINER_IMAGES_REGISTRY/productcatalogservice - name: gcr.io/google-samples/microservices-demo/recommendationservice - newName: @(CONTAINER_IMAGES_REGISTRY)/recommendationservice + newName: CONTAINER_IMAGES_REGISTRY/recommendationservice - name: gcr.io/google-samples/microservices-demo/shippingservice - newName: @(CONTAINER_IMAGES_REGISTRY)/shippingservice + newName: CONTAINER_IMAGES_REGISTRY/shippingservice diff --git a/kustomize/components/container-images-tag-suffix/kustomization.yaml b/kustomize/components/container-images-tag-suffix/kustomization.yaml index 11e0b38c7d1..eab21e0466f 100644 --- a/kustomize/components/container-images-tag-suffix/kustomization.yaml +++ b/kustomize/components/container-images-tag-suffix/kustomization.yaml @@ -16,24 +16,24 @@ apiVersion: kustomize.config.k8s.io/v1alpha1 kind: Component images: - name: gcr.io/google-samples/microservices-demo/adservice - tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: CONTAINER_IMAGES_TAG_SUFFIX - name: gcr.io/google-samples/microservices-demo/cartservice - tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: CONTAINER_IMAGES_TAG_SUFFIX - name: gcr.io/google-samples/microservices-demo/checkoutservice - tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: CONTAINER_IMAGES_TAG_SUFFIX - name: gcr.io/google-samples/microservices-demo/currencyservice - tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: CONTAINER_IMAGES_TAG_SUFFIX - name: gcr.io/google-samples/microservices-demo/emailservice - tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: CONTAINER_IMAGES_TAG_SUFFIX - name: gcr.io/google-samples/microservices-demo/frontend - tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: CONTAINER_IMAGES_TAG_SUFFIX - name: gcr.io/google-samples/microservices-demo/loadgenerator - tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: CONTAINER_IMAGES_TAG_SUFFIX - name: gcr.io/google-samples/microservices-demo/paymentservice - tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: CONTAINER_IMAGES_TAG_SUFFIX - name: gcr.io/google-samples/microservices-demo/productcatalogservice - tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: CONTAINER_IMAGES_TAG_SUFFIX - name: gcr.io/google-samples/microservices-demo/recommendationservice - tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) + tagSuffix: CONTAINER_IMAGES_TAG_SUFFIX - name: gcr.io/google-samples/microservices-demo/shippingservice - tagSuffix: @(CONTAINER_IMAGES_TAG_SUFFIX) \ No newline at end of file + tagSuffix: CONTAINER_IMAGES_TAG_SUFFIX \ No newline at end of file diff --git a/kustomize/components/container-images-tag/kustomization.yaml b/kustomize/components/container-images-tag/kustomization.yaml index de4f7b1bf14..23bda660db6 100644 --- a/kustomize/components/container-images-tag/kustomization.yaml +++ b/kustomize/components/container-images-tag/kustomization.yaml @@ -16,24 +16,24 @@ apiVersion: kustomize.config.k8s.io/v1alpha1 kind: Component images: - name: gcr.io/google-samples/microservices-demo/adservice - newTag: @(CONTAINER_IMAGES_TAG) + newTag: CONTAINER_IMAGES_TAG - name: gcr.io/google-samples/microservices-demo/cartservice - newTag: @(CONTAINER_IMAGES_TAG) + newTag: CONTAINER_IMAGES_TAG - name: gcr.io/google-samples/microservices-demo/checkoutservice - newTag: @(CONTAINER_IMAGES_TAG) + newTag: CONTAINER_IMAGES_TAG - name: gcr.io/google-samples/microservices-demo/currencyservice - newTag: @(CONTAINER_IMAGES_TAG) + newTag: CONTAINER_IMAGES_TAG - name: gcr.io/google-samples/microservices-demo/emailservice - newTag: @(CONTAINER_IMAGES_TAG) + newTag: CONTAINER_IMAGES_TAG - name: gcr.io/google-samples/microservices-demo/frontend - newTag: @(CONTAINER_IMAGES_TAG) + newTag: CONTAINER_IMAGES_TAG - name: gcr.io/google-samples/microservices-demo/loadgenerator - newTag: @(CONTAINER_IMAGES_TAG) + newTag: CONTAINER_IMAGES_TAG - name: gcr.io/google-samples/microservices-demo/paymentservice - newTag: @(CONTAINER_IMAGES_TAG) + newTag: CONTAINER_IMAGES_TAG - name: gcr.io/google-samples/microservices-demo/productcatalogservice - newTag: @(CONTAINER_IMAGES_TAG) + newTag: CONTAINER_IMAGES_TAG - name: gcr.io/google-samples/microservices-demo/recommendationservice - newTag: @(CONTAINER_IMAGES_TAG) + newTag: CONTAINER_IMAGES_TAG - name: gcr.io/google-samples/microservices-demo/shippingservice - newTag: @(CONTAINER_IMAGES_TAG) + newTag: CONTAINER_IMAGES_TAG diff --git a/kustomize/components/memorystore/README.md b/kustomize/components/memorystore/README.md index 20e6a2cd50f..d7d8a216446 100644 --- a/kustomize/components/memorystore/README.md +++ b/kustomize/components/memorystore/README.md @@ -39,7 +39,7 @@ Update current Kustomize manifest to target this Memorystore (Redis) instance. MEMORYSTORE_REGION=replace-with-the-region-of-your-memorystore-instance REDIS_IP=$(gcloud redis instances describe redis-cart --region=${MEMORYSTORE_REGION} --format='get(host)') REDIS_PORT=$(gcloud redis instances describe redis-cart --region=${MEMORYSTORE_REGION} --format='get(port)') -sed -i "s/@(REDIS_ADDR)/${REDIS_IP}:${REDIS_PORT}/g" components/memorystore/kustomization.yaml +sed -i "s/\"REDIS_ADDR\"/${REDIS_IP}:${REDIS_PORT}/g" components/memorystore/kustomization.yaml ``` You can locally render these manifests by running `kubectl kustomize .` as well as deploying them by running `kubectl apply -k .`. diff --git a/kustomize/components/memorystore/kustomization.yaml b/kustomize/components/memorystore/kustomization.yaml index c8aac627c0a..79331747bd1 100644 --- a/kustomize/components/memorystore/kustomization.yaml +++ b/kustomize/components/memorystore/kustomization.yaml @@ -28,7 +28,7 @@ patchesStrategicMerge: - name: server env: - name: REDIS_ADDR - value: "@(REDIS_ADDR)" + value: "REDIS_ADDR" # redis - remove the redis-cart Deployment - |- apiVersion: apps/v1 diff --git a/terraform/memorystore.tf b/terraform/memorystore.tf index 95adf7e7b46..c15e24afa42 100644 --- a/terraform/memorystore.tf +++ b/terraform/memorystore.tf @@ -34,7 +34,7 @@ resource "google_redis_instance" "redis-cart" { resource "null_resource" "kustomization-update" { provisioner "local-exec" { interpreter = ["bash", "-exc"] - command = "sed -i \"s/@(REDIS_ADDR)/${google_redis_instance.redis-cart[0].host}:${google_redis_instance.redis-cart[0].port}/g\" ../kustomize/components/memorystore/kustomization.yaml" + command = "sed -i \"s/\"REDIS_ADDR\"/${google_redis_instance.redis-cart[0].host}:${google_redis_instance.redis-cart[0].port}/g\" ../kustomize/components/memorystore/kustomization.yaml" } # count specifies the number of instances to create; From 7c5acf7220d8b7322125d49437ddb8b51a0cb143 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 30 Sep 2022 18:34:35 -0400 Subject: [PATCH 14/25] More documentation for the new Kustomize variations --- .github/workflows/kustomize-build-ci.yaml | 6 +-- hack/make-docker-images.sh | 4 +- kustomize/README.md | 5 +++ .../container-images-registry/README.md | 27 +++++++++++ .../container-images-tag-suffix/README.md | 45 +++++++++++++++++++ .../components/container-images-tag/README.md | 41 +++++++++++++++++ .../native-grpc-health-check/README.md | 26 +++++------ 7 files changed, 136 insertions(+), 18 deletions(-) create mode 100644 kustomize/components/container-images-registry/README.md create mode 100644 kustomize/components/container-images-tag-suffix/README.md create mode 100644 kustomize/components/container-images-tag/README.md diff --git a/.github/workflows/kustomize-build-ci.yaml b/.github/workflows/kustomize-build-ci.yaml index 565fd2d1703..1146d5e9517 100644 --- a/.github/workflows/kustomize-build-ci.yaml +++ b/.github/workflows/kustomize-build-ci.yaml @@ -59,11 +59,11 @@ jobs: cd components/network-policies kustomize edit remove resource network-policy-redis.yaml cd ../.. - sed -i "s/@(CONTAINER_IMAGES_TAG)/v1.0.0/g" components/container-images-tag/kustomization.yaml + sed -i "s/CONTAINER_IMAGES_TAG/v1.0.0/g" components/container-images-tag/kustomization.yaml kustomize edit add component components/container-images-tag - sed -i "s/@(CONTAINER_IMAGES_TAG_SUFFIX)/-test/g" components/container-images-tag-suffix/kustomization.yaml + sed -i "s/CONTAINER_IMAGES_TAG_SUFFIX/-test/g" components/container-images-tag-suffix/kustomization.yaml kustomize edit add component components/container-images-tag-suffix - sed -i "s/@(CONTAINER_IMAGES_REGISTRY)/my-registry/g" components/container-images-registry/kustomization.yaml + sed -i "s/CONTAINER_IMAGES_REGISTRY/my-registry/g" components/container-images-registry/kustomization.yaml kustomize edit add component components/container-images-registry kustomize edit add component components/native-grpc-health-check kustomize build . diff --git a/hack/make-docker-images.sh b/hack/make-docker-images.sh index cc850a51bea..873b1fb54e4 100755 --- a/hack/make-docker-images.sh +++ b/hack/make-docker-images.sh @@ -38,11 +38,11 @@ while IFS= read -d $'\0' -r dir; do cd "${builddir}" log "Building: ${image}" docker build -t "${image}" . - docker build -t "${image}-native-grpc" . --target without-grpc-health-probe-bin + docker build -t "${image}-native-grpc-probes" . --target without-grpc-health-probe-bin log "Pushing: ${image}" docker push "${image}" - docker push "${image}-native-grpc" + docker push "${image}-native-grpc-probes" ) done < <(find "${SCRIPTDIR}/../src" -mindepth 1 -maxdepth 1 -type d -print0) diff --git a/kustomize/README.md b/kustomize/README.md index 12ce9b92aef..bff1b9bb3c1 100644 --- a/kustomize/README.md +++ b/kustomize/README.md @@ -77,6 +77,11 @@ Here is the list of the variations available as Kustomize components that you co - Deploy fine granular `NetworkPolicies` for Online Boutique. - [**Create Kubernetes Service Accounts**](components/service-accounts) - Deploy fine granular `ServiceAccounts` for Online Boutique. +- [**Support the native gRPC probes for Kubernetes 1.24+**](components/native-grpc-health-check) + - Deploy the Online Boutique apps by supporting the native gRPC probes for Kubernetes 1.24+. +- [**Update the registry name of the container images**](components/container-images-registry) +- [**Update the image tag of the container images**](components/container-images-tag) +- [**Add an image tag suffix to the container images**](components/container-images-tag-suffix) ### Select variations diff --git a/kustomize/components/container-images-registry/README.md b/kustomize/components/container-images-registry/README.md new file mode 100644 index 00000000000..9a054e80990 --- /dev/null +++ b/kustomize/components/container-images-registry/README.md @@ -0,0 +1,27 @@ +# Update the container registry of the Online Boutique apps + +By default, the Online Boutique apps are coming from the public container registry `gcr.io/google-samples/microservices-demo`. One best practice is to have these container images in your own private container registry, this Kustomize variation will help you setting this up. + +## Change the default container registry via Kustomize + +To automate the deployment of Online Boutique integrated with your own container registry, you can leverage the following variation with [Kustomize](../..). + +From the `kustomize/` folder at the root level of this repository, execute this command: +``` +REGISTRY=my-registry +sed -i "s/CONTAINER_IMAGES_REGISTRY/$REGISTRY/g" components/container-images-registry/kustomization.yaml +kustomize edit add components/container-images-registry +``` +_Note: this Kustomize component will update the container registry in the `image:` field in all `Deployments`._ + +This will update the `kustomize/kustomization.yaml` file which could be similar to: +``` +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- base +components: +- components/container-images-registry +``` + +You can locally render these manifests by running `kubectl kustomize .` as well as deploying them by running `kubectl apply -k .`. diff --git a/kustomize/components/container-images-tag-suffix/README.md b/kustomize/components/container-images-tag-suffix/README.md new file mode 100644 index 00000000000..ca473a3c718 --- /dev/null +++ b/kustomize/components/container-images-tag-suffix/README.md @@ -0,0 +1,45 @@ +# Add a suffix the container image tag of the Online Boutique apps + +You may need to add a suffix to the Online Boutique container image tag to target a specific version, this Kustomize variation will help you setting this up. + +## Add a suffix to the container image tag via Kustomize + +To automate the deployment of the Online Boutique apps with a suffix added to the container imag tag, you can leverage the following variation with [Kustomize](../..). + +From the `kustomize/` folder at the root level of this repository, execute this command: +``` +SUFFIX=-test +sed -i "s/CONTAINER_IMAGES_TAG_SUFFIX/$SUFFIX/g" components/container-images-tag-suffix/kustomization.yaml +kustomize edit add components/container-images-tag-suffix +``` +_Note: this Kustomize component will add a suffix to the container image tag of the `image:` field in all `Deployments`._ + +This will update the `kustomize/kustomization.yaml` file which could be similar to: +``` +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- base +components: +- components/container-images-tag-suffix +``` + +You can locally render these manifests by running `kubectl kustomize . | sed "s/$SUFFIX$SUFFIX/$SUFFIX/g"` as well as deploying them by running `kubectl kustomize . | sed "s/$SUFFIX$SUFFIX/$SUFFIX/g" | kubectl apply -f`. + +_Note: for this variation, `kubectl apply -k .` won't work because there is a [known issue currently in Kustomize](https://github.com/kubernetes-sigs/kustomize/issues/4814) where the `tagSuffix` is duplicated. The command lines above are a temporary workaround._ + +**Important notes:** if combining with the other variations, here are some considerations: +- should be placed before `components/container-images-registry` +- should be placed after `components/container-images-tag` + +So for example here is the order respected: +``` +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- base +components: +- components/container-images-tag +- components/container-images-tag-suffix +- components/container-images-registry +``` \ No newline at end of file diff --git a/kustomize/components/container-images-tag/README.md b/kustomize/components/container-images-tag/README.md new file mode 100644 index 00000000000..84342c53b80 --- /dev/null +++ b/kustomize/components/container-images-tag/README.md @@ -0,0 +1,41 @@ +# Update the container image tag of the Online Boutique apps + +By default, the Online Boutique apps are targeting the latest release version (see the list of versions [here](https://github.com/GoogleCloudPlatform/microservices-demo/releases)). You may need to change this image tag to target a specific version, this Kustomize variation will help you setting this up. + +## Change the default container image tag via Kustomize + +To automate the deployment of the Online Boutique apps with a specific container imag tag, you can leverage the following variation with [Kustomize](../..). + +From the `kustomize/` folder at the root level of this repository, execute this command: +``` +TAG=v1.0.0 +sed -i "s/CONTAINER_IMAGES_TAG/$TAG/g" components/container-images-tag/kustomization.yaml +kustomize edit add components/container-images-tag +``` +_Note: this Kustomize component will update the container image tag of the `image:` field in all `Deployments`._ + +This will update the `kustomize/kustomization.yaml` file which could be similar to: +``` +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- base +components: +- components/container-images-tag +``` + +You can locally render these manifests by running `kubectl kustomize .` as well as deploying them by running `kubectl apply -k .`. + +**Important notes:** if combining with the other variations, here are some considerations: +- should be placed before `components/container-images-registry` + +So for example here is the order respected: +``` +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- base +components: +- components/container-images-tag +- components/container-images-registry +``` \ No newline at end of file diff --git a/kustomize/components/native-grpc-health-check/README.md b/kustomize/components/native-grpc-health-check/README.md index c2038fc8db6..ed2c0e5cbfd 100644 --- a/kustomize/components/native-grpc-health-check/README.md +++ b/kustomize/components/native-grpc-health-check/README.md @@ -1,18 +1,19 @@ -# Integrate Online Boutique with native gRPC Healthcheck probes +# Integrate Online Boutique with native gRPC probes -FIXME +The current container images of the Online Boutique apps contains the [grpc-health-probe](https://github.com/grpc-ecosystem/grpc-health-probe) binary in order to have their `liveness` and `readiness` probes working on Kubernetes. But, since [Kubernetes 1.24, gRPC container probes feature is in beta](https://kubernetes.io/blog/2022/05/13/grpc-probes-now-in-beta/), and this binary could be removed from the container images and the associated `Deployment` manifests can directly use the new gRPC probes (`liveness` and `readiness`). -Kubernetes 1.24+ +## Deploy Online Boutique integrated with native gRPC probes -## Deploy Online Boutique connected to a Memorystore (Redis) instance - -To automate the deployment of Online Boutique integrated with Memorystore (Redis) you can leverage the following variation with [Kustomize](../..). +To automate the deployment of Online Boutique integrated with native gRPC probes you can leverage the following variation with [Kustomize](../..). From the `kustomize/` folder at the root level of this repository, execute this command: ``` +SUFFIX=-native-grpc-probes +sed -i "s/CONTAINER_IMAGES_TAG_SUFFIX/$SUFFIX/g" components/container-images-tag-suffix/kustomization.yaml kustomize edit add components/container-images-tag-suffix +kustomize edit add components/native-grpc-health-check ``` -_Note: this Kustomize component will also remove the `redis-cart` `Deployment` and `Service` not used anymore._ +_Note: we are applying the `-native-grpc-probes` tag suffix to all the container images, it's a prebuilt image without the [grpc-health-probe](https://github.com/grpc-ecosystem/grpc-health-probe) binary since the version 0.3.10 of Online Boutique._ This will update the `kustomize/kustomization.yaml` file which could be similar to: ``` @@ -22,15 +23,14 @@ resources: - base components: - components/container-images-tag-suffix +- components/native-grpc-health-check ``` -Update current Kustomize manifest to target the new container images tag (same tag as default tag but with the suffix `-native-grpc`). -```sh -sed -i "s/$(CONTAINER_IMAGES_TAG_SUFFIX)/-native-grpc/g" components/container-images-tag-suffix/kustomization.yaml -``` +You can locally render these manifests by running `kubectl kustomize . | sed "s/$SUFFIX$SUFFIX/$SUFFIX/g"` as well as deploying them by running `kubectl kustomize . | sed "s/$SUFFIX$SUFFIX/$SUFFIX/g" | kubectl apply -f`. -You can locally render these manifests by running `kubectl kustomize .` as well as deploying them by running `kubectl apply -k .`. +_Note: for this variation, `kubectl apply -k .` won't work because there is a [known issue currently in Kustomize](https://github.com/kubernetes-sigs/kustomize/issues/4814) where the `tagSuffix` is duplicated. The command lines above are a temporary workaround._ ## Resources -- FIXME +- [Kubernetes 1.24: gRPC container probes in beta](https://kubernetes.io/blog/2022/05/13/grpc-probes-now-in-beta/) +- [Define a gRPC liveness probe](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-grpc-liveness-probe) From 722907ae2ba36fd72a2e6ca7190f03fdcc00de75 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 30 Sep 2022 18:42:46 -0400 Subject: [PATCH 15/25] fix docs --- kustomize/components/container-images-registry/README.md | 2 +- kustomize/components/container-images-tag-suffix/README.md | 2 +- kustomize/components/container-images-tag/README.md | 2 +- kustomize/components/cymbal-branding/README.md | 2 +- kustomize/components/google-cloud-operations/README.md | 2 +- kustomize/components/memorystore/README.md | 2 +- kustomize/components/native-grpc-health-check/README.md | 4 ++-- kustomize/components/network-policies/README.md | 2 +- kustomize/components/service-accounts/README.md | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/kustomize/components/container-images-registry/README.md b/kustomize/components/container-images-registry/README.md index 9a054e80990..f799e637935 100644 --- a/kustomize/components/container-images-registry/README.md +++ b/kustomize/components/container-images-registry/README.md @@ -10,7 +10,7 @@ From the `kustomize/` folder at the root level of this repository, execute this ``` REGISTRY=my-registry sed -i "s/CONTAINER_IMAGES_REGISTRY/$REGISTRY/g" components/container-images-registry/kustomization.yaml -kustomize edit add components/container-images-registry +kustomize edit add component components/container-images-registry ``` _Note: this Kustomize component will update the container registry in the `image:` field in all `Deployments`._ diff --git a/kustomize/components/container-images-tag-suffix/README.md b/kustomize/components/container-images-tag-suffix/README.md index ca473a3c718..999d9bc0c27 100644 --- a/kustomize/components/container-images-tag-suffix/README.md +++ b/kustomize/components/container-images-tag-suffix/README.md @@ -10,7 +10,7 @@ From the `kustomize/` folder at the root level of this repository, execute this ``` SUFFIX=-test sed -i "s/CONTAINER_IMAGES_TAG_SUFFIX/$SUFFIX/g" components/container-images-tag-suffix/kustomization.yaml -kustomize edit add components/container-images-tag-suffix +kustomize edit add component components/container-images-tag-suffix ``` _Note: this Kustomize component will add a suffix to the container image tag of the `image:` field in all `Deployments`._ diff --git a/kustomize/components/container-images-tag/README.md b/kustomize/components/container-images-tag/README.md index 84342c53b80..7a2cde008b7 100644 --- a/kustomize/components/container-images-tag/README.md +++ b/kustomize/components/container-images-tag/README.md @@ -10,7 +10,7 @@ From the `kustomize/` folder at the root level of this repository, execute this ``` TAG=v1.0.0 sed -i "s/CONTAINER_IMAGES_TAG/$TAG/g" components/container-images-tag/kustomization.yaml -kustomize edit add components/container-images-tag +kustomize edit add component components/container-images-tag ``` _Note: this Kustomize component will update the container image tag of the `image:` field in all `Deployments`._ diff --git a/kustomize/components/cymbal-branding/README.md b/kustomize/components/cymbal-branding/README.md index 4fe87756164..e3b9acc6b4c 100644 --- a/kustomize/components/cymbal-branding/README.md +++ b/kustomize/components/cymbal-branding/README.md @@ -30,7 +30,7 @@ To automate the deployment of Online Boutique with the Cymbal Shops branding you From the `kustomize/` folder at the root level of this repository, execute this command: ``` -kustomize edit add components/cymbal-branding +kustomize edit add component components/cymbal-branding ``` This will update the `kustomize/kustomization.yaml` file which could be similar to: diff --git a/kustomize/components/google-cloud-operations/README.md b/kustomize/components/google-cloud-operations/README.md index 17f9c1442c5..233783d50bc 100644 --- a/kustomize/components/google-cloud-operations/README.md +++ b/kustomize/components/google-cloud-operations/README.md @@ -47,7 +47,7 @@ To automate the deployment of Online Boutique integrated with Google Cloud Opera From the `kustomize/` folder at the root level of this repository, execute this command: ``` -kustomize edit add components/google-cloud-operations +kustomize edit add component components/google-cloud-operations ``` This will update the `kustomize/kustomization.yaml` file which could be similar to: diff --git a/kustomize/components/memorystore/README.md b/kustomize/components/memorystore/README.md index d7d8a216446..7329c8dfa18 100644 --- a/kustomize/components/memorystore/README.md +++ b/kustomize/components/memorystore/README.md @@ -20,7 +20,7 @@ To automate the deployment of Online Boutique integrated with Memorystore (Redis From the `kustomize/` folder at the root level of this repository, execute this command: ``` -kustomize edit add components/memorystore +kustomize edit add component components/memorystore ``` _Note: this Kustomize component will also remove the `redis-cart` `Deployment` and `Service` not used anymore._ diff --git a/kustomize/components/native-grpc-health-check/README.md b/kustomize/components/native-grpc-health-check/README.md index ed2c0e5cbfd..6586c83cf4b 100644 --- a/kustomize/components/native-grpc-health-check/README.md +++ b/kustomize/components/native-grpc-health-check/README.md @@ -10,8 +10,8 @@ From the `kustomize/` folder at the root level of this repository, execute this ``` SUFFIX=-native-grpc-probes sed -i "s/CONTAINER_IMAGES_TAG_SUFFIX/$SUFFIX/g" components/container-images-tag-suffix/kustomization.yaml -kustomize edit add components/container-images-tag-suffix -kustomize edit add components/native-grpc-health-check +kustomize edit add component components/container-images-tag-suffix +kustomize edit add component components/native-grpc-health-check ``` _Note: we are applying the `-native-grpc-probes` tag suffix to all the container images, it's a prebuilt image without the [grpc-health-probe](https://github.com/grpc-ecosystem/grpc-health-probe) binary since the version 0.3.10 of Online Boutique._ diff --git a/kustomize/components/network-policies/README.md b/kustomize/components/network-policies/README.md index 2d4de950d4f..5ffd87dedc1 100644 --- a/kustomize/components/network-policies/README.md +++ b/kustomize/components/network-policies/README.md @@ -10,7 +10,7 @@ To automate the deployment of Online Boutique integrated with fine granular `Net From the `kustomize/` folder at the root level of this repository, execute this command: ``` -kustomize edit add components/network-policies +kustomize edit add component components/network-policies ``` This will update the `kustomize/kustomization.yaml` file which could be similar to: diff --git a/kustomize/components/service-accounts/README.md b/kustomize/components/service-accounts/README.md index 8ea45bcd8eb..cade675c188 100644 --- a/kustomize/components/service-accounts/README.md +++ b/kustomize/components/service-accounts/README.md @@ -8,7 +8,7 @@ To automate the deployment of Online Boutique integrated with fine granular `Ser From the `kustomize/` folder at the root level of this repository, execute this command: ``` -kustomize edit add components/service-accounts +kustomize edit add component components/service-accounts ``` _Note: this Kustomize component will also update the `serviceAccountName` field in all `Deployments`._ From 8908fec056da1a74d31a28827f2ff199c3e8bbb3 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Mon, 17 Oct 2022 13:51:47 -0400 Subject: [PATCH 16/25] update docs --- kustomize/README.md | 6 ++++-- kustomize/components/native-grpc-health-check/README.md | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/kustomize/README.md b/kustomize/README.md index bff1b9bb3c1..62d594c3907 100644 --- a/kustomize/README.md +++ b/kustomize/README.md @@ -71,8 +71,10 @@ Here is the list of the variations available as Kustomize components that you co - Changes all Online Boutique-related branding to Google Cloud's fictitious company — Cymbal Shops. The code adds/enables an environment variable `CYMBAL_BRANDING` in the `frontend` service. - [**Integrate with Google Cloud Operations**](components/google-cloud-operations) - Enables Monitoring (Stats), Tracing, Profiler, and Debugger for various services within Online Boutique. The code removes the existing environment variables (`DISABLE_STATS`, `DISABLE_TRACING`, `DISABLE_PROFILER`, `DISABLE_DEBUGGER`) from appropriate YAML config files. -- [**Integrate with Memorystore (redis)**](components/memorystore) - - The default Online Boutique deployment uses the in-cluster `redis` database for storing the contents of its shopping cart. The Memorystore deployment variation overrides the default database with its own Memorystore (redis) database. These changes directly affect `cartservice`. +- [**Integrate with Memorystore (Redis)**](components/memorystore) + - The default Online Boutique deployment uses the in-cluster `redis` database for storing the contents of its shopping cart. The Memorystore deployment variation overrides the default database with its own Memorystore (Redis) database. These changes directly affect `cartservice`. +- [**Integrate with Spanner**](components/memorystore) + - The default Online Boutique deployment uses the in-cluster `redis` database for storing the contents of its shopping cart. The Spanner deployment variation overrides the default database with its own Spanner database. These changes directly affect `cartservice`. - [**Secure with Network Policies**](components/network-policies) - Deploy fine granular `NetworkPolicies` for Online Boutique. - [**Create Kubernetes Service Accounts**](components/service-accounts) diff --git a/kustomize/components/native-grpc-health-check/README.md b/kustomize/components/native-grpc-health-check/README.md index 6586c83cf4b..2dcb8a436d7 100644 --- a/kustomize/components/native-grpc-health-check/README.md +++ b/kustomize/components/native-grpc-health-check/README.md @@ -13,7 +13,7 @@ sed -i "s/CONTAINER_IMAGES_TAG_SUFFIX/$SUFFIX/g" components/container-images-tag kustomize edit add component components/container-images-tag-suffix kustomize edit add component components/native-grpc-health-check ``` -_Note: we are applying the `-native-grpc-probes` tag suffix to all the container images, it's a prebuilt image without the [grpc-health-probe](https://github.com/grpc-ecosystem/grpc-health-probe) binary since the version 0.3.10 of Online Boutique._ +_Note: we are applying the `-native-grpc-probes` tag suffix to all the container images, it's a prebuilt image without the [grpc-health-probe](https://github.com/grpc-ecosystem/grpc-health-probe) binary since the version 0.4.0 of Online Boutique._ This will update the `kustomize/kustomization.yaml` file which could be similar to: ``` From 7b3096d509730f509c480232e3dbcf047d94df69 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 18 Oct 2022 08:30:34 -0400 Subject: [PATCH 17/25] fix link in doc --- kustomize/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kustomize/README.md b/kustomize/README.md index 62d594c3907..00f6cc25e29 100644 --- a/kustomize/README.md +++ b/kustomize/README.md @@ -73,7 +73,7 @@ Here is the list of the variations available as Kustomize components that you co - Enables Monitoring (Stats), Tracing, Profiler, and Debugger for various services within Online Boutique. The code removes the existing environment variables (`DISABLE_STATS`, `DISABLE_TRACING`, `DISABLE_PROFILER`, `DISABLE_DEBUGGER`) from appropriate YAML config files. - [**Integrate with Memorystore (Redis)**](components/memorystore) - The default Online Boutique deployment uses the in-cluster `redis` database for storing the contents of its shopping cart. The Memorystore deployment variation overrides the default database with its own Memorystore (Redis) database. These changes directly affect `cartservice`. -- [**Integrate with Spanner**](components/memorystore) +- [**Integrate with Spanner**](components/spanner) - The default Online Boutique deployment uses the in-cluster `redis` database for storing the contents of its shopping cart. The Spanner deployment variation overrides the default database with its own Spanner database. These changes directly affect `cartservice`. - [**Secure with Network Policies**](components/network-policies) - Deploy fine granular `NetworkPolicies` for Online Boutique. From 002c0db8979012df16a88294cb2e8c2a123d10d1 Mon Sep 17 00:00:00 2001 From: Nim Jayawardena Date: Fri, 21 Oct 2022 10:56:22 -0400 Subject: [PATCH 18/25] Fix container-images-registry/README.md --- kustomize/components/container-images-registry/README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kustomize/components/container-images-registry/README.md b/kustomize/components/container-images-registry/README.md index f799e637935..ee5cb9bcae3 100644 --- a/kustomize/components/container-images-registry/README.md +++ b/kustomize/components/container-images-registry/README.md @@ -1,6 +1,6 @@ # Update the container registry of the Online Boutique apps -By default, the Online Boutique apps are coming from the public container registry `gcr.io/google-samples/microservices-demo`. One best practice is to have these container images in your own private container registry, this Kustomize variation will help you setting this up. +By default, Online Boutique's services' container images are pulled from a public container registry (`gcr.io/google-samples/microservices-demo`). One best practice is to have these container images in your own private container registry. The Kustomize variation in this folder can help with using your own private container registry. ## Change the default container registry via Kustomize @@ -8,8 +8,8 @@ To automate the deployment of Online Boutique integrated with your own container From the `kustomize/` folder at the root level of this repository, execute this command: ``` -REGISTRY=my-registry -sed -i "s/CONTAINER_IMAGES_REGISTRY/$REGISTRY/g" components/container-images-registry/kustomization.yaml +REGISTRY=my-registry # Example: gcr.io/my-project/my-directory +sed -i "s|CONTAINER_IMAGES_REGISTRY|${REGISTRY}|g" components/container-images-registry/kustomization.yaml kustomize edit add component components/container-images-registry ``` _Note: this Kustomize component will update the container registry in the `image:` field in all `Deployments`._ @@ -24,4 +24,5 @@ components: - components/container-images-registry ``` -You can locally render these manifests by running `kubectl kustomize .` as well as deploying them by running `kubectl apply -k .`. +You can locally render these manifests by running `kubectl kustomize .`. +You can deploy them by running `kubectl apply -k .`. From 4c227ff7ad75ad61aad090dd97dba29ba8eecf7c Mon Sep 17 00:00:00 2001 From: Nim Jayawardena Date: Fri, 21 Oct 2022 11:01:41 -0400 Subject: [PATCH 19/25] Update container-images-registry/README.md --- kustomize/components/container-images-registry/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kustomize/components/container-images-registry/README.md b/kustomize/components/container-images-registry/README.md index ee5cb9bcae3..2e6deaf4f30 100644 --- a/kustomize/components/container-images-registry/README.md +++ b/kustomize/components/container-images-registry/README.md @@ -24,5 +24,5 @@ components: - components/container-images-registry ``` -You can locally render these manifests by running `kubectl kustomize .`. +You can (optionally) locally render these manifests by running `kubectl kustomize .`. You can deploy them by running `kubectl apply -k .`. From f4f3360f9bf26f4347cfa908433aecc9031ff3e2 Mon Sep 17 00:00:00 2001 From: Nim Jayawardena Date: Fri, 21 Oct 2022 11:09:08 -0400 Subject: [PATCH 20/25] Update container-images-tag-suffix/README.md --- .../components/container-images-tag-suffix/README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kustomize/components/container-images-tag-suffix/README.md b/kustomize/components/container-images-tag-suffix/README.md index 999d9bc0c27..591cecf474c 100644 --- a/kustomize/components/container-images-tag-suffix/README.md +++ b/kustomize/components/container-images-tag-suffix/README.md @@ -1,6 +1,7 @@ -# Add a suffix the container image tag of the Online Boutique apps +# Add a suffix to the image tag of the Online Boutique container images -You may need to add a suffix to the Online Boutique container image tag to target a specific version, this Kustomize variation will help you setting this up. +You may want to add a suffix to the Online Boutique container image tag to target a specific version. +The Kustomize Component inside this folder can help. ## Add a suffix to the container image tag via Kustomize @@ -8,7 +9,7 @@ To automate the deployment of the Online Boutique apps with a suffix added to th From the `kustomize/` folder at the root level of this repository, execute this command: ``` -SUFFIX=-test +SUFFIX=-my-suffix sed -i "s/CONTAINER_IMAGES_TAG_SUFFIX/$SUFFIX/g" components/container-images-tag-suffix/kustomization.yaml kustomize edit add component components/container-images-tag-suffix ``` @@ -26,7 +27,7 @@ components: You can locally render these manifests by running `kubectl kustomize . | sed "s/$SUFFIX$SUFFIX/$SUFFIX/g"` as well as deploying them by running `kubectl kustomize . | sed "s/$SUFFIX$SUFFIX/$SUFFIX/g" | kubectl apply -f`. -_Note: for this variation, `kubectl apply -k .` won't work because there is a [known issue currently in Kustomize](https://github.com/kubernetes-sigs/kustomize/issues/4814) where the `tagSuffix` is duplicated. The command lines above are a temporary workaround._ +_Note: for this variation, `kubectl apply -k .` alone won't work because there is a [known issue currently in Kustomize](https://github.com/kubernetes-sigs/kustomize/issues/4814) where the `tagSuffix` is duplicated. The `sed "s/$SUFFIX$SUFFIX/$SUFFIX/g"` commands above are a temporary workaround._ **Important notes:** if combining with the other variations, here are some considerations: - should be placed before `components/container-images-registry` @@ -42,4 +43,4 @@ components: - components/container-images-tag - components/container-images-tag-suffix - components/container-images-registry -``` \ No newline at end of file +``` From a7d3fc7eb276e301287793201278f591d2b3650c Mon Sep 17 00:00:00 2001 From: Nim Jayawardena Date: Fri, 21 Oct 2022 11:21:09 -0400 Subject: [PATCH 21/25] Update container-images-tag-suffix/README.md --- kustomize/components/container-images-tag-suffix/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kustomize/components/container-images-tag-suffix/README.md b/kustomize/components/container-images-tag-suffix/README.md index 591cecf474c..e4cd3080314 100644 --- a/kustomize/components/container-images-tag-suffix/README.md +++ b/kustomize/components/container-images-tag-suffix/README.md @@ -29,9 +29,10 @@ You can locally render these manifests by running `kubectl kustomize . | sed "s/ _Note: for this variation, `kubectl apply -k .` alone won't work because there is a [known issue currently in Kustomize](https://github.com/kubernetes-sigs/kustomize/issues/4814) where the `tagSuffix` is duplicated. The `sed "s/$SUFFIX$SUFFIX/$SUFFIX/g"` commands above are a temporary workaround._ -**Important notes:** if combining with the other variations, here are some considerations: -- should be placed before `components/container-images-registry` -- should be placed after `components/container-images-tag` +## Combine with other Kustomize Components +If you're combining this Kustomize Component with other variations, here are some considerations: +- `components/container-images-tag-suffix` should be placed before `components/container-images-registry` +- `components/container-images-tag-suffix` should be placed after `components/container-images-tag` So for example here is the order respected: ``` From 533fdab83b8efcb9d46ac8b4ed70742c89d6e4ff Mon Sep 17 00:00:00 2001 From: Nim Jayawardena Date: Fri, 21 Oct 2022 11:30:46 -0400 Subject: [PATCH 22/25] Update native-grpc-health-check/README.md --- kustomize/components/native-grpc-health-check/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kustomize/components/native-grpc-health-check/README.md b/kustomize/components/native-grpc-health-check/README.md index 2dcb8a436d7..c5b18215e74 100644 --- a/kustomize/components/native-grpc-health-check/README.md +++ b/kustomize/components/native-grpc-health-check/README.md @@ -26,9 +26,10 @@ components: - components/native-grpc-health-check ``` -You can locally render these manifests by running `kubectl kustomize . | sed "s/$SUFFIX$SUFFIX/$SUFFIX/g"` as well as deploying them by running `kubectl kustomize . | sed "s/$SUFFIX$SUFFIX/$SUFFIX/g" | kubectl apply -f`. +You can (optionally) locally render these manifests by running `kubectl kustomize . | sed "s/$SUFFIX$SUFFIX/$SUFFIX/g"`. +You can deploy them by running `kubectl kustomize . | sed "s/$SUFFIX$SUFFIX/$SUFFIX/g" | kubectl apply -f`. -_Note: for this variation, `kubectl apply -k .` won't work because there is a [known issue currently in Kustomize](https://github.com/kubernetes-sigs/kustomize/issues/4814) where the `tagSuffix` is duplicated. The command lines above are a temporary workaround._ +_Note: for this variation, `kubectl apply -k .` alone won't work because there is a [known issue currently in Kustomize](https://github.com/kubernetes-sigs/kustomize/issues/4814) where the `tagSuffix` is duplicated. The `sed "s/$SUFFIX$SUFFIX/$SUFFIX/g"` commands above are a temporary workaround._ ## Resources From 3bfd68dfd2a94491a099707bf9d61fe104879b93 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 21 Oct 2022 11:32:11 -0400 Subject: [PATCH 23/25] yaml|bash|output in docs --- kustomize/components/container-images-registry/README.md | 4 ++-- .../components/container-images-tag-suffix/README.md | 6 +++--- kustomize/components/container-images-tag/README.md | 6 +++--- kustomize/components/cymbal-branding/README.md | 6 +++--- kustomize/components/google-cloud-operations/README.md | 8 ++++---- kustomize/components/memorystore/README.md | 2 +- kustomize/components/native-grpc-health-check/README.md | 4 ++-- kustomize/components/network-policies/README.md | 6 +++--- kustomize/components/service-accounts/README.md | 6 +++--- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/kustomize/components/container-images-registry/README.md b/kustomize/components/container-images-registry/README.md index 2e6deaf4f30..0429f1fd6a6 100644 --- a/kustomize/components/container-images-registry/README.md +++ b/kustomize/components/container-images-registry/README.md @@ -7,7 +7,7 @@ By default, Online Boutique's services' container images are pulled from a publi To automate the deployment of Online Boutique integrated with your own container registry, you can leverage the following variation with [Kustomize](../..). From the `kustomize/` folder at the root level of this repository, execute this command: -``` +```bash REGISTRY=my-registry # Example: gcr.io/my-project/my-directory sed -i "s|CONTAINER_IMAGES_REGISTRY|${REGISTRY}|g" components/container-images-registry/kustomization.yaml kustomize edit add component components/container-images-registry @@ -15,7 +15,7 @@ kustomize edit add component components/container-images-registry _Note: this Kustomize component will update the container registry in the `image:` field in all `Deployments`._ This will update the `kustomize/kustomization.yaml` file which could be similar to: -``` +```yaml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: diff --git a/kustomize/components/container-images-tag-suffix/README.md b/kustomize/components/container-images-tag-suffix/README.md index e4cd3080314..c47976da370 100644 --- a/kustomize/components/container-images-tag-suffix/README.md +++ b/kustomize/components/container-images-tag-suffix/README.md @@ -8,7 +8,7 @@ The Kustomize Component inside this folder can help. To automate the deployment of the Online Boutique apps with a suffix added to the container imag tag, you can leverage the following variation with [Kustomize](../..). From the `kustomize/` folder at the root level of this repository, execute this command: -``` +```bash SUFFIX=-my-suffix sed -i "s/CONTAINER_IMAGES_TAG_SUFFIX/$SUFFIX/g" components/container-images-tag-suffix/kustomization.yaml kustomize edit add component components/container-images-tag-suffix @@ -16,7 +16,7 @@ kustomize edit add component components/container-images-tag-suffix _Note: this Kustomize component will add a suffix to the container image tag of the `image:` field in all `Deployments`._ This will update the `kustomize/kustomization.yaml` file which could be similar to: -``` +```yaml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: @@ -35,7 +35,7 @@ If you're combining this Kustomize Component with other variations, here are som - `components/container-images-tag-suffix` should be placed after `components/container-images-tag` So for example here is the order respected: -``` +```yaml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: diff --git a/kustomize/components/container-images-tag/README.md b/kustomize/components/container-images-tag/README.md index 7a2cde008b7..8bd606edbad 100644 --- a/kustomize/components/container-images-tag/README.md +++ b/kustomize/components/container-images-tag/README.md @@ -7,7 +7,7 @@ By default, the Online Boutique apps are targeting the latest release version (s To automate the deployment of the Online Boutique apps with a specific container imag tag, you can leverage the following variation with [Kustomize](../..). From the `kustomize/` folder at the root level of this repository, execute this command: -``` +```bash TAG=v1.0.0 sed -i "s/CONTAINER_IMAGES_TAG/$TAG/g" components/container-images-tag/kustomization.yaml kustomize edit add component components/container-images-tag @@ -15,7 +15,7 @@ kustomize edit add component components/container-images-tag _Note: this Kustomize component will update the container image tag of the `image:` field in all `Deployments`._ This will update the `kustomize/kustomization.yaml` file which could be similar to: -``` +```yaml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: @@ -30,7 +30,7 @@ You can locally render these manifests by running `kubectl kustomize .` as well - should be placed before `components/container-images-registry` So for example here is the order respected: -``` +```yaml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: diff --git a/kustomize/components/cymbal-branding/README.md b/kustomize/components/cymbal-branding/README.md index e3b9acc6b4c..23840853453 100644 --- a/kustomize/components/cymbal-branding/README.md +++ b/kustomize/components/cymbal-branding/README.md @@ -5,7 +5,7 @@ But you may want to use Google Cloud's fictitious company, _Cymbal Shops_, inste To use "Cymbal Shops" branding, set the `CYMBAL_BRANDING` environment variable to `"true"` in the the Kubernetes manifest (`.yaml`) for the `frontend` Deployment. -``` +```yaml apiVersion: apps/v1 kind: Deployment metadata: @@ -29,12 +29,12 @@ spec: To automate the deployment of Online Boutique with the Cymbal Shops branding you can leverage the following variation with [Kustomize](../..). From the `kustomize/` folder at the root level of this repository, execute this command: -``` +```bash kustomize edit add component components/cymbal-branding ``` This will update the `kustomize/kustomization.yaml` file which could be similar to: -``` +```yaml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: diff --git a/kustomize/components/google-cloud-operations/README.md b/kustomize/components/google-cloud-operations/README.md index 80405ef3f69..1decc84ca42 100644 --- a/kustomize/components/google-cloud-operations/README.md +++ b/kustomize/components/google-cloud-operations/README.md @@ -4,7 +4,7 @@ By default, [Google Cloud Operations](https://cloud.google.com/products/operatio You can see the instrumentation status in your deployment by opening one of the `Deployment` YAML files and seeing: -```YAML +```yaml - name: DISABLE_STATS value: "1" - name: DISABLE_TRACING @@ -31,7 +31,7 @@ value: "0" You will also need to make sure that you have the associated Google APIs enabled in your Google Cloud project: -``` +```bash gcloud services enable \ monitoring.googleapis.com \ cloudtrace.googleapis.com \ @@ -67,12 +67,12 @@ gcloud projects add-iam-policy-binding ${PROJECT_ID} \ To automate the deployment of Online Boutique integrated with Google Cloud Operations you can leverage the following variation with [Kustomize](../..). From the `kustomize/` folder at the root level of this repository, execute this command: -``` +```bash kustomize edit add component components/google-cloud-operations ``` This will update the `kustomize/kustomization.yaml` file which could be similar to: -``` +```yaml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: diff --git a/kustomize/components/memorystore/README.md b/kustomize/components/memorystore/README.md index 5f22b063483..eb66eca079e 100644 --- a/kustomize/components/memorystore/README.md +++ b/kustomize/components/memorystore/README.md @@ -47,7 +47,7 @@ components: ``` Update current Kustomize manifest to target this Memorystore (Redis) instance. -```sh +```bash REDIS_IP=$(gcloud redis instances describe redis-cart --region=${REGION} --format='get(host)') REDIS_PORT=$(gcloud redis instances describe redis-cart --region=${REGION} --format='get(port)') sed -i "s/{{REDIS_ADDR}}/${REDIS_IP}:${REDIS_PORT}/g" components/memorystore/kustomization.yaml diff --git a/kustomize/components/native-grpc-health-check/README.md b/kustomize/components/native-grpc-health-check/README.md index 2dcb8a436d7..6603a203418 100644 --- a/kustomize/components/native-grpc-health-check/README.md +++ b/kustomize/components/native-grpc-health-check/README.md @@ -7,7 +7,7 @@ The current container images of the Online Boutique apps contains the [grpc-heal To automate the deployment of Online Boutique integrated with native gRPC probes you can leverage the following variation with [Kustomize](../..). From the `kustomize/` folder at the root level of this repository, execute this command: -``` +```bash SUFFIX=-native-grpc-probes sed -i "s/CONTAINER_IMAGES_TAG_SUFFIX/$SUFFIX/g" components/container-images-tag-suffix/kustomization.yaml kustomize edit add component components/container-images-tag-suffix @@ -16,7 +16,7 @@ kustomize edit add component components/native-grpc-health-check _Note: we are applying the `-native-grpc-probes` tag suffix to all the container images, it's a prebuilt image without the [grpc-health-probe](https://github.com/grpc-ecosystem/grpc-health-probe) binary since the version 0.4.0 of Online Boutique._ This will update the `kustomize/kustomization.yaml` file which could be similar to: -``` +```yaml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: diff --git a/kustomize/components/network-policies/README.md b/kustomize/components/network-policies/README.md index 5ffd87dedc1..b9410443a78 100644 --- a/kustomize/components/network-policies/README.md +++ b/kustomize/components/network-policies/README.md @@ -9,12 +9,12 @@ To use `NetworkPolicies` in Google Kubernetes Engine (GKE), you will need a GKE To automate the deployment of Online Boutique integrated with fine granular `NetworkPolicies` (one per `Deployment`), you can leverage the following variation with [Kustomize](../..). From the `kustomize/` folder at the root level of this repository, execute this command: -``` +```bash kustomize edit add component components/network-policies ``` This will update the `kustomize/kustomization.yaml` file which could be similar to: -``` +```yaml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: @@ -31,7 +31,7 @@ kubectl get networkpolicy ``` The output could be similar to: -``` +```output NAME POD-SELECTOR AGE adservice app=adservice 2m58s cartservice app=cartservice 2m58s diff --git a/kustomize/components/service-accounts/README.md b/kustomize/components/service-accounts/README.md index cade675c188..fcea7accc8a 100644 --- a/kustomize/components/service-accounts/README.md +++ b/kustomize/components/service-accounts/README.md @@ -7,13 +7,13 @@ Creating a `ServiceAccount` per `Deployment` could be helpful if you need to def To automate the deployment of Online Boutique integrated with fine granular `ServiceAccounts` (one per `Deployment`), you can leverage the following variation with [Kustomize](../..). From the `kustomize/` folder at the root level of this repository, execute this command: -``` +```bash kustomize edit add component components/service-accounts ``` _Note: this Kustomize component will also update the `serviceAccountName` field in all `Deployments`._ This will update the `kustomize/kustomization.yaml` file which could be similar to: -``` +```yaml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: @@ -30,7 +30,7 @@ kubectl get serviceaccount ``` The output could be similar to: -``` +```output NAME SECRETS AGE default 1 2m58s adservice 1 2m58s From a92c135700f04e3660f044175905f25a249a004d Mon Sep 17 00:00:00 2001 From: Nim Jayawardena Date: Fri, 21 Oct 2022 11:35:16 -0400 Subject: [PATCH 24/25] Remove {{ }} around REDIS_ADDR --- kustomize/components/memorystore/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kustomize/components/memorystore/README.md b/kustomize/components/memorystore/README.md index eb66eca079e..c15800eaea2 100644 --- a/kustomize/components/memorystore/README.md +++ b/kustomize/components/memorystore/README.md @@ -50,7 +50,7 @@ Update current Kustomize manifest to target this Memorystore (Redis) instance. ```bash REDIS_IP=$(gcloud redis instances describe redis-cart --region=${REGION} --format='get(host)') REDIS_PORT=$(gcloud redis instances describe redis-cart --region=${REGION} --format='get(port)') -sed -i "s/{{REDIS_ADDR}}/${REDIS_IP}:${REDIS_PORT}/g" components/memorystore/kustomization.yaml +sed -i "s/REDIS_ADDR/${REDIS_IP}:${REDIS_PORT}/g" components/memorystore/kustomization.yaml ``` You can locally render these manifests by running `kubectl kustomize .` as well as deploying them by running `kubectl apply -k .`. From f60a67fabbd855df4c0f703ea6bb3918e4b214f1 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 21 Oct 2022 11:51:17 -0400 Subject: [PATCH 25/25] fix "REDIS_ADDR" token --- kustomize/components/memorystore/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kustomize/components/memorystore/README.md b/kustomize/components/memorystore/README.md index c15800eaea2..84dd5ff0615 100644 --- a/kustomize/components/memorystore/README.md +++ b/kustomize/components/memorystore/README.md @@ -50,7 +50,7 @@ Update current Kustomize manifest to target this Memorystore (Redis) instance. ```bash REDIS_IP=$(gcloud redis instances describe redis-cart --region=${REGION} --format='get(host)') REDIS_PORT=$(gcloud redis instances describe redis-cart --region=${REGION} --format='get(port)') -sed -i "s/REDIS_ADDR/${REDIS_IP}:${REDIS_PORT}/g" components/memorystore/kustomization.yaml +sed -i "s/\"REDIS_ADDR\"/${REDIS_IP}:${REDIS_PORT}/g" components/memorystore/kustomization.yaml ``` You can locally render these manifests by running `kubectl kustomize .` as well as deploying them by running `kubectl apply -k .`.