Skip to content

Commit 898815c

Browse files
authored
chore: update the online boutique to latest (#40)
* chore: update the online boutique to latest * fixing online boutique * reverting readme
1 parent 3f20034 commit 898815c

File tree

154 files changed

+15293
-4795
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+15293
-4795
lines changed

online-boutique-demo/cloudbuild.yaml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
# This configuration file is used to build and deploy the app into a
1+
# Copyright 2020 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# This configuration file is used to build and deploy the app into a
216
# GKE cluster using Google Cloud Build.
317
#
418
# PREREQUISITES:
@@ -13,13 +27,13 @@ steps:
1327
- id: 'Deploy application to cluster'
1428
name: 'gcr.io/k8s-skaffold/skaffold:v0.20.0'
1529
entrypoint: 'bash'
16-
args:
30+
args:
1731
- '-c'
18-
- >
32+
- >
1933
gcloud container clusters get-credentials --zone=$_ZONE $_CLUSTER;
2034
skaffold run -f=skaffold.yaml --default-repo=gcr.io/$PROJECT_ID;
2135
2236
# Add more power, and more time, for heavy Skaffold build
2337
timeout: '3600s'
2438
options:
25-
machineType: 'N1_HIGHCPU_8'
39+
machineType: 'N1_HIGHCPU_8'
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Online Boutique
2+
3+
##
4+
5+
This tutorial shows you how to deploy the cloud-native microservices demo application **[Online Boutique](https://github.com/GoogleCloudPlatform/microservices-demo)** to a Kubernetes cluster.
6+
7+
You'll be able to run Online Boutique on:
8+
9+
- a free [minikube](https://minikube.sigs.k8s.io/docs/) cluster, which comes built in to the Cloud Shell instance
10+
- a [Google Kubernetes Engine](https://cloud.google.com/kubernetes-engine) cluster using a new or existing [Google Cloud Platform project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#creating_a_project)
11+
12+
Let's get started!
13+
14+
## Kubernetes cluster setup
15+
16+
Set up a Kubernetes cluster using the instructions below for either **minikube** or **GKE**.
17+
18+
---
19+
### Minikube instructions
20+
21+
Minikube creates a local Kubernetes cluster on Cloud Shell.
22+
23+
1. Click <walkthrough-editor-spotlight spotlightId="minikube-status-bar">minikube</walkthrough-editor-spotlight> on the status bar located at the bottom of the editor window.
24+
25+
2. The command palette will prompt you to choose which minikube cluster to control. Select **minikube** and, in the next prompt, click **Start** if the cluster has not already been started.
26+
27+
3. If prompted, authorize Cloud Shell to make a GCP API call with your credentials.
28+
29+
*It may take a few minutes for minikube to finish starting.*
30+
31+
Once minikube has started, you're ready to move on to the next step.
32+
33+
34+
---
35+
36+
### GKE instructions
37+
38+
In order to create a GKE cluster, you'll need to **[create a Google Cloud Platform project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#creating_a_project)** or use an existing project.
39+
40+
1. Access the command palette by going to **View > Find Command**.
41+
42+
2. Run the command **"Cloud Code: Create GKE cluster"**.
43+
44+
3. Select your GCP project.
45+
46+
4. Apply the following configurations in the GKE wizard:
47+
> - Zone: us-central1-b
48+
> - Cluster name: onlineboutique
49+
> - Node count: 4
50+
> - Machine type: e2-standard-2
51+
52+
5. Click **Create Cluster**. Once your cluster has been created successfully, you can move on to the next step.
53+
54+
55+
## Run on Kubernetes
56+
57+
Now you can run Online Boutique on your Kubernetes cluster!
58+
59+
1. Launch the <walkthrough-editor-spotlight spotlightId="cloud-code-status-bar">Cloud Code menu</walkthrough-editor-spotlight> from the status bar and select <walkthrough-editor-spotlight spotlightId="cloud-code-run-on-k8s">Run on Kubernetes</walkthrough-editor-spotlight>.
60+
61+
2. If prompted to select a Skaffold Profile, select **[default]**.
62+
63+
3. Select **Yes** to confirm your current context.
64+
65+
4. If you're using a GKE cluster, you'll need to confirm your container image registry.
66+
67+
5. If prompted, authorize Cloud Shell to make a GCP API call with your credentials.
68+
69+
Cloud Code uses configurations defined in <walkthrough-editor-open-file filePath="skaffold.yaml">skaffold.yaml</walkthrough-editor-open-file> to build and deploy the app. *It may take a few minutes for the deploy to complete.*
70+
71+
6. Once the app is running, the local URLs will be displayed in the <walkthrough-editor-spotlight spotlightId="output">Output</walkthrough-editor-spotlight> terminal.
72+
73+
7. To access your Online Boutique frontend service, click on the <walkthrough-spotlight-pointer spotlightId="devshell-web-preview-button" target="cloudshell">Web Preview button</walkthrough-spotlight-pointer> in the upper right of the editor window.
74+
75+
8. Select **Change Port** and enter '4503' as the port, then click **Change and Preview**. Your app will open in a new window.
76+
77+
78+
## Stop the app
79+
80+
To stop running the app:
81+
82+
1. Go to the <walkthrough-editor-spotlight spotlightId="activity-bar-debug">Debug view</walkthrough-editor-spotlight>
83+
84+
2. Click the 'Stop' icon. 🟥
85+
86+
3. Select **Yes** to clean up deployed resources.
87+
88+
You can start, stop, and debug apps from the Debug view.
89+
90+
### Clean up
91+
92+
If you've deployed your app to a GKE cluster in your Google Cloud Platform project, you'll want to delete the cluster to avoid incurring charges.
93+
94+
1. Navigate to the <walkthrough-editor-spotlight spotlightId="activity-bar-cloud-k8s">Cloud Code - Kubernetes view</walkthrough-editor-spotlight> in the Activity bar.
95+
96+
2. Under the <walkthrough-editor-spotlight spotlightId="cloud-code-gke-explorer">Google Kubernetes Engine Explorer tab</walkthrough-editor-spotlight>, right-click on your cluster and select **Delete Cluster**.
97+
98+
99+
## Conclusion
100+
101+
<walkthrough-conclusion-trophy></walkthrough-conclusion-trophy>
102+
103+
Congratulations! You've successfully deployed Online Boutique using Cloud Shell.
104+
105+
<walkthrough-inline-feedback></walkthrough-inline-feedback>
106+
107+
##### What's next?
108+
109+
Try other deployment options for Online Boutique:
110+
- **Workload Identity**: <walkthrough-editor-open-file filePath="./docs/workload-identity.md">See these instructions</walkthrough-editor-open-file>.
111+
- **Istio**: <walkthrough-editor-open-file filePath="./docs/service-mesh.md">See these instructions</walkthrough-editor-open-file>.
112+
- **Anthos Service Mesh**: ASM requires Workload Identity to be enabled in your GKE cluster. <walkthrough-editor-open-file filePath="./docs/workload-identity.md">See these instructions</walkthrough-editor-open-file> to configure and deploy the app. Then, use the <walkthrough-editor-open-file filePath="./docs/service-mesh.md">service mesh guide</walkthrough-editor-open-file>.
113+
- **Memorystore**: <walkthrough-editor-open-file filePath="./docs/memorystore.md">See these instructions</walkthrough-editor-open-file> to replace the in-cluster `redis` database with hosted Google Cloud Memorystore (redis).
114+
115+
Learn more about the [Cloud Shell](https://cloud.google.com/shell) IDE environment and the [Cloud Code](https://cloud.google.com/code) extension.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Cymbal Shops Branding
2+
3+
By default, when you deploy this sample app, the "Online Boutique" branding (logo and wording) will be used.
4+
But you may want to use Google Cloud's fictitious company, _Cymbal Shops_, instead.
5+
6+
To use "Cymbal Shops" branding, set the `CYMBAL_BRANDING` environment variable to `"true"` in the the Kubernetes manifest (`.yaml`) for the `frontend` Deployment.
7+
8+
```
9+
apiVersion: apps/v1
10+
kind: Deployment
11+
metadata:
12+
name: frontend
13+
spec:
14+
...
15+
template:
16+
...
17+
spec:
18+
...
19+
containers:
20+
...
21+
env:
22+
...
23+
- name: CYMBAL_BRANDING
24+
value: "true"
25+
```
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Development Guide
2+
3+
This doc explains how to build and run the OnlineBoutique source code locally using the `skaffold` command-line tool.
4+
5+
## Prerequisites
6+
7+
- [Docker for Desktop](https://www.docker.com/products/docker-desktop).
8+
- kubectl (can be installed via `gcloud components install kubectl`)
9+
- [skaffold **1.27+**](https://skaffold.dev/docs/install/) (latest version recommended), a tool that builds and deploys Docker images in bulk.
10+
- A Google Cloud Project with Google Container Registry enabled.
11+
- Enable GCP APIs for Cloud Monitoring, Tracing, Debugger, Profiler:
12+
```
13+
gcloud services enable monitoring.googleapis.com \
14+
cloudtrace.googleapis.com \
15+
clouddebugger.googleapis.com \
16+
cloudprofiler.googleapis.com
17+
```
18+
- [Minikube](https://minikube.sigs.k8s.io/docs/start/) (optional - see Local Cluster)
19+
- [Kind](https://kind.sigs.k8s.io/) (optional - see Local Cluster)
20+
21+
## Option 1: Google Kubernetes Engine (GKE)
22+
23+
> 💡 Recommended if you're using Google Cloud Platform and want to try it on
24+
> a realistic cluster. **Note**: If your cluster has Workload Identity enabled,
25+
> [see these instructions](/docs/workload-identity.md)
26+
27+
1. Create a Google Kubernetes Engine cluster and make sure `kubectl` is pointing
28+
to the cluster.
29+
30+
```sh
31+
gcloud services enable container.googleapis.com
32+
```
33+
34+
```sh
35+
gcloud container clusters create demo --enable-autoupgrade \
36+
--enable-autoscaling --min-nodes=3 --max-nodes=10 --num-nodes=5 --zone=us-central1-a
37+
```
38+
39+
```
40+
kubectl get nodes
41+
```
42+
43+
2. Enable Google Container Registry (GCR) on your GCP project and configure the
44+
`docker` CLI to authenticate to GCR:
45+
46+
```sh
47+
gcloud services enable containerregistry.googleapis.com
48+
```
49+
50+
```sh
51+
gcloud auth configure-docker -q
52+
```
53+
54+
3. In the root of this repository, run `skaffold run --default-repo=gcr.io/[PROJECT_ID]`,
55+
where [PROJECT_ID] is your GCP project ID.
56+
57+
This command:
58+
59+
- builds the container images
60+
- pushes them to GCR
61+
- applies the `./kubernetes-manifests` deploying the application to
62+
Kubernetes.
63+
64+
**Troubleshooting:** If you get "No space left on device" error on Google
65+
Cloud Shell, you can build the images on Google Cloud Build: [Enable the
66+
Cloud Build
67+
API](https://console.cloud.google.com/flows/enableapi?apiid=cloudbuild.googleapis.com),
68+
then run `skaffold run -p gcb --default-repo=gcr.io/[PROJECT_ID]` instead.
69+
70+
4. Find the IP address of your application, then visit the application on your
71+
browser to confirm installation.
72+
73+
kubectl get service frontend-external
74+
75+
76+
## Option 2 - Local Cluster
77+
78+
1. Launch a local Kubernetes cluster with one of the following tools:
79+
80+
- To launch **Minikube** (tested with Ubuntu Linux). Please, ensure that the
81+
local Kubernetes cluster has at least:
82+
- 4 CPUs
83+
- 4.0 GiB memory
84+
- 32 GB disk space
85+
86+
```shell
87+
minikube start --cpus=4 --memory 4096 --disk-size 32g
88+
```
89+
90+
- To launch **Docker for Desktop** (tested with Mac/Windows). Go to Preferences:
91+
- choose “Enable Kubernetes”,
92+
- set CPUs to at least 3, and Memory to at least 6.0 GiB
93+
- on the "Disk" tab, set at least 32 GB disk space
94+
95+
- To launch a **Kind** cluster:
96+
97+
```shell
98+
kind create cluster
99+
```
100+
101+
2. Run `kubectl get nodes` to verify you're connected to the respective control plane.
102+
103+
3. Run `skaffold run` (first time will be slow, it can take ~20 minutes).
104+
This will build and deploy the application. If you need to rebuild the images
105+
automatically as you refactor the code, run `skaffold dev` command.
106+
107+
4. Run `kubectl get pods` to verify the Pods are ready and running.
108+
109+
5. Access the web frontend through your browser
110+
- **Minikube** requires you to run a command to access the frontend service:
111+
112+
```shell
113+
minikube service frontend-external
114+
```
115+
116+
- **Docker For Desktop** should automatically provide the frontend at http://localhost:80
117+
118+
- **Kind** does not provision an IP address for the service.
119+
You must run a port-forwarding process to access the frontend at http://localhost:8080:
120+
121+
```shell
122+
kubectl port-forward deployment/frontend 8080:8080
123+
```
124+
125+
## Cleanup
126+
127+
If you've deployed the application with `skaffold run` command, you can run
128+
`skaffold delete` to clean up the deployed resources.

online-boutique-demo/docs/development-principles.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Development Principles
22

33
> **Note:** This document outlines guidances behind some development decisions
4-
> behind the Hipster Shop demo application.
4+
> behind the Online Boutique demo application.
55
66
### Minimal configuration
77

Loading
167 KB
Loading
Loading
Loading

0 commit comments

Comments
 (0)