#!/bin/bash # Demo: create N Managed proxies backed by the kubernetes-pod provider, # named proxy-kubernetes-demo-1 .. proxy-kubernetes-demo-N. Pods share the # cluster's egress IP — this exercises the full lifecycle, not distinct # egress paths (use create-gcp-proxies.sh for that). # # Usage: # ./create-kubernetes-proxies.sh # # Optional environment: # NAMESPACE namespace to create the proxies in (default: current context) set -euo pipefail if [ $# -ne 1 ] || ! [[ "$1" =~ ^[1-9][0-9]*$ ]]; then echo "usage: $(basename "$0") (positive integer)" >&2 exit 1 fi count="$1" if ! command -v kubectl &> /dev/null; then echo "ERROR: kubectl is required but not installed" >&2 exit 1 fi ns_args=() if [ -n "${NAMESPACE:-}" ]; then ns_args=(-n "${NAMESPACE}") fi for i in $(seq 1 "${count}"); do echo "Creating proxy-kubernetes-demo-${i} ..." kubectl apply "${ns_args[@]}" -f - << EOF apiVersion: crawl.example.com/v1alpha1 kind: Proxy metadata: name: proxy-kubernetes-demo-${i} spec: mode: Managed provider: kubernetes attributes: geo: local purpose: crawl EOF done echo "" echo "Created ${count} proxies. Watch them come up with:" echo " kubectl get px ${ns_args[*]:-} -w"