Skip to content

Instantly share code, notes, and snippets.

@bleggett
Created March 10, 2025 15:13
Show Gist options
  • Save bleggett/abb8692ea4a52dbdc2abab9267961f9b to your computer and use it in GitHub Desktop.
Save bleggett/abb8692ea4a52dbdc2abab9267961f9b to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
# Copyright Istio Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
unset LOCAL_ISTIO_IMGS DOCKER_SOCKET_MOUNT BUILD_ZTUNNEL BUILD_ZTUNNEL_REPO ISTIO_ZTUNNEL_BASE_URL ISTIO_ENVOY_BASE_URL
BUILDSHA=$(git rev-parse --short=10 HEAD)
ARCH=arm64
export BUILD_ZTUNNEL=1
if [ "$BUILD_WITH_CONTAINER" = 1 ]; then
echo "Building inside container, using ztunnel bind mounts"
export BUILD_ZTUNNEL_REPO="./ztunnel"
else
echo "Building outside container, using ztunnel path"
export BUILD_ZTUNNEL_REPO="./ztunnel"
fi
export TAG="ben-local-14-$ARCH-$BUILDSHA" # make sure to set .values.global.variant=""
export HUB=gcr.io/oss/bleggett
export LOCALHUB=localhost:5000
export DOCKER_ARCHITECTURES="linux/$ARCH"
export TARGET_ARCH=$ARCH
export LOCAL_ISTIO_IMGS="pilot,ztunnel,istioctl,install-cni,proxyv2,app,app_sidecar_ubuntu_noble,ext-authz"
export INTEGRATION_TEST_FLAGS='--istio.test.nocleanup --istio.test.ambient --log_output_level=all:debug --istio.test.kube.helm.values="global.logging.level=all:debug" -v'
export CONDITIONAL_HOST_MOUNTS=" --mount type=bind,source=/home/bleggett/Source/istio/ztunnel,destination=/work/ztunnel --mount type=bind,source=$SSH_AUTH_SOCK,destination=$SSH_AUTH_SOCK"
alias istiofastbuild='make gen && tools/docker --targets=$LOCAL_ISTIO_IMGS --hub=$HUB --tag=$TAG --push --builder=crane'
alias prowk8s="IP_FAMILY=dual ./prow/integ-suite-kind.sh --skip-build --skip-cleanup --kind-config prow/config/ambient-sc.yaml && copy_images_local"
copy_images_local() {
IFS=","
# shellcheck disable=SC2043
for i in $=LOCAL_ISTIO_IMGS; do
INT_COPYREMOTE="${HUB}/${i}:${TAG}"
INT_COPYLOCAL="localhost:5000/${i}:${TAG}"
docker pull "${INT_COPYREMOTE}"
docker tag "${INT_COPYREMOTE}" "${INT_COPYLOCAL}"
docker push "${INT_COPYLOCAL}"
done
}
scale_down_cluster() {
COUNT=$1
kubectl get nodes --field-selector metadata.name!=istio-testing-control-plane --no-headers | awk -F ' ' '{print $1}' | head -n "$COUNT" | xargs -l1 -- sh -c "kubectl delete node $1 && docker stop $1 && docker container rm $1" --
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment