Setup
Begin by cloning a local copy of the Spring PetClinic Istio repository from GitHub.
Kubernetes¶
Select whether you wish to provision Kubernetes locally or remotely using a cloud provider.
On a Mac running Docker Desktop or Rancher Desktop, make sure to give your VM plenty of CPU and memory. 16GB of memory and 6 CPUs seems to work for me.
Deploy a local K3D Kubernetes cluster with a local registry:
k3d cluster create my-istio-cluster \
--api-port 6443 \
--k3s-arg "--disable=traefik@server:0" \
--port 80:80@loadbalancer \
--registry-create my-cluster-registry:0.0.0.0:5010
Above, we:
- Disable the default traefik load balancer and configure local port 80 to instead forward to the "istio-ingressgateway" load balancer.
- Create a registry we can push to locally on port 5010 that is accessible from the Kubernetes cluster at "my-cluster-registry:5000".
Environment variables¶
Use envrc-template.sh
as the basis for configuring environment variables.
Be sure to:
- Set the local variable
local_setup
to either "true" or "false", depending on your choice of a local or remote cluster. - If using a remote setup, set the value of PUSH_IMAGE_REGISTRY to the value of your image registry URL.
I highly recommend using direnv
, a convenient way of associating setting environment variables with a specific directory.
If you choose to use direnv
, then the variables can be automatically set by renaming the file to .envrc
and running the command direnv allow
.
Istio¶
-
Follow the Istio documentation's instructions to download Istio.
-
After you have added the
istioctl
CLI to your PATH, run the following command to install Istio:
The above-referenced configuration manifest configures certain facets of the mesh, namely:
- Setting trace sampling at 100%, for ease of obtaining distributed traces
- Deploying sidecars (envoy proxies) not only alongside workloads, but also in front of mysql databases.
istio-install-manifest.yaml
- Turns on sidecar access logging to stdout
- Sets trace sampling to 100% to easily expose see distributed traces (for testing)
- Enables mysql filter, see protocol selection and env vars
Once Istio is installed, feel free to verify the installation with:
In the next section, you will work on deploying the microservices to the default
namespace.
As a final step, label the default
namespace for sidecar injection with: