Dapatkan jawaban atas pertanyaan yang sering diajukan tentang integrasi pemantauan dan penyimpanan profil untuk pembuatan profil GPU di Azure Kubernetes Service (AKS). Sebelum memulai, siapkan pembuatan profil GPU.
Pemantauan integrasi
Bagaimana cara menghubungkan instans Prometheus saya sendiri ke Inspektor Gadget?
Jika Anda menjalankan instans Prometheus sendiri alih-alih layanan terkelola Azure Monitor untuk Prometheus, konfigurasikan instans tersebut untuk mengumpulkan metrik dari pod Inspektor Gadget.
Inspektor Gadget mengekspos metriknya di titik akhir berikut:
| Setting | Nilai |
|---|---|
| Namespace | gadget |
| Pelabuhan | 2224 |
| Path | /metrics |
Tambahkan job scrape ke konfigurasi Prometheus Anda untuk menemukan pod dan mengambil metriknya:
Tip
Untuk penyebaran Operator Prometheus, buat PodMonitor dengan namespace, pemilih label, port, dan jalur metrik yang setara.
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__
Verifikasi koneksi di UI Prometheus Anda di bawahTargetStatus>. Tugas inspektor-gadget harus menampilkan target sebagai UP.
Bagaimana cara memvisualisasikan metrik Inspektor Gadget dalam instans Grafana saya sendiri?
Pastikan instans Prometheus Anda terhubung ke Grafana sebagai sumber data. Kemudian, impor dasbor Inspektor Gadget dari definisi JSON berikut:
Penyimpanan profil
Bagaimana cara menggunakan Azure Blob Storage sebagai backend Pyroscope?
Secara bawaan, deploymen Pyroscope di artikel penyiapan pembuatan profil GPU menyimpan profil di sistem berkas lokal. Data profil akan hilang jika pod dibuat ulang. Untuk mempertahankan profil, konfigurasikan Pyroscope untuk menggunakan Azure Blob Storage dengan Microsoft Entra Workload ID.
Ekspor variabel yang diperlukan:
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"
Membuat akun penyimpanan dan kontainer
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
Membuat identitas terkelola dan memberikan akses ke akun penyimpanan
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
Mengaktifkan identitas beban kerja dan membuat kredensial federasi
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
Nama akun layanan dalam subjek kredensial federasi harus cocok dengan nama akun layanan yang digunakan oleh rilis Helm Pyroscope. Jika tidak, Pyroscope tidak dapat mengautentikasi ke Azure Blob Storage.
Menyebarkan Pyroscope dengan backend Azure Blob Storage
Alih-alih perintah Helm di Aktifkan visualisasi profil dengan Pyroscope, jalankan perintah berikut. Konfigurasi ini menggunakan Azure Blob Storage, membuat akun layanan, dan mengaktifkan identitas beban kerja pada 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
Verifikasi bahwa pod sedang berjalan:
kubectl get pods -n gadget pyroscope-0
Lanjutkan dengan Sambungkan Pyroscope ke Azure Managed Grafana.
Nota
Kunci nilai Helm dapat berubah antar versi chart. Untuk mengonfirmasi kunci yang tersedia untuk versi Anda, jalankan helm show values oci://ghcr.io/grafana/helm-charts/pyroscope --version 1.15.0.