kustomize/README.md
This page contains instructions on deploying variations of the Online Boutique sample application using Kustomize. Each variations is designed as a Kustomize component, so multiple variations can be composed together in the deployment.
Kustomize is a Kubernetes configuration management tool that allows users to customize their manifest configurations without duplication. Its commands are built into kubectl as apply -k. More information on Kustomize can be found on the official Kustomize website.
Optionally, install the kustomize binary to avoid manually editing a kustomization.yaml file. Online Boutique's instructions will often use kustomize edit (like kustomize edit add component components/some-component), but you can skip these commands and instead add components manually to the /kustomize/kustomization.yaml file.
You need to have a Kubernetes cluster where you will deploy the Online Boutique's Kubernetes manifests. To set up a GKE (Google Kubernetes Engine) cluster, you can follow the instruction in the root /README.md.
From the root folder of this repository, navigate to the kustomize/ directory.
cd kustomize/
See what the default Kustomize configuration defined by kustomize/kustomization.yaml will generate (without actually deploying them yet).
kubectl kustomize .
Apply the default Kustomize configuration (kustomize/kustomization.yaml).
kubectl apply -k .
Wait for all Pods to show STATUS of Running.
kubectl get pods
The output should be similar to the following:
NAME READY STATUS RESTARTS AGE
adservice-76bdd69666-ckc5j 1/1 Running 0 2m58s
cartservice-66d497c6b7-dp5jr 1/1 Running 0 2m59s
checkoutservice-666c784bd6-4jd22 1/1 Running 0 3m1s
currencyservice-5d5d496984-4jmd7 1/1 Running 0 2m59s
emailservice-667457d9d6-75jcq 1/1 Running 0 3m2s
frontend-6b8d69b9fb-wjqdg 1/1 Running 0 3m1s
loadgenerator-665b5cd444-gwqdq 1/1 Running 0 3m
paymentservice-68596d6dd6-bf6bv 1/1 Running 0 3m
productcatalogservice-557d474574-888kr 1/1 Running 0 3m
recommendationservice-69c56b74d4-7z8r5 1/1 Running 0 3m1s
shippingservice-6ccc89f8fd-v686r 1/1 Running 0 2m58s
Note: It may take 2-3 minutes before the changes are reflected on the deployment.
Access the web frontend in a browser using the frontend's EXTERNAL_IP.
kubectl get service frontend-external | awk '{print $4}'
Note: you may see <pending> while GCP provisions the load balancer. If this happens, wait a few minutes and re-run the command.
Here is the list of the variations available as Kustomize components that you could leverage:
CYMBAL_BRANDING in the frontend service.ENABLE_STATS, ENABLE_TRACING, DISABLE_PROFILER) for each YAML config file.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.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.redis database for storing the contents of its shopping cart. The AlloyDB deployment variation overrides the default database with its own AlloyDB database.
These changes directly affect cartservice.NetworkPolicies for Online Boutique.frontend publiclyfrontend to manage only one single shared sessionIstio service mesh resourcesTo customize Online Boutique with its variations, you need to update the default kustomize/kustomization.yaml file. You could do that manually, use sed, or use the kustomize edit command like illustrated below.
kustomize edit to select variationsHere is an example with the Cymbal Shops Branding variation, from the kustomize/ folder, run the command below:
kustomize edit add component components/cymbal-branding
You could now combine it with other variations, like for example with the Google Cloud Operations variation:
kustomize edit add component components/google-cloud-operations
Like explained earlier, you can locally render these manifests by running kubectl kustomize . as well as deploying them by running kubectl apply -k ..
So for example, the associated kustomization.yaml could look like:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- base
components:
- components/cymbal-branding
- components/google-cloud-operations
Kustomize allows you to reference public remote resources so the kustomization.yaml could look like:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- github.com/GoogleCloudPlatform/microservices-demo/kustomize/base
components:
- github.com/GoogleCloudPlatform/microservices-demo/kustomize/components/cymbal-branding
- github.com/GoogleCloudPlatform/microservices-demo/kustomize/components/google-cloud-operations
Learn more about Kustomize remote targets.