Domande frequenti sulla profilatura GPU per Servizio Azure Kubernetes (AKS) (anteprima)

Risposte alle domande frequenti sul monitoraggio delle integrazioni e dell'archiviazione dei profili per la profilatura GPU in Servizio Azure Kubernetes (AKS). Prima di iniziare, configurare la profilatura GPU.

Monitoraggio delle integrazioni

Come collego la mia istanza di Prometheus a Inspektor Gadget?

Se si utilizza una propria istanza di Prometheus anziché il servizio gestito di Monitoraggio di Azure per Prometheus, configurarla in modo che raccolga le metriche dai pod di Inspektor Gadget.

Inspektor Gadget espone le metriche al seguente endpoint:

Setting Value
Namespace gadget
Porto 2224
Percorso /metrics

Aggiungere un processo di scraping alla configurazione di Prometheus per individuare i pod ed eseguirne lo scraping:

Tip

Per le distribuzioni con Prometheus Operator, creare un oggetto PodMonitor con namespace, selettore di etichette, porta e percorso delle metriche equivalenti.

scrape_configs:
  - job_name: "inspektor-gadget"
    kubernetes_sd_configs:
      - role: pod
        namespaces:
          names:
            - gadget
    relabel_configs:
      # Only keep pods with the k8s-app=gadget label.
      - source_labels: [__meta_kubernetes_pod_label_k8s_app]
        action: keep
        regex: gadget

      # Set the metrics path.
      - target_label: __metrics_path__
        replacement: /metrics

      # Set the metrics port.
      - source_labels: [__address__]
        action: replace
        regex: ([^:]+)(?::\d+)?
        replacement: $1:2224
        target_label: __address__

Verificare la connessione nell'interfaccia utente di Prometheus in Stato>. Il processo inspektor-gadget deve mostrare la propria destinazione come UP.

Come si visualizzano le metriche di Inspektor Gadget nell'istanza di Grafana?

Assicurarsi che l'istanza di Prometheus sia collegata a Grafana come origine dati. Quindi, importa la dashboard Inspektor Gadget dalla seguente definizione JSON:

https://raw.githubusercontent.com/inspektor-gadget/grafana-dashboards/refs/heads/main/dashboards/gpu-observability/AdvancedGPUObservability.json

Archiviazione dei profili

Come si utilizza Archiviazione BLOB di Azure come backend di Pyroscope?

Per impostazione predefinita, la distribuzione di Pyroscope nell'articolo di configurazione della profilatura GPU archivia i profili nel file system locale. I dati di profilatura vengono persi se il pod viene ricreato. Per rendere persistenti i profili, configurare Pyroscope per l'uso di Archiviazione BLOB di Azure con ID dei carichi di lavoro di Microsoft Entra.

Esportare le variabili necessarie:

export RESOURCE_GROUP="<your-resource-group>"
export AKS_CLUSTER="<your-aks-cluster-name>"
export LOCATION="<your-aks-cluster-location>"
export BLOB_STORAGE_NAME="<your-storage-account-name>"

export BLOB_STORAGE_CONTAINER="pyroscope-blob-storage"
export PYROSCOPE_IDENTITY="pyroscope-id"
export PYROSCOPE_SERVICE_ACCOUNT="pyroscope-sa"
export PYROSCOPE_FEDERATED_CREDS="pyroscope-federated-creds"

Creare l'account di archiviazione e il contenitore

az storage account create \
  --name "$BLOB_STORAGE_NAME" \
  --resource-group "$RESOURCE_GROUP" \
  --location "$LOCATION" \
  --sku Standard_ZRS \
  --kind StorageV2 \
  --min-tls-version TLS1_2 \
  --allow-blob-public-access false \
  --output none

az storage container create \
  --name "$BLOB_STORAGE_CONTAINER" \
  --account-name "$BLOB_STORAGE_NAME" \
  --auth-mode login \
  --output none

Creare un'identità gestita e concedere l'accesso all'account di archiviazione

az identity create \
  --name "$PYROSCOPE_IDENTITY" \
  --resource-group "$RESOURCE_GROUP" \
  --location "$LOCATION" \
  --output none

IDENTITY_CLIENT_ID=$(az identity show \
  --name "$PYROSCOPE_IDENTITY" \
  --resource-group "$RESOURCE_GROUP" \
  --query 'clientId' \
  --output tsv)

