Skip to content

Commit 8c5d271

Browse files
Fixing doc for Spanner Kustomize overlay (GoogleCloudPlatform#1178)
* Fixing doc for Spanner Kustomize overlay * link to the associated blog * split spanner instance versus database provisioning for more clarity
1 parent 2131938 commit 8c5d271

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

Diff for: kustomize/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ Here is the list of the variations available as Kustomize components that you co
7373
- 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.
7474
- [**Integrate with Memorystore (redis)**](components/memorystore)
7575
- 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`.
76+
- [**Integrate with Spanner**](components/spanner)
77+
- 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`.
7678
- [**Secure with Network Policies**](components/network-policies)
7779
- Deploy fine granular `NetworkPolicies` for Online Boutique.
7880
- [**Create Kubernetes Service Accounts**](components/service-accounts)

Diff for: kustomize/components/spanner/README.md

+17-7
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,29 @@ Using a fully managed database service outside your GKE cluster (such as [Google
55

66
## Provision a Spanner database
77

8-
To provision a Spanner database you can follow the following instructions:
8+
To provision a Spanner instance you can follow the following instructions:
99
```bash
1010
gcloud services enable spanner.googleapis.com
1111

1212
SPANNER_REGION_CONFIG="<your-spanner-region-config-name>" # e.g. "regional-us-east5"
1313
SPANNER_INSTANCE_NAME=onlineboutique
14-
SPANNER_DATABASE_NAME=carts
1514

1615
gcloud spanner instances create ${SPANNER_INSTANCE_NAME} \
17-
--config ${SPANNER_REGION_CONFIG}
16+
--description="online boutique shopping cart" \
17+
--config ${SPANNER_REGION_CONFIG} \
18+
--instance-type free-instance
19+
```
20+
_Note: With latest version of `gcloud` we are creating a free Spanner instance._
21+
22+
To provision a Spanner database you can follow the following instructions:
23+
```bash
24+
SPANNER_DATABASE_NAME=carts
1825

1926
gcloud spanner databases create ${SPANNER_DATABASE_NAME} \
2027
--instance ${SPANNER_INSTANCE_NAME} \
2128
--database-dialect GOOGLE_STANDARD_SQL \
22-
--ddl-file ./src/cartservice/ddl/CartItems.ddl
29+
--ddl "CREATE TABLE CartItems (userId STRING(1024), productId STRING(1024), quantity INT64) PRIMARY KEY (userId, productId); CREATE INDEX CartItemsByUserId ON CartItems(userId);"
2330
```
24-
_Note: With latest version of `gcloud` you can create a free Spanner instance by leveraging the `--instance-type free-instance` parameter._
2531

2632
## Grant the `cartservice`'s service account access to the Spanner database
2733

@@ -78,9 +84,13 @@ sed -i "s/SPANNER_DB_USER_GSA_ID/${SPANNER_DB_USER_GSA_ID}/g" components/spanner
7884

7985
You can locally render these manifests by running `kubectl kustomize .` as well as deploying them by running `kubectl apply -k .`.
8086

81-
## Note on Spanner connection environmental variables
87+
## Note on Spanner connection environment variables
8288

8389
The following environment variables will be used by the `cartservice`, if present:
8490
- `SPANNER_INSTANCE`: defaults to `onlineboutique`, unless specified.
8591
- `SPANNER_DATABASE`: defaults to `carts`, unless specified.
86-
- `SPANNER_CONNECTION_STRING`: defaults to `projects/${SPANNER_PROJECT}/instances/${SPANNER_INSTANCE}/databases/${SPANNER_DATABASE}`. If this variable is defined explicitly, all other environmental variables will be ignored.
92+
- `SPANNER_CONNECTION_STRING`: defaults to `projects/${SPANNER_PROJECT}/instances/${SPANNER_INSTANCE}/databases/${SPANNER_DATABASE}`. If this variable is defined explicitly, all other environment variables will be ignored.
93+
94+
## Resources
95+
96+
- [Use Google Cloud Spanner with the Online Boutique sample apps](https://medium.com/google-cloud/f7248e077339)

Diff for: src/cartservice/ddl/CartItems.ddl

-7
This file was deleted.

0 commit comments

Comments
 (0)