From 66e73f3aea5c1982f364a0cfb6cfbb993b124926 Mon Sep 17 00:00:00 2001
From: Danny Gershman <danny@radiusmethod.com>
Date: Tue, 4 Apr 2023 14:57:12 +0000
Subject: [PATCH] Override k8s version for k3d

---
 docs/assets/scripts/developer/k3d-dev.sh |  6 ++++++
 docs/developer/aws-k3d-script.md         | 16 +++++++++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/docs/assets/scripts/developer/k3d-dev.sh b/docs/assets/scripts/developer/k3d-dev.sh
index 42dc7345b0..54860999bb 100755
--- a/docs/assets/scripts/developer/k3d-dev.sh
+++ b/docs/assets/scripts/developer/k3d-dev.sh
@@ -434,6 +434,12 @@ k3d_command+=" --k3s-arg \"--disable=traefik@server:0\"  --k3s-arg \"--disable=m
 # Port mappings to support Istio ingress + API access
 k3d_command+=" --port 80:80@loadbalancer --port 443:443@loadbalancer --api-port 6443"
 
+K3S_IMAGE_TAG=${K3S_IMAGE_TAG:=""}
+if [[ ! -z "$K3S_IMAGE_TAG" ]]; then
+  echo "Using custom K3S image tag $K3S_IMAGE_TAG..."
+  k3d_command+=" --image docker.io/rancher/k3s:$K3S_IMAGE_TAG"
+fi
+
 # Add MetalLB specific k3d config
 if [[ "$METAL_LB" == true ]]; then
   # create docker network for k3d cluster
diff --git a/docs/developer/aws-k3d-script.md b/docs/developer/aws-k3d-script.md
index 104d564114..b5034023f3 100644
--- a/docs/developer/aws-k3d-script.md
+++ b/docs/developer/aws-k3d-script.md
@@ -58,18 +58,28 @@ k3d-dev.sh -b -p -m -d -h
 The script uses the default AWS profile and defaults the VPC id and AMI id. 
 To change this default behavior you can export environment variables before running the script.  
 
-Run the script with a specific AWS profile by first exporting the AWS_PROFILE environment variable
+Run the script with a specific AWS profile by first exporting the AWS_PROFILE environment variable:
 ```shell
 export AWS_PROFILE=my-aws-profile
 ```
-To run the script with a specific VPC
+To run the script with a specific VPC:
 ```shell
 export VPC_ID=vpc-XXXXXXXXXXXX
 ```
-To run the script with a specific AMI
+To run the script with a specific AMI:
 ```shell
 export AMI_ID=ami-XXXXXXXXXX
 ```
+To specify a specific Kubernetes version (the eligible choices are [here](https://hub.docker.com/r/rancher/k3s/tags)):
+```shell
+export K3S_IMAGE_TAG=sometag
+```
+
+You can also run these inline with the script, without exporting them to your environment.  Example:
+
+```shell
+K3S_IMAGE_TAG=v1.24.12-k3s1 ./docs/assets/scripts/developer/k3d-dev.sh
+```
 
 ## After Running The Script
 
-- 
GitLab