Skip to content

Instantly share code, notes, and snippets.

@nordineb
Last active January 26, 2023 10:28
Show Gist options
  • Save nordineb/5b172f9efb15a5cefe06d4dcf227e50a to your computer and use it in GitHub Desktop.
Save nordineb/5b172f9efb15a5cefe06d4dcf227e50a to your computer and use it in GitHub Desktop.
Istio on a local k3d cluster

Istio on a local k3d cluster

Sometimes it's more practical to have a local cluster for testing Istio stuff.

Guide

Install k3d. Tested on k3d 5.4.4, but it should work on the latest too:

curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | TAG=v5.4.4 bash

Add the following entries to /etc/hosts. Alternatively, configure your machine to resolve *.localhost to 127.0.0.1

127.0.0.1 k3d-registry.localhost

Creating a container registry and a k3d cluster

k3d registry create registry.localhost --port 50000

CLUSTERNAME="mycluster"

k3d cluster create $CLUSTERNAME \
  --registry-use k3d-registry.localhost:50000 \
  --servers 1 \
  --agents 1 \
  --port 9080:80@loadbalancer \
  --port 9443:443@loadbalancer \
  --api-port 6443 \
  --k3s-arg --disable=traefik@server:0 \
  --verbose

Install Istio

kubectl config use-context k3d-$CLUSTERNAME

kubectl create ns istio-system
 
istioctl install --set profile=demo --set meshConfig.enableTracing=true  -y
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.10/samples/addons/prometheus.yaml
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.10/samples/addons/grafana.yaml
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.10/samples/addons/kiali.yaml
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.10/samples/addons/jaeger.yaml
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.10/samples/addons/extras/zipkin.yaml

If you are using a Mac M1 laptop (ARM64), you need to use an unofficial fix with m1-istio-config.yaml from devtools-repo. Might not be necessary in the future.

istioctl operator init --hub=ghcr.io/resf/istio
istioctl install -f m1-istio-config.yaml

Make sure istiod, istio-ingressgateway and istio-egressgateway are created in namespace istio-system. If you are facing issues - try changing istioctl version to 1.14.1. See https://stackoverflow.com/questions/72073613/istio-installation-failed-apple-silicon-m1 for more information on M1.

Enable istio-injection

kubectl label <namespace> default istio-injection=enabled

How Push an docker image to the local registry

docker build . -t xxxx:latest
docker tag xxxx:latest k3d-registry.localhost:50000/xxxx:latest
docker push k3d-registry.localhost:50000/xxxx:latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment