Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kustomize variation to deploy Online Boutique apps without the grpc-health-probe bin #1102

Merged
merged 37 commits into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f3e6ef7
without-grpc-health-probe-bin
Sep 27, 2022
b1e0835
Merge branch 'main' into mathieu-benoit/without-grpc-health-probe-bin
mathieu-benoit Sep 27, 2022
b53a97b
Merge branch 'main' into mathieu-benoit/without-grpc-health-probe-bin
mathieu-benoit Sep 29, 2022
f458993
fix docker build for cartservice
Sep 29, 2022
8d1bd03
kustomize - add container-image-registry
Sep 29, 2022
9c31b94
kustomize - add container-image-tag
Sep 29, 2022
921a04c
kustomize - add container-image-tag-suffix
Sep 29, 2022
1f4d261
fix container-images-registry
Sep 29, 2022
c146e00
fix container-images-tag
Sep 29, 2022
e44a138
complete native-grpc-health-check Kustomize variation
Sep 29, 2022
bd38492
Review tokens in Kustomize files: $() instead of {{}} (issues with Ku…
Sep 29, 2022
72a2bfb
Merge branch 'main' into mathieu-benoit/without-grpc-health-probe-bin
mathieu-benoit Sep 30, 2022
5ed543a
docker build -t "${image}-native-grpc"
Sep 30, 2022
0ca4a52
Bonify the custom test in Kustomize CI
Sep 30, 2022
77a38a0
Review token to avoid issue in bash with sed: @() instead of $()
Sep 30, 2022
403eb0b
Fix token issues with Kustomize
Sep 30, 2022
7c5acf7
More documentation for the new Kustomize variations
Sep 30, 2022
722907a
fix docs
Sep 30, 2022
a93644a
Merge branch 'main' into mathieu-benoit/without-grpc-health-probe-bin
mathieu-benoit Oct 3, 2022
bf130b4
Merge branch 'main' into mathieu-benoit/without-grpc-health-probe-bin
mathieu-benoit Oct 3, 2022
37c0688
Merge branch 'main' into mathieu-benoit/without-grpc-health-probe-bin
mathieu-benoit Oct 4, 2022
13d7c01
Merge branch 'main' into mathieu-benoit/without-grpc-health-probe-bin
minherz Oct 7, 2022
9fde09b
Merge branch 'main' into mathieu-benoit/without-grpc-health-probe-bin
minherz Oct 10, 2022
d05e994
Merge branch 'main' into mathieu-benoit/without-grpc-health-probe-bin
mathieu-benoit Oct 17, 2022
8908fec
update docs
Oct 17, 2022
7b3096d
fix link in doc
mathieu-benoit Oct 18, 2022
3e0e2c3
Merge branch 'main' into mathieu-benoit/without-grpc-health-probe-bin
mathieu-benoit Oct 18, 2022
002c0db
Fix container-images-registry/README.md
NimJay Oct 21, 2022
4c227ff
Update container-images-registry/README.md
NimJay Oct 21, 2022
f4f3360
Update container-images-tag-suffix/README.md
NimJay Oct 21, 2022
1941536
Merge branch 'main' into mathieu-benoit/without-grpc-health-probe-bin
mathieu-benoit Oct 21, 2022
a7d3fc7
Update container-images-tag-suffix/README.md
NimJay Oct 21, 2022
533fdab
Update native-grpc-health-check/README.md
NimJay Oct 21, 2022
3bfd68d
yaml|bash|output in docs
Oct 21, 2022
15dd029
Merge branch 'mathieu-benoit/without-grpc-health-probe-bin' of https:…
Oct 21, 2022
a92c135
Remove {{ }} around REDIS_ADDR
NimJay Oct 21, 2022
f60a67f
fix "REDIS_ADDR" token
Oct 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions hack/make-docker-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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-probes" . --target without-grpc-health-probe-bin

log "Pushing: ${image}"
docker push "${image}"
docker push "${image}-native-grpc-probes"
mathieu-benoit marked this conversation as resolved.
Show resolved Hide resolved
)
done < <(find "${SCRIPTDIR}/../src" -mindepth 1 -maxdepth 1 -type d -print0)

Expand Down
9 changes: 7 additions & 2 deletions kustomize/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,19 @@ 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/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.
- [**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

Expand Down
28 changes: 28 additions & 0 deletions kustomize/components/container-images-registry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Update the container registry of the Online Boutique apps

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

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 # Example: gcr.io/my-project/my-directory
sed -i "s|CONTAINER_IMAGES_REGISTRY|${REGISTRY}|g" components/container-images-registry/kustomization.yaml
Copy link
Collaborator

@NimJay NimJay Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rationale for my change:
I've changed "s/CONTAINER_IMAGES_REGISTRY/$REGISTRY/g" to "s|CONTAINER_IMAGES_REGISTRY|$REGISTRY|g" because the /s inside gcr.io/my-project/my-directory were breaking the sed command. Now we're no longer using regexes (we're using |s instead) to avoid /s from the ${REGISTRY} variable being interpreted as special characters.

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:
```
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- base
components:
- components/container-images-registry
```

You can (optionally) locally render these manifests by running `kubectl kustomize .`.
You can deploy them by running `kubectl apply -k .`.
Original file line number Diff line number Diff line change
@@ -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
newName: CONTAINER_IMAGES_REGISTRY/adservice
- name: gcr.io/google-samples/microservices-demo/cartservice
newName: CONTAINER_IMAGES_REGISTRY/cartservice
- name: gcr.io/google-samples/microservices-demo/checkoutservice
newName: CONTAINER_IMAGES_REGISTRY/checkoutservice
- name: gcr.io/google-samples/microservices-demo/currencyservice
newName: CONTAINER_IMAGES_REGISTRY/currencyservice
- name: gcr.io/google-samples/microservices-demo/emailservice
newName: CONTAINER_IMAGES_REGISTRY/emailservice
- name: gcr.io/google-samples/microservices-demo/frontend
newName: CONTAINER_IMAGES_REGISTRY/frontend
- name: gcr.io/google-samples/microservices-demo/loadgenerator
newName: CONTAINER_IMAGES_REGISTRY/loadgenerator
- name: gcr.io/google-samples/microservices-demo/paymentservice
newName: CONTAINER_IMAGES_REGISTRY/paymentservice
- name: gcr.io/google-samples/microservices-demo/productcatalogservice
newName: CONTAINER_IMAGES_REGISTRY/productcatalogservice
- name: gcr.io/google-samples/microservices-demo/recommendationservice
newName: CONTAINER_IMAGES_REGISTRY/recommendationservice
- name: gcr.io/google-samples/microservices-demo/shippingservice
newName: CONTAINER_IMAGES_REGISTRY/shippingservice
46 changes: 46 additions & 0 deletions kustomize/components/container-images-tag-suffix/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Add a suffix to the image tag of the Online Boutique container images

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

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=-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
```
_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 .` 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._
mathieu-benoit marked this conversation as resolved.
Show resolved Hide resolved

**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
```
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions kustomize/components/container-images-tag/README.md
Original file line number Diff line number Diff line change
@@ -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 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:
```
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
```
39 changes: 39 additions & 0 deletions kustomize/components/container-images-tag/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -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
newTag: CONTAINER_IMAGES_TAG
- name: gcr.io/google-samples/microservices-demo/cartservice
newTag: CONTAINER_IMAGES_TAG
- name: gcr.io/google-samples/microservices-demo/checkoutservice
newTag: CONTAINER_IMAGES_TAG
- name: gcr.io/google-samples/microservices-demo/currencyservice
newTag: CONTAINER_IMAGES_TAG
- name: gcr.io/google-samples/microservices-demo/emailservice
newTag: CONTAINER_IMAGES_TAG
- name: gcr.io/google-samples/microservices-demo/frontend
newTag: CONTAINER_IMAGES_TAG
- name: gcr.io/google-samples/microservices-demo/loadgenerator
newTag: CONTAINER_IMAGES_TAG
- name: gcr.io/google-samples/microservices-demo/paymentservice
newTag: CONTAINER_IMAGES_TAG
- name: gcr.io/google-samples/microservices-demo/productcatalogservice
newTag: CONTAINER_IMAGES_TAG
- name: gcr.io/google-samples/microservices-demo/recommendationservice
newTag: CONTAINER_IMAGES_TAG
- name: gcr.io/google-samples/microservices-demo/shippingservice
newTag: CONTAINER_IMAGES_TAG
2 changes: 1 addition & 1 deletion kustomize/components/cymbal-branding/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion kustomize/components/google-cloud-operations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,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:
Expand Down
6 changes: 3 additions & 3 deletions kustomize/components/memorystore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ _Note: You can also find in this repository the Terraform script to provision th
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:
```bash
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._

Expand All @@ -47,7 +47,7 @@ components:
```

Update current Kustomize manifest to target this Memorystore (Redis) instance.
```bash
```sh
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Should we update this sed command?

Suggested change
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

Regarding: #1102 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, maybe a merge issue, let me check that and update this.

Expand Down
2 changes: 1 addition & 1 deletion kustomize/components/memorystore/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ patchesStrategicMerge:
- name: server
env:
- name: REDIS_ADDR
value: "{{REDIS_ADDR}}"
value: "REDIS_ADDR"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Is there a reason we remove the curly braces?
Should we also fix:

sed -i "s/{{REDIS_ADDR}}/${REDIS_IP}:${REDIS_PORT}/g" components/memorystore/kustomization.yaml

inside kustomize/components/memorystore/README.md?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it was an accident?

Suggested change
value: "REDIS_ADDR"
value: "{{REDIS_ADDR}}"

Copy link
Contributor Author

@mathieu-benoit mathieu-benoit Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Nim, good question, actually I had that in the description: Review the setup of tokens to avoid issues with Kustomize and bash session. So that's on purpose otherwise we have issue in bash session when doing the sed part and/or when doing kustomize build . without these tokens replaced. Let me know if you need more info. But the tl,dr is we should have token just like this REDIS_ADDR not with any {} nor {{}}, etc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following this today, one possible unintended side effect is that the sed now matches the name and value. So I end up with:

            - name: 10.34.24.75:6379
              value: "10.34.24.75:6379"

Copy link
Contributor Author

@mathieu-benoit mathieu-benoit Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's why we document this like this: f60a67f. But yeah if someone is not doing the \" it could land to this error. Open for suggestions to improve this for the different files having tokens like this. PR about that are more than welcome ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. I checked that I pulled latest and just reran the terraform deploy. I see the escape characters and the quote \" and it still seems to be replacing all of them.

To clarify, it worked in the sense that the application deployed beautifully, it just replaced all instances of REDIS_ADDR with 10.34.24.75:6379. (Including the instance at the top of the /microservices-demo/kustomize/components/memorystore/kustomization.yaml file.)

-# cartservice - replace REDIS_ADDR to target new Memorystore (redis) instance
+# cartservice - replace 10.34.24.75:6379 to target new Memorystore (redis) instance
 - |-
   apiVersion: apps/v1
   kind: Deployment
@@ -27,8 +27,8 @@ patchesStrategicMerge:
         containers:
           - name: server
             env:
-            - name: REDIS_ADDR
-              value: "REDIS_ADDR"
+            - name: 10.34.24.75:6379
+              value: "10.34.24.75:6379"
 # redis - remove the redis-cart Deployment
 - |-
   apiVersion: apps/v1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, thanks. Do you mind reporting this as a dedicated issue please? We will need to tackle this to fix this broken Terraform deployment with Memorystore. Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do that!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: this will be fixed via #1202. Thanks!

Copy link
Member

@LukeSchlangen LukeSchlangen Oct 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

I also had a solution (all the backslashes!!) that I was going to PR today, but that is much cleaner.

# redis - remove the redis-cart Deployment
- |-
apiVersion: apps/v1
Expand Down
36 changes: 36 additions & 0 deletions kustomize/components/native-grpc-health-check/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Integrate Online Boutique with native gRPC probes

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`).

## Deploy Online Boutique integrated with native gRPC probes

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 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.4.0 of Online Boutique._

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
- 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`.

_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

- [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)
Loading