2018-06-13 21:22:48 +00:00
|
|
|
# Microservices demo
|
2018-07-02 17:24:11 +00:00
|
|
|
|
|
|
|
This project contains a 10-tier microservices application. The application is a
|
|
|
|
web-based e-commerce app called “Hipster Shop” where users can browse items,
|
|
|
|
add them to the cart, and purchase them.
|
|
|
|
|
2018-07-11 02:47:24 +00:00
|
|
|
### Running locally
|
2018-07-02 17:24:11 +00:00
|
|
|
|
2018-07-02 18:03:55 +00:00
|
|
|
1. Install:
|
|
|
|
|
|
|
|
- kubectl (can be installed via `gcloud components install kubectl`)
|
2018-07-11 02:47:24 +00:00
|
|
|
- Docker for Desktop (Mac/Windows): **Download the Edge release**; not the
|
|
|
|
stable. Edge release provides Kubernetes support as [noted
|
|
|
|
here](https://docs.docker.com/docker-for-mac/kubernetes/).
|
|
|
|
- [skaffold](https://github.com/GoogleContainerTools/skaffold/#installation)
|
|
|
|
|
|
|
|
1. Launch Docker for Desktop. Go to Preferences and choose “Enable Kubernetes”.
|
|
|
|
|
|
|
|
1. Run `kubectl get nodes` to verify you're connected to Kubernetes on Docker.
|
|
|
|
|
|
|
|
1. Run `skaffold run` (first time will be slow). This will build and deploy the
|
|
|
|
application. If you need to rebuild the images automatically as you refactor
|
|
|
|
the code, run `skaffold dev` command.
|
|
|
|
|
|
|
|
1. Run `kubectl get pods` to verify the Pods are ready and running. The
|
|
|
|
application frontend should be available at http://localhost:80 on your
|
|
|
|
machine.
|
|
|
|
|
|
|
|
### Setup on GKE
|
|
|
|
|
|
|
|
1. Install tools specified in the previous section (Docker, kubectl, skaffold)
|
2018-07-02 18:03:55 +00:00
|
|
|
|
|
|
|
1. Create a Google Kubernetes Engine cluster and make sure `kubectl` is pointing
|
|
|
|
to the cluster.
|
|
|
|
|
|
|
|
1. Enable Google Container Registry (GCR) on your GCP project:
|
2018-07-02 17:24:11 +00:00
|
|
|
|
|
|
|
gcloud services enable containerregistry.googleapis.com
|
2018-07-02 18:03:55 +00:00
|
|
|
|
|
|
|
1. Configure docker to authenticate to GCR:
|
|
|
|
|
|
|
|
gcloud auth configure-docker -q
|
2018-07-02 17:24:11 +00:00
|
|
|
|
|
|
|
1. Edit `skaffold.yaml`, prepend your GCR registry host (`gcr.io/YOUR_PROJECT/`)
|
2018-07-08 00:14:52 +00:00
|
|
|
to all `imageName:` fields (or update the existing project name).
|
2018-07-02 17:24:11 +00:00
|
|
|
|
2018-07-02 18:03:55 +00:00
|
|
|
1. Edit the Deployment manifests at `kubernetes-manifests` directory and update
|
2018-07-02 17:30:54 +00:00
|
|
|
the `image` fields to match the changes you made in the previous step.
|
2018-07-02 17:24:11 +00:00
|
|
|
|
2018-07-02 18:03:55 +00:00
|
|
|
1. Run `skaffold run`. This builds the container
|
2018-07-02 17:24:11 +00:00
|
|
|
images, pushes them to GFR, and deploys the application to Kubernetes.
|
|
|
|
|
2018-07-02 18:03:55 +00:00
|
|
|
1. Find the IP address of your application:
|
2018-07-02 17:24:11 +00:00
|
|
|
|
|
|
|
kubectl get service frontend-external
|
|
|
|
|
|
|
|
then visit the application on your browser to confirm
|
|
|
|
installation.
|
2018-07-08 00:14:52 +00:00
|
|
|
|
|
|
|
### Istio Deployment
|
|
|
|
|
|
|
|
1. Create a GKE cluster.
|
|
|
|
|
|
|
|
2. Install Istio **without mutual TLS** enablement.
|
|
|
|
|
|
|
|
3. Install the automatic sidecar injection (annotate the `default` namespace
|
|
|
|
with the label):
|
|
|
|
|
|
|
|
kubectl label namespace default istio-injection=enabled
|
|
|
|
|
|
|
|
4. Deploy the application.
|
|
|
|
|
|
|
|
5. Apply the manifests in [`./istio-manifests`](./istio-manifests) directory.
|
|
|
|
|
|
|
|
kubectl apply -f ./istio-manifests
|