SUBSCRIPTION_ID=$(az account show --query id --output tsv)

# Restrict the role assignment scope to the storage account.
STORAGE_SCOPE="/subscriptions/${SUBSCRIPTION_ID}/resourceGroups/${RESOURCE_GROUP}/providers/Microsoft.Storage/storageAccounts/${BLOB_STORAGE_NAME}"

az role assignment create \
  --assignee "$IDENTITY_CLIENT_ID" \
  --role "Storage Blob Data Contributor" \
  --scope "$STORAGE_SCOPE" \
  --output none

Abilitare l'identità del carico di lavoro e creare credenziali federate

az aks update \
  --name "$AKS_CLUSTER" \
  --resource-group "$RESOURCE_GROUP" \
  --enable-oidc-issuer \
  --enable-workload-identity \
  --output none

OIDC_ISSUER=$(az aks show \
  --name "$AKS_CLUSTER" \
  --resource-group "$RESOURCE_GROUP" \
  --query 'oidcIssuerProfile.issuerUrl' \
  --output tsv)

az identity federated-credential create \
  --name "$PYROSCOPE_FEDERATED_CREDS" \
  --identity-name "$PYROSCOPE_IDENTITY" \
  --resource-group "$RESOURCE_GROUP" \
  --issuer "$OIDC_ISSUER" \
  --subject "system:serviceaccount:gadget:${PYROSCOPE_SERVICE_ACCOUNT}" \
  --audiences "api://AzureADTokenExchange" \
  --output none

Important

Il nome dell'account di servizio nel soggetto credenziale federata deve corrispondere al nome dell'account di servizio utilizzato dalla release Helm di Pyroscope. In caso contrario, Il Piroscopio non può eseguire l'autenticazione per Archiviazione BLOB di Azure.

Distribuire Pyroscope con il back-end di Archiviazione BLOB di Azure

Invece del comando Helm in Abilitare la visualizzazione del profilo con Pyroscope, eseguire il comando seguente. Questa configurazione usa Archiviazione BLOB di Azure, crea l'account del servizio e abilita l'identità del carico di lavoro nel pod Pyroscope.

helm install pyroscope -n gadget \
  oci://ghcr.io/grafana/helm-charts/pyroscope \
  --version 1.15.0 \
  --set pyroscope.image.repository=grafana/pyroscope \
  --set-string pyroscope.image.tag=1.15.0 \
  --set pyroscope.replicaCount=1 \
  --set pyroscope.structuredConfig.self_profiling.disable_push=true \
  --set pyroscope.structuredConfig.storage.backend=azure \
  --set-string pyroscope.structuredConfig.storage.azure.account_name="$BLOB_STORAGE_NAME" \
  --set-string pyroscope.structuredConfig.storage.azure.container_name="$BLOB_STORAGE_CONTAINER" \
  --set pyroscope.serviceAccount.create=true \
  --set-string pyroscope.serviceAccount.name="$PYROSCOPE_SERVICE_ACCOUNT" \
  --set-string pyroscope.serviceAccount.annotations."azure\.workload\.identity/client-id"="$IDENTITY_CLIENT_ID" \
  --set-string pyroscope.podLabels."azure\.workload\.identity/use"=true \
  --set pyroscope.service.type=LoadBalancer \
  --set pyroscope.service.port=4040 \
  --set-string pyroscope.service.annotations."service\.beta\.kubernetes\.io/azure-load-balancer-internal"=true \
  --set-string pyroscope.service.annotations."service\.beta\.kubernetes\.io/azure-pls-create"=true \
  --set-string pyroscope.service.annotations."service\.beta\.kubernetes\.io/azure-pls-name"=pyroscope-pls \
  --set-string pyroscope.service.annotations."service\.beta\.kubernetes\.io/azure-pls-proxy-protocol"=false \
  --set-string pyroscope.service.annotations."service\.beta\.kubernetes\.io/azure-pls-visibility"='*' \
  --set alloy.enabled=false \
  --set minio.enabled=false

Verificare che il pod sia in esecuzione:

kubectl get pods -n gadget pyroscope-0

Continua con Connect Pyroscope to Grafana con gestione Azure.

Annotazioni

Le chiavi dei valori di Helm possono cambiare tra le versioni del chart. Per confermare le chiavi disponibili per la versione, eseguire helm show values oci://ghcr.io/grafana/helm-charts/pyroscope --version 1.15.0.