Skip to content

Instantly share code, notes, and snippets.

@rafi
Last active August 16, 2023 11:29
Show Gist options
  • Save rafi/ebc50f0b0cd12dc061e4c69b3ee2521c to your computer and use it in GitHub Desktop.
Save rafi/ebc50f0b0cd12dc061e4c69b3ee2521c to your computer and use it in GitHub Desktop.
K3d and Istio (Service Mesh - Governing the data plane)

K3d and Istio

Prerequisites

Ensure docker, k3d and istioctl installed.

brew update
brew install --cask docker
brew install k3d istioctl

Versions in use:

$ docker version
Client:
 Cloud integration: 1.0.14
 Version:           20.10.6

Server: Docker Engine - Community
 Engine:
  Version:          20.10.6
  API version:      1.41 (minimum version 1.12)

$ k3d version
k3d version v4.4.4

$ istioctl version
client version: 1.10.0
control plane version: 1.10.0
data plane version: 1.10.0 (8 proxies)

Deploy Multi-Node Cluster

k3d cluster create bob --servers 1 --agents 3 \
  --port 9443:443@loadbalancer \
  --port 80:80@loadbalancer \
  --port '32036:32036@server[0]' \
  --api-port 6443 --k3s-server-arg '--no-deploy=traefik'

Probe New Cluster

docker ps --format 'table {{.ID}}\t{{.Image}}\t{{.Names}}\t{{.Ports}}'
kubectl get nodes
kubectl get ns
kubectl get pods -A
kubectl get services -A

Install Istio

Istio install profiles.

Inspect profiles:

istioctl profile list # Will list available profiles
istioctl profile dump default # Will dump the default profile config
istioctl profile dump demo

Install demo profile:

istioctl install --set profile=demo -y

To enable the automatic injection of Envoy sidecar proxies, run the following: (Otherwise you will need to do this manually when you deploy your applications)

kubectl label namespace default istio-injection=enabled

Deploy Demo Distributed System

Download and extract samples:

ISTIO_VERSION=1.10.0
ISTIO_URL=https://github.com/istio/istio/releases/download/$ISTIO_VERSION/istio-$ISTIO_VERSION-linux-amd64.tar.gz
curl -L $ISTIO_URL | tar xz
cd istio-$ISTIO_VERSION
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
kubectl get services
kubectl get pods

Verify Demo System

kubectl exec "$(kubectl get pod -l app=ratings \
  -o jsonpath='{.items[0].metadata.name}')" -c ratings \
  -- curl -sS productpage:9080/productpage | grep -o "<title>.*</title>"

Open Outside Traffic

kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
istioctl analyze

Open in browser:

open http://localhost/productpage

Install Tracing Utilities

kubectl apply -f samples/addons
kubectl rollout status deployment/kiali -n istio-system

If there are errors trying to install the addons, try running the command again. There may be some timing issues which will be resolved when the command is run again.

Access the Kiali dashboard

istioctl dashboard kiali

for i in $(seq 1 100); do curl -so /dev/null http://localhost/productpage; done

Uninstall and Cleanup

Uninstall Istio:

kubectl delete -f samples/addons
kubectl delete -f samples/bookinfo/networking/bookinfo-gateway.yaml
kubectl delete -f samples/bookinfo/platform/kube/bookinfo.yaml
istioctl x uninstall --purge
kubectl delete namespace istio-system
kubectl label namespace default istio-injection-

Delete k3d/k3s cluster:

k3d cluster delete bob
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment