|
| 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. |
0 commit comments