diff --git a/kcl/lib/steps/kperf/run_benchmark.k b/kcl/lib/steps/kperf/run_benchmark.k index d98d854e04..ba28746057 100644 --- a/kcl/lib/steps/kperf/run_benchmark.k +++ b/kcl/lib/steps/kperf/run_benchmark.k @@ -49,7 +49,7 @@ done # RunKperfRunnerGroup runs `kperf rg run` with the specified runner image, runner # group manifest, optional flow control setting, and optional affinity selector. -RunKperfRunnerGroup = lambda runnerImage: str, runnerGroup: str, flowcontrol: str = "", affinity: str = "", target: str = Undefined -> steps.Step { +RunKperfRunnerGroup = lambda runnerImage: str, runnerGroup: str, flowcontrol: str = "", affinity: str = "", target: str = Undefined, displayName: str = "Run kperf runner group" -> steps.Step { steps.Script { script = """ set -euo pipefail @@ -94,7 +94,7 @@ until run_rg; do sleep 120 done """ - displayName = "Run kperf runner group" + displayName = displayName target = target } } diff --git a/kcl/workload_identity_webhook/pipeline.k b/kcl/workload_identity_webhook/pipeline.k new file mode 100644 index 0000000000..ec67f1df00 --- /dev/null +++ b/kcl/workload_identity_webhook/pipeline.k @@ -0,0 +1,179 @@ +import azure_pipelines.ap +import azure_pipelines.ap.jobs.job +import azure_pipelines.ap.steps +import lib.const +import lib.steps.azure +import lib.steps.common +import lib.steps.kperf +import lib.util.asi_dashboard + +SUBSCRIPTION_ID = "b8ceb4e5-f05b-4562-a9f5-14acb1f24219" +LOCATION = "australiaeast" +RUNNER_IMAGE = "ghcr.io/azure/kperf:0.3.7" +RATES = [100, 150, 200, 250] + +RunBenchmark = lambda rate: int -> [steps.Step] { + [ + steps.Bash { + bash = """ +set -euo pipefail +namespace="$(RUN_ID)-r${rate}" +kubectl create namespace "$namespace" --dry-run=client -o yaml | kubectl --request-timeout=60s apply -f - +kubectl create serviceaccount pod-benchmark --namespace "$namespace" --dry-run=client -o yaml | kubectl --request-timeout=60s apply -f - +# Use a fake client ID because benchmark Pods do not access Azure resources. +kubectl --request-timeout=60s annotate serviceaccount pod-benchmark \\ + --namespace "$namespace" \\ + "azure.workload.identity/client-id=00000000-0000-4000-8000-000000000001" \\ + --overwrite +""" + displayName = "Prepare WI resources for ${rate}/sec" + }, + steps.Bash { + bash = """ +set -euo pipefail +profile="$(Agent.TempDirectory)/$(RUN_ID)-r${rate}-runner-group.yaml" +sed \\ + -e 's/__RUN_NAMESPACE__/$(RUN_ID)-r${rate}/g' \\ + -e 's/__RATE__/${rate}/g' \\ + -e 's/__PHASE_RUN_ID__/$(RUN_ID)-r${rate}/g' \\ + "$(Build.SourcesDirectory)/kcl/workload_identity_webhook/runner-group.yaml" > "$profile" +if grep -q '__[A-Z_]*__' "$profile"; then + echo "Unresolved runner-group placeholders" >&2 + exit 1 +fi +""" + displayName = "Prepare ${rate}/sec runner group" + }, + kperf.RunKperfRunnerGroup( + RUNNER_IMAGE, + "file://$(Agent.TempDirectory)/$(RUN_ID)-r${rate}-runner-group.yaml", + affinity="agentpool=runner", + displayName="Run kperf runner group at ${rate} CREATEs/sec"), + kperf.FetchKperfRunnerGroupResult( + displayName="Wait for ${rate}/sec runner group result"), + steps.Bash { + bash = """ +set -euo pipefail +kubectl delete namespace "$(RUN_ID)-r${rate}" \\ + --ignore-not-found=true \\ + --wait=true +echo "Namespace cleanup completed for ${rate}/sec phase at $(date -u +%Y-%m-%dT%H:%M:%SZ)" +""" + displayName = "Delete namespace from ${rate}/sec run" + continueOnError = True + timeoutInMinutes = 15 + }, + steps.Bash { + bash = """ +set -euo pipefail +echo "Starting five-minute pause after ${rate}/sec phase at $(date -u +%Y-%m-%dT%H:%M:%SZ)" +sleep 300 +echo "Finished pause after ${rate}/sec phase at $(date -u +%Y-%m-%dT%H:%M:%SZ)" +""" + displayName = "Pause 5 minutes after kperf run" + timeoutInMinutes = 6 + }, + ] +} + +output = ap.Pipeline { + name = "Workload Identity Webhook Benchmark" + trigger = "none" + pr = "none" + pool = const.DEFAULT_POOL + parameters = [ + ap.Parameter { + name = "keep_cluster" + displayName = "Keep cluster after benchmark (phase namespaces are deleted)" + type = "boolean" + default = False + }, + ] + jobs = [ + job.Job { + job = "benchmark" + displayName = "Baseline Run: 100/150/200/250 RPS" + timeoutInMinutes = 240 + variables = { + RESOURCE_GROUP = "$(RUN_ID)" + CLUSTER = "wi-webhook" + } + steps = [ + common.SetRunId(), + azure.Login( + const.DEFAULT_SERVICE_CONNECTION, + SUBSCRIPTION_ID, + LOCATION), + azure.CreateResourceGroup( + const.DEFAULT_SERVICE_CONNECTION, + "$(RESOURCE_GROUP)", + LOCATION, + SUBSCRIPTION_ID), + azure.AzCli( + const.DEFAULT_SERVICE_CONNECTION, + "Create H2 cluster with OIDC and workload identity", + """ +az extension add \\ + --name aks-preview \\ + --version 21.0.0b17 \\ + --allow-preview true \\ + --yes +az aks create \\ + --subscription "${SUBSCRIPTION_ID}" \\ + --resource-group "$(RESOURCE_GROUP)" \\ + --name "$(CLUSTER)" \\ + --location "${LOCATION}" \\ + --kubernetes-version "1.36" \\ + --dns-name-prefix "$(RUN_ID)" \\ + --tier standard \\ + --control-plane-scaling-size H2 \\ + --enable-oidc-issuer \\ + --enable-workload-identity \\ + --generate-ssh-keys \\ + --nodepool-name systempool \\ + --node-count 3 \\ + --node-vm-size Standard_D4_v4 \\ + --max-pods 50 \\ + --network-plugin azure \\ + --network-plugin-mode overlay \\ + --pod-cidr 10.64.0.0/10 \\ + --service-cidr 10.0.0.0/16 \\ + --dns-service-ip 10.0.0.10 \\ + --outbound-type managedNATGateway \\ + --nat-gateway-managed-outbound-ip-count 10 \\ + --tags SkipAKSCluster=true \\ + --yes +"""), + azure.CreateNodePool( + const.DEFAULT_SERVICE_CONNECTION, + "$(CLUSTER)", + "$(RESOURCE_GROUP)", + SUBSCRIPTION_ID, + azure.NodePool { + name = "runner" + sku = "Standard_D4s_v5" + count = 1 + }), + azure.GetCredentials( + const.DEFAULT_SERVICE_CONNECTION, + "$(CLUSTER)", + "$(RESOURCE_GROUP)", + SUBSCRIPTION_ID), + kperf.InstallRunkperf(RUNNER_IMAGE), + common.RecordCurrentTime("BENCHMARK_START_TIME"), + *[step for rate in RATES for step in RunBenchmark(rate)], + asi_dashboard.PrintAsiDashboardUrl( + const.DEFAULT_SERVICE_CONNECTION, + "$(CLUSTER)", + "$(RESOURCE_GROUP)", + SUBSCRIPTION_ID, + startTime="$(BENCHMARK_START_TIME)"), + azure.DeleteResourceGroup( + const.DEFAULT_SERVICE_CONNECTION, + "$(RESOURCE_GROUP)", + SUBSCRIPTION_ID, + condition="and(always(), not(\${{ parameters.keep_cluster }}))"), + ] + }, + ] +} diff --git a/kcl/workload_identity_webhook/pipeline.yaml b/kcl/workload_identity_webhook/pipeline.yaml new file mode 100755 index 0000000000..d75aec1226 --- /dev/null +++ b/kcl/workload_identity_webhook/pipeline.yaml @@ -0,0 +1,570 @@ +name: Workload Identity Webhook Benchmark +pool: AKS-Telescope-Airlock +trigger: none +parameters: +- name: keep_cluster + displayName: Keep cluster after benchmark (phase namespaces are deleted) + type: boolean + default: false +pr: none +jobs: +- job: benchmark + displayName: 'Baseline Run: 100/150/200/250 RPS' + timeoutInMinutes: 240 + variables: + RESOURCE_GROUP: $(RUN_ID) + CLUSTER: wi-webhook + steps: + - bash: | + set -eo pipefail + + job_id="$(System.JobId)" + RUN_ID=$(Build.BuildId)-${job_id:0:8} + echo "Run ID: $RUN_ID" + + echo "##vso[task.setvariable variable=RUN_ID]$RUN_ID" + displayName: Set Run ID + - task: AzureCLI@2 + inputs: + azureSubscription: Azure-for-Telescope-internal + scriptType: bash + scriptLocation: inlineScript + inlineScript: | + set -exo pipefail + az account set --subscription "b8ceb4e5-f05b-4562-a9f5-14acb1f24219" + az config set defaults.location="australiaeast" + az account show + displayName: Login to Azure + - task: AzureCLI@2 + inputs: + azureSubscription: Azure-for-Telescope-internal + scriptType: bash + scriptLocation: inlineScript + inlineScript: |+ + set -exo pipefail + az group create \ + --name "$(RESOURCE_GROUP)" \ + --location "australiaeast" \ + --subscription "b8ceb4e5-f05b-4562-a9f5-14acb1f24219" \ + + displayName: Create resource group in australiaeast (b8ceb4e5-f05b-4562-a9f5-14acb1f24219) + - task: AzureCLI@2 + inputs: + azureSubscription: Azure-for-Telescope-internal + scriptType: bash + scriptLocation: inlineScript + inlineScript: | + set -exo pipefail + az extension add \ + --name aks-preview \ + --version 21.0.0b17 \ + --allow-preview true \ + --yes + az aks create \ + --subscription "b8ceb4e5-f05b-4562-a9f5-14acb1f24219" \ + --resource-group "$(RESOURCE_GROUP)" \ + --name "$(CLUSTER)" \ + --location "australiaeast" \ + --kubernetes-version "1.36" \ + --dns-name-prefix "$(RUN_ID)" \ + --tier standard \ + --control-plane-scaling-size H2 \ + --enable-oidc-issuer \ + --enable-workload-identity \ + --generate-ssh-keys \ + --nodepool-name systempool \ + --node-count 3 \ + --node-vm-size Standard_D4_v4 \ + --max-pods 50 \ + --network-plugin azure \ + --network-plugin-mode overlay \ + --pod-cidr 10.64.0.0/10 \ + --service-cidr 10.0.0.0/16 \ + --dns-service-ip 10.0.0.10 \ + --outbound-type managedNATGateway \ + --nat-gateway-managed-outbound-ip-count 10 \ + --tags SkipAKSCluster=true \ + --yes + displayName: Create H2 cluster with OIDC and workload identity + - task: AzureCLI@2 + inputs: + azureSubscription: Azure-for-Telescope-internal + scriptType: bash + scriptLocation: inlineScript + inlineScript: "set -exo pipefail\ncreate_node_pool() {\n local deadline sleep_between=30 attempt=0 output rc now remaining_retry_seconds\n deadline=$(($(date +%s) + 600))\n while :; do\n attempt=$((attempt + 1))\n if output=$(az aks nodepool add \"$@\" 2>&1); then\n rc=0\n else\n rc=$?\n fi\n echo \"$output\"\n if [ \"$rc\" -eq 0 ]; then\n return 0\n fi\n if echo \"$output\" | grep -qiE \"OperationNotAllowed\"; then\n now=$(date +%s)\n if [ \"$now\" -ge \"$deadline\" ]; then\n echo \"Retriable error persisted past 600s retry window ($attempt attempts); giving up.\"\n return \"$rc\"\n fi\n remaining_retry_seconds=$((deadline - now))\n echo \"Attempt $attempt matched retriable pattern; retrying in $sleep_between seconds ($remaining_retry_seconds seconds remain in retry window).\"\n sleep \"$sleep_between\"\n else\n echo \"Non-retriable error (rc=$rc); giving up after attempt $attempt.\"\n return \"$rc\"\n fi\n done\n}\n\n\ncreate_node_pool \\\n --cluster-name \"$(CLUSTER)\" \\\n --resource-group \"$(RESOURCE_GROUP)\" \\\n --subscription \"b8ceb4e5-f05b-4562-a9f5-14acb1f24219\" \\\n --name \"runner\" \\\n --node-count 1 \\\n --node-vm-size \"Standard_D4s_v5\" \\\n --mode User \\\n \n" + displayName: Create node pool runner + - task: AzureCLI@2 + inputs: + azureSubscription: Azure-for-Telescope-internal + scriptType: bash + scriptLocation: inlineScript + inlineScript: | + set -exo pipefail + az aks get-credentials \ + --name "$(CLUSTER)" \ + --resource-group "$(RESOURCE_GROUP)" \ + --subscription "b8ceb4e5-f05b-4562-a9f5-14acb1f24219" \ + --overwrite-existing + displayName: Get credentials for $(CLUSTER) + - script: | + set -euo pipefail + set -x + + temp_dir=$(mktemp -p /tmp -d kperfinstall.XXXX) + docker rmi ghcr.io/azure/kperf:0.3.7 2>/dev/null || true + docker pull ghcr.io/azure/kperf:0.3.7 + docker run --rm -v $temp_dir:/install-dir \ + ghcr.io/azure/kperf:0.3.7 bash -c "set -x; install /kperf /runkperf /install-dir" + + sudo install $temp_dir/kperf $temp_dir/runkperf /usr/local/bin + rm -rf $temp_dir + docker rmi ghcr.io/azure/kperf:0.3.7 2>/dev/null || true + displayName: Install runkperf binary + - bash: | + set -exo pipefail + TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%S.000Z") + echo "BENCHMARK_START_TIME: $TIMESTAMP" + echo "##vso[task.setvariable variable=BENCHMARK_START_TIME]$TIMESTAMP" + displayName: Record current time as BENCHMARK_START_TIME + - bash: | + set -euo pipefail + namespace="$(RUN_ID)-r100" + kubectl create namespace "$namespace" --dry-run=client -o yaml | kubectl --request-timeout=60s apply -f - + kubectl create serviceaccount pod-benchmark --namespace "$namespace" --dry-run=client -o yaml | kubectl --request-timeout=60s apply -f - + # Use a fake client ID because benchmark Pods do not access Azure resources. + kubectl --request-timeout=60s annotate serviceaccount pod-benchmark \ + --namespace "$namespace" \ + "azure.workload.identity/client-id=00000000-0000-4000-8000-000000000001" \ + --overwrite + displayName: Prepare WI resources for 100/sec + - bash: | + set -euo pipefail + profile="$(Agent.TempDirectory)/$(RUN_ID)-r100-runner-group.yaml" + sed \ + -e 's/__RUN_NAMESPACE__/$(RUN_ID)-r100/g' \ + -e 's/__RATE__/100/g' \ + -e 's/__PHASE_RUN_ID__/$(RUN_ID)-r100/g' \ + "$(Build.SourcesDirectory)/kcl/workload_identity_webhook/runner-group.yaml" > "$profile" + if grep -q '__[A-Z_]*__' "$profile"; then + echo "Unresolved runner-group placeholders" >&2 + exit 1 + fi + displayName: Prepare 100/sec runner group + - script: | + set -euo pipefail + set -x + + run_rg() { + args=( + rg run + --runner-image="ghcr.io/azure/kperf:0.3.7" + --runnergroup="file://$(Agent.TempDirectory)/$(RUN_ID)-r100-runner-group.yaml" + ) + if [ -n "" ]; then + args+=(--runner-flowcontrol="") + fi + if [ -n "agentpool=runner" ]; then + args+=(--affinity="agentpool=runner") + fi + kperf "${args[@]}" + } + + cleanup_rg() { + kperf rg delete || true + kubectl -n runnergroups-kperf-io delete pod runnergroup-server \ + --force --grace-period=0 --ignore-not-found=true --timeout=120s || true + } + + cleanup_rg + + attempt=0 + max_attempts=10 + until run_rg; do + attempt=$((attempt + 1)) + if [ "$attempt" -ge "$max_attempts" ]; then + echo "kperf rg run failed after $attempt attempts" >&2 + kubectl -n runnergroups-kperf-io get pods -o wide || true + kubectl -n runnergroups-kperf-io describe pod runnergroup-server || true + kubectl -n runnergroups-kperf-io get events --sort-by=.lastTimestamp | tail -50 || true + exit 1 + fi + cleanup_rg + echo "attempt $attempt failed; cleaning up and retrying in 120s" >&2 + sleep 120 + done + displayName: Run kperf runner group at 100 CREATEs/sec + - bash: | + set -euo pipefail + sleep 0 + attempt=0 + max_attempts=5 + until kperf rg result --wait; do + attempt=$((attempt + 1)) + if [ "$attempt" -ge "$max_attempts" ]; then + exit 1 + fi + echo "attempt $attempt failed; retry in 10s" >&2 + sleep 10 + done + continueOnError: true + displayName: Wait for 100/sec runner group result + timeoutInMinutes: 15 + - bash: | + set -euo pipefail + kubectl delete namespace "$(RUN_ID)-r100" \ + --ignore-not-found=true \ + --wait=true + echo "Namespace cleanup completed for 100/sec phase at $(date -u +%Y-%m-%dT%H:%M:%SZ)" + continueOnError: true + displayName: Delete namespace from 100/sec run + timeoutInMinutes: 15 + - bash: | + set -euo pipefail + echo "Starting five-minute pause after 100/sec phase at $(date -u +%Y-%m-%dT%H:%M:%SZ)" + sleep 300 + echo "Finished pause after 100/sec phase at $(date -u +%Y-%m-%dT%H:%M:%SZ)" + displayName: Pause 5 minutes after kperf run + timeoutInMinutes: 6 + - bash: | + set -euo pipefail + namespace="$(RUN_ID)-r150" + kubectl create namespace "$namespace" --dry-run=client -o yaml | kubectl --request-timeout=60s apply -f - + kubectl create serviceaccount pod-benchmark --namespace "$namespace" --dry-run=client -o yaml | kubectl --request-timeout=60s apply -f - + # Use a fake client ID because benchmark Pods do not access Azure resources. + kubectl --request-timeout=60s annotate serviceaccount pod-benchmark \ + --namespace "$namespace" \ + "azure.workload.identity/client-id=00000000-0000-4000-8000-000000000001" \ + --overwrite + displayName: Prepare WI resources for 150/sec + - bash: | + set -euo pipefail + profile="$(Agent.TempDirectory)/$(RUN_ID)-r150-runner-group.yaml" + sed \ + -e 's/__RUN_NAMESPACE__/$(RUN_ID)-r150/g' \ + -e 's/__RATE__/150/g' \ + -e 's/__PHASE_RUN_ID__/$(RUN_ID)-r150/g' \ + "$(Build.SourcesDirectory)/kcl/workload_identity_webhook/runner-group.yaml" > "$profile" + if grep -q '__[A-Z_]*__' "$profile"; then + echo "Unresolved runner-group placeholders" >&2 + exit 1 + fi + displayName: Prepare 150/sec runner group + - script: | + set -euo pipefail + set -x + + run_rg() { + args=( + rg run + --runner-image="ghcr.io/azure/kperf:0.3.7" + --runnergroup="file://$(Agent.TempDirectory)/$(RUN_ID)-r150-runner-group.yaml" + ) + if [ -n "" ]; then + args+=(--runner-flowcontrol="") + fi + if [ -n "agentpool=runner" ]; then + args+=(--affinity="agentpool=runner") + fi + kperf "${args[@]}" + } + + cleanup_rg() { + kperf rg delete || true + kubectl -n runnergroups-kperf-io delete pod runnergroup-server \ + --force --grace-period=0 --ignore-not-found=true --timeout=120s || true + } + + cleanup_rg + + attempt=0 + max_attempts=10 + until run_rg; do + attempt=$((attempt + 1)) + if [ "$attempt" -ge "$max_attempts" ]; then + echo "kperf rg run failed after $attempt attempts" >&2 + kubectl -n runnergroups-kperf-io get pods -o wide || true + kubectl -n runnergroups-kperf-io describe pod runnergroup-server || true + kubectl -n runnergroups-kperf-io get events --sort-by=.lastTimestamp | tail -50 || true + exit 1 + fi + cleanup_rg + echo "attempt $attempt failed; cleaning up and retrying in 120s" >&2 + sleep 120 + done + displayName: Run kperf runner group at 150 CREATEs/sec + - bash: | + set -euo pipefail + sleep 0 + attempt=0 + max_attempts=5 + until kperf rg result --wait; do + attempt=$((attempt + 1)) + if [ "$attempt" -ge "$max_attempts" ]; then + exit 1 + fi + echo "attempt $attempt failed; retry in 10s" >&2 + sleep 10 + done + continueOnError: true + displayName: Wait for 150/sec runner group result + timeoutInMinutes: 15 + - bash: | + set -euo pipefail + kubectl delete namespace "$(RUN_ID)-r150" \ + --ignore-not-found=true \ + --wait=true + echo "Namespace cleanup completed for 150/sec phase at $(date -u +%Y-%m-%dT%H:%M:%SZ)" + continueOnError: true + displayName: Delete namespace from 150/sec run + timeoutInMinutes: 15 + - bash: | + set -euo pipefail + echo "Starting five-minute pause after 150/sec phase at $(date -u +%Y-%m-%dT%H:%M:%SZ)" + sleep 300 + echo "Finished pause after 150/sec phase at $(date -u +%Y-%m-%dT%H:%M:%SZ)" + displayName: Pause 5 minutes after kperf run + timeoutInMinutes: 6 + - bash: | + set -euo pipefail + namespace="$(RUN_ID)-r200" + kubectl create namespace "$namespace" --dry-run=client -o yaml | kubectl --request-timeout=60s apply -f - + kubectl create serviceaccount pod-benchmark --namespace "$namespace" --dry-run=client -o yaml | kubectl --request-timeout=60s apply -f - + # Use a fake client ID because benchmark Pods do not access Azure resources. + kubectl --request-timeout=60s annotate serviceaccount pod-benchmark \ + --namespace "$namespace" \ + "azure.workload.identity/client-id=00000000-0000-4000-8000-000000000001" \ + --overwrite + displayName: Prepare WI resources for 200/sec + - bash: | + set -euo pipefail + profile="$(Agent.TempDirectory)/$(RUN_ID)-r200-runner-group.yaml" + sed \ + -e 's/__RUN_NAMESPACE__/$(RUN_ID)-r200/g' \ + -e 's/__RATE__/200/g' \ + -e 's/__PHASE_RUN_ID__/$(RUN_ID)-r200/g' \ + "$(Build.SourcesDirectory)/kcl/workload_identity_webhook/runner-group.yaml" > "$profile" + if grep -q '__[A-Z_]*__' "$profile"; then + echo "Unresolved runner-group placeholders" >&2 + exit 1 + fi + displayName: Prepare 200/sec runner group + - script: | + set -euo pipefail + set -x + + run_rg() { + args=( + rg run + --runner-image="ghcr.io/azure/kperf:0.3.7" + --runnergroup="file://$(Agent.TempDirectory)/$(RUN_ID)-r200-runner-group.yaml" + ) + if [ -n "" ]; then + args+=(--runner-flowcontrol="") + fi + if [ -n "agentpool=runner" ]; then + args+=(--affinity="agentpool=runner") + fi + kperf "${args[@]}" + } + + cleanup_rg() { + kperf rg delete || true + kubectl -n runnergroups-kperf-io delete pod runnergroup-server \ + --force --grace-period=0 --ignore-not-found=true --timeout=120s || true + } + + cleanup_rg + + attempt=0 + max_attempts=10 + until run_rg; do + attempt=$((attempt + 1)) + if [ "$attempt" -ge "$max_attempts" ]; then + echo "kperf rg run failed after $attempt attempts" >&2 + kubectl -n runnergroups-kperf-io get pods -o wide || true + kubectl -n runnergroups-kperf-io describe pod runnergroup-server || true + kubectl -n runnergroups-kperf-io get events --sort-by=.lastTimestamp | tail -50 || true + exit 1 + fi + cleanup_rg + echo "attempt $attempt failed; cleaning up and retrying in 120s" >&2 + sleep 120 + done + displayName: Run kperf runner group at 200 CREATEs/sec + - bash: | + set -euo pipefail + sleep 0 + attempt=0 + max_attempts=5 + until kperf rg result --wait; do + attempt=$((attempt + 1)) + if [ "$attempt" -ge "$max_attempts" ]; then + exit 1 + fi + echo "attempt $attempt failed; retry in 10s" >&2 + sleep 10 + done + continueOnError: true + displayName: Wait for 200/sec runner group result + timeoutInMinutes: 15 + - bash: | + set -euo pipefail + kubectl delete namespace "$(RUN_ID)-r200" \ + --ignore-not-found=true \ + --wait=true + echo "Namespace cleanup completed for 200/sec phase at $(date -u +%Y-%m-%dT%H:%M:%SZ)" + continueOnError: true + displayName: Delete namespace from 200/sec run + timeoutInMinutes: 15 + - bash: | + set -euo pipefail + echo "Starting five-minute pause after 200/sec phase at $(date -u +%Y-%m-%dT%H:%M:%SZ)" + sleep 300 + echo "Finished pause after 200/sec phase at $(date -u +%Y-%m-%dT%H:%M:%SZ)" + displayName: Pause 5 minutes after kperf run + timeoutInMinutes: 6 + - bash: | + set -euo pipefail + namespace="$(RUN_ID)-r250" + kubectl create namespace "$namespace" --dry-run=client -o yaml | kubectl --request-timeout=60s apply -f - + kubectl create serviceaccount pod-benchmark --namespace "$namespace" --dry-run=client -o yaml | kubectl --request-timeout=60s apply -f - + # Use a fake client ID because benchmark Pods do not access Azure resources. + kubectl --request-timeout=60s annotate serviceaccount pod-benchmark \ + --namespace "$namespace" \ + "azure.workload.identity/client-id=00000000-0000-4000-8000-000000000001" \ + --overwrite + displayName: Prepare WI resources for 250/sec + - bash: | + set -euo pipefail + profile="$(Agent.TempDirectory)/$(RUN_ID)-r250-runner-group.yaml" + sed \ + -e 's/__RUN_NAMESPACE__/$(RUN_ID)-r250/g' \ + -e 's/__RATE__/250/g' \ + -e 's/__PHASE_RUN_ID__/$(RUN_ID)-r250/g' \ + "$(Build.SourcesDirectory)/kcl/workload_identity_webhook/runner-group.yaml" > "$profile" + if grep -q '__[A-Z_]*__' "$profile"; then + echo "Unresolved runner-group placeholders" >&2 + exit 1 + fi + displayName: Prepare 250/sec runner group + - script: | + set -euo pipefail + set -x + + run_rg() { + args=( + rg run + --runner-image="ghcr.io/azure/kperf:0.3.7" + --runnergroup="file://$(Agent.TempDirectory)/$(RUN_ID)-r250-runner-group.yaml" + ) + if [ -n "" ]; then + args+=(--runner-flowcontrol="") + fi + if [ -n "agentpool=runner" ]; then + args+=(--affinity="agentpool=runner") + fi + kperf "${args[@]}" + } + + cleanup_rg() { + kperf rg delete || true + kubectl -n runnergroups-kperf-io delete pod runnergroup-server \ + --force --grace-period=0 --ignore-not-found=true --timeout=120s || true + } + + cleanup_rg + + attempt=0 + max_attempts=10 + until run_rg; do + attempt=$((attempt + 1)) + if [ "$attempt" -ge "$max_attempts" ]; then + echo "kperf rg run failed after $attempt attempts" >&2 + kubectl -n runnergroups-kperf-io get pods -o wide || true + kubectl -n runnergroups-kperf-io describe pod runnergroup-server || true + kubectl -n runnergroups-kperf-io get events --sort-by=.lastTimestamp | tail -50 || true + exit 1 + fi + cleanup_rg + echo "attempt $attempt failed; cleaning up and retrying in 120s" >&2 + sleep 120 + done + displayName: Run kperf runner group at 250 CREATEs/sec + - bash: | + set -euo pipefail + sleep 0 + attempt=0 + max_attempts=5 + until kperf rg result --wait; do + attempt=$((attempt + 1)) + if [ "$attempt" -ge "$max_attempts" ]; then + exit 1 + fi + echo "attempt $attempt failed; retry in 10s" >&2 + sleep 10 + done + continueOnError: true + displayName: Wait for 250/sec runner group result + timeoutInMinutes: 15 + - bash: | + set -euo pipefail + kubectl delete namespace "$(RUN_ID)-r250" \ + --ignore-not-found=true \ + --wait=true + echo "Namespace cleanup completed for 250/sec phase at $(date -u +%Y-%m-%dT%H:%M:%SZ)" + continueOnError: true + displayName: Delete namespace from 250/sec run + timeoutInMinutes: 15 + - bash: | + set -euo pipefail + echo "Starting five-minute pause after 250/sec phase at $(date -u +%Y-%m-%dT%H:%M:%SZ)" + sleep 300 + echo "Finished pause after 250/sec phase at $(date -u +%Y-%m-%dT%H:%M:%SZ)" + displayName: Pause 5 minutes after kperf run + timeoutInMinutes: 6 + - task: AzureCLI@2 + inputs: + azureSubscription: Azure-for-Telescope-internal + scriptType: bash + scriptLocation: inlineScript + inlineScript: | + set -exo pipefail + RESOURCE_UID=$(az aks show \ + --resource-group "$(RESOURCE_GROUP)" \ + --name "$(CLUSTER)" \ + --subscription "b8ceb4e5-f05b-4562-a9f5-14acb1f24219" \ + --query "resourceUid" -o tsv) + + if [ -z "$RESOURCE_UID" ]; then + echo "##[warning]Failed to fetch resourceUid, skipping ASI URL" + exit 1 + fi + + END_TIME="" + if [ -z "$END_TIME" ]; then + END_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S.000Z") + fi + + FROM_ENCODED=$(echo "$(BENCHMARK_START_TIME)" | sed 's/:/%3A/g') + TO_ENCODED=$(echo "$END_TIME" | sed 's/:/%3A/g') + + echo "============================================" + echo "ASI Managed Cluster Dashboard URL:" + echo "https://asi.azure.ms/services/AKS/pages/Managed%20Cluster?clusterVersion=$RESOURCE_UID&globalFrom=$FROM_ENCODED&globalTo=$TO_ENCODED" + echo "" + echo "ASI API Server Analyzer URL:" + echo "https://asi.azure.ms/services/AKS/pages/API%20Server%20Analyzer?clusterVersion=$RESOURCE_UID&globalFrom=$FROM_ENCODED&globalTo=$TO_ENCODED" + echo "============================================" + condition: always() + continueOnError: true + displayName: Print ASI dashboard URL + - task: AzureCLI@2 + inputs: + azureSubscription: Azure-for-Telescope-internal + scriptType: bash + scriptLocation: inlineScript + inlineScript: | + set -exo pipefail + az group delete --name "$(RESOURCE_GROUP)" --subscription "b8ceb4e5-f05b-4562-a9f5-14acb1f24219" --yes + condition: and(always(), not(${{ parameters.keep_cluster }})) + displayName: Delete resource group (b8ceb4e5-f05b-4562-a9f5-14acb1f24219) diff --git a/kcl/workload_identity_webhook/runner-group.yaml b/kcl/workload_identity_webhook/runner-group.yaml new file mode 100644 index 0000000000..98cd6b31ae --- /dev/null +++ b/kcl/workload_identity_webhook/runner-group.yaml @@ -0,0 +1,29 @@ +# One runner keeps the profile rate equal to the phase's aggregate target. +count: 1 +loadProfile: + version: 1 + description: WI Pod CREATE exploratory benchmark - __RATE__ creates/sec for 10 minutes + specs: + - rate: __RATE__ + duration: 600 + total: 0 + client: 600 + conns: 20 + contentType: json + maxRetries: 0 + requests: + - shares: 1 + postDel: + group: "" + version: v1 + resource: pods + namespace: "__RUN_NAMESPACE__" + deleteRatio: 0 + pod: + labels: + azure.workload.identity/use: "true" + benchmark-run: "__PHASE_RUN_ID__" + serviceAccountName: pod-benchmark + # No scheduler handles this name: Pods undergo admission but remain + # unscheduled, excluding node placement and container startup work. + schedulerName: kperf-admission-only