容器见解资源管理器模板示例

本文包括 Azure 资源管理器模板示例,用于在 Azure Monitor 中部署和配置虚拟机的 Log Analytics 代理。 每个示例都包含模板文件和参数文件,其中包含要提供给模板的示例值。

注意

有关可用示例的列表以及在 Azure 订阅中部署这些示例的指南,请参阅 Azure Monitor 的 Azure 资源管理器示例

为 AKS 群集启用

以下示例为某个 AKS 群集启用容器见解。

模板文件

@description('AKS Cluster Resource ID')
param aksResourceId string

@description('Location of the AKS resource e.g. "China North"')
param aksResourceLocation string

@description('Existing all tags on AKS Cluster Resource')
param aksResourceTagValues object

@description('Azure Monitor Log Analytics Resource ID')
param workspaceResourceId string

resource aksResourceId_8 'Microsoft.ContainerService/managedClusters@2022-01-02-preview' = {
  name: split(aksResourceId, '/')[8]
  location: aksResourceLocation
  tags: aksResourceTagValues
  properties: {
    addonProfiles: {
      omsagent: {
        enabled: true
        config: {
          logAnalyticsWorkspaceResourceID: workspaceResourceId
        }
      }
    }
  }
}

参数文件

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "aksResourceId": {
      "value": "/subscriptions/<SubscriptionId>/resourcegroups/<ResourceGroup>/providers/Microsoft.ContainerService/managedClusters/<ResourceName>"
    },
    "aksResourceLocation": {
      "value": "<aksClusterLocation>"
    },
    "workspaceResourceId": {
      "value": "/subscriptions/<SubscriptionId>/resourceGroups/<ResourceGroup>/providers/Microsoft.OperationalInsights/workspaces/<workspaceName>"
    },
    "aksResourceTagValues": {
      "value": {
        "<existing-tag-name1>": "<existing-tag-value1>",
        "<existing-tag-name2>": "<existing-tag-value2>",
        "<existing-tag-nameN>": "<existing-tag-valueN>"
      }
    }
  }
}

为新的 Azure Red Hat OpenShift v3 群集启用

模板文件

@description('Location')
param location string

@description('Unique name for the cluster')
param clusterName string

@description('number of master nodes')
param masterNodeCount int = 3

@description('number of compute nodes')
param computeNodeCount int = 3

@description('number of infra nodes')
param infraNodeCount int = 3

@description('The ID of an Azure Active Directory tenant')
param aadTenantId string

@description('The ID of an Azure Active Directory client application')
param aadClientId string

@description('The secret of an Azure Active Directory client application')
@secure()
param aadClientSecret string

@description('The Object ID of an Azure Active Directory Group that memberships will get synced into the OpenShift group \'osa-customer-admins\'. If not specified, no cluster admin access will be granted.')
param aadCustomerAdminGroupId string

@description('Azure ResourceId of an existing Log Analytics Workspace')
param workspaceResourceId string

resource clusterName_resource 'Microsoft.ContainerService/openShiftManagedClusters@2019-10-27-preview' = {
  location: location
  name: clusterName
  properties: {
    openShiftVersion: 'v3.11'
    networkProfile: {
      vnetCidr: '10.0.0.0/8'
    }
    authProfile: {
      identityProviders: [
        {
          name: 'Azure AD'
          provider: {
            kind: 'AADIdentityProvider'
            clientId: aadClientId
            secret: aadClientSecret
            tenantId: aadTenantId
            customerAdminGroupId: aadCustomerAdminGroupId
          }
        }
      ]
    }
    masterPoolProfile: {
      count: masterNodeCount
      subnetCidr: '10.0.0.0/24'
      vmSize: 'Standard_D4s_v3'
    }
    agentPoolProfiles: [
      {
        role: 'compute'
        name: 'compute'
        count: computeNodeCount
        subnetCidr: '10.0.0.0/24'
        vmSize: 'Standard_D4s_v3'
        osType: 'Linux'
      }
      {
        role: 'infra'
        name: 'infra'
        count: infraNodeCount
        subnetCidr: '10.0.0.0/24'
        vmSize: 'Standard_D4s_v3'
        osType: 'Linux'
      }
    ]
    routerProfiles: [
      {
        name: 'default'
      }
    ]
    monitorProfile: {
      workspaceResourceID: workspaceResourceId
      enabled: true
    }
  }
}

参数文件

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
            "value": "<azure region of the cluster e.g. chinanorth>"
        },
        "clusterName": {
            "value": "<name of the aro cluster>"
        },
        "aadTenantId": {
            "value": "<id of an azure active directory tenant>"
        },
        "aadClientId": {
            "value": "<id of an azure active directory client application>"
        },
        "aadClientSecret": {
            "value": "<secret of an azure active directory client application  >"
        },
        "aadCustomerAdminGroupId": {
            "value": "<customer admin group id>"
        },
        "workspaceResourceId": {
            "value": "<resource id of an existing log analytics workspace>"
        },
        "masterNodeCount": {
            "value": "<number of master node e.g. 3>"
        },
        "computeNodeCount": {
            "value": "<number of compute nodes in agent pool profile e.g. 3>"
        },
        "infraNodeCount": {
            "value": "<number of infra nodes in agent pool profile e.g. 3>"
        }
    }
}

为现有的 Azure Red Hat OpenShift v3 群集启用

模板文件

@description('ARO Cluster Resource ID')
param aroResourceId string

@description('Location of the aro cluster resource e.g. westcentralus')
param aroResourceLocation string

@description('Azure Monitor Log Analytics Resource ID')
param workspaceResourceId string

resource aroResourceId_8 'Microsoft.ContainerService/openShiftManagedClusters@2019-10-27-preview' = {
  name: split(aroResourceId, '/')[8]
  location: aroResourceLocation
  properties: {
    openShiftVersion: 'v3.11'
    monitorProfile: {
      enabled: true
      workspaceResourceID: workspaceResourceId
    }
  }
}

参数文件

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "aroResourceId": {
      "value": "/subscriptions/<subId>/resourceGroups/<rgName>/providers/Microsoft.ContainerService/openShiftManagedClusters/<clusterName>"
    },
    "aroResourceLocation": {
      "value": "<azure region of the cluster e.g. chinanorth>"
    },
    "workspaceResourceId": {
      "value": "/subscriptions/<SubscriptionId>/resourceGroups/<ResourceGroup>/providers/Microsoft.OperationalInsights/workspaces/<workspaceName>"
    }
  }
}

后续步骤