다음을 통해 공유


빠른 시작: Azure Bicep을 사용하여 AKS(Azure Kubernetes Service) 클러스터에 대한 자격 증명 모음 백업 구성

이 빠른 시작에서는 Azure Bicep을 사용하여 AKS(Azure Kubernetes Service) 클러스터에 대한 자격 증명 모음 백업을 구성하는 방법을 설명합니다.

AKS용 Azure Backup은 AKS 클러스터에 대한 백업을 신속하게 구성할 수 있는 클라우드 네이티브 엔터프라이즈급 애플리케이션 중심 백업 서비스입니다.Azure Backup 을 사용하면 Azure Portal, PowerShell, CLI, Azure Resource Manager, Bicep 등과 같은 여러 옵션을 사용하여 AKS 클러스터를 백업할 수 있습니다. 이 빠른 시작에서는 Bicep 파일 및 Azure PowerShell을 사용하여 AKS 클러스터를 백업하는 방법을 설명합니다. Bicep 파일 개발에 대한 자세한 내용은 Bicep 설명서를 참조하세요.

Bicep은 Azure 리소스를 선언적으로 배포하기 위한 언어입니다. ARM 템플릿(Azure Resource Manager 템플릿)을 개발하는 데 JSON 대신 Bicep을 사용할 수 있습니다. Bicep 구문은 이러한 복잡성을 줄이고 개발 환경을 향상시킵니다. Bicep은 모든 JSON 템플릿 기능을 제공하는 ARM 템플릿 JSON에 대한 투명한 추상화입니다. 배포하는 동안 Bicep CLI는 Bicep 파일을 ARM 템플릿 JSON으로 변환합니다. Bicep 파일은 리소스를 만드는 일련의 프로그래밍 명령을 작성하지 않고 Azure 리소스 및 리소스 속성을 명시합니다.

ARM 템플릿에서 유효한 리소스 종류, API 버전, 속성은 Bicep 파일에서도 유효합니다.

필수 조건

Bicep 개발 환경을 설정하려면 Bicep 도구 설치를 참조하세요.

참고 항목

문서에 설명된 대로 최신 Azure PowerShell 모듈 및 Bicep CLI를 설치합니다.

템플릿 검토

이 템플릿을 사용하면 AKS 클러스터에 대한 백업을 구성할 수 있습니다. 이 템플릿에서는 4시간 일정과 7일 보존 기간을 사용하여 AKS 클러스터에 대한 백업 정책을 사용하여 백업 자격 증명 모음을 만듭니다.

@description('Location for the resource group')
param resourceGroupLocation string
@description('Name of the resource group for AKS and Backup Vault')
param resourceGroupName string
@description('Name of the resource group for storage account and snapshots')
param backupResourceGroupName string
@description('Location for the backup resource group')
param backupResourceGroupLocation string
@description('AKS Cluster name')
param aksClusterName string
@description('DNS prefix for AKS')
param dnsPrefix string
@description('Node count for the AKS Cluster')
param nodeCount int
@description('Name of the Backup Vault')
param backupVaultName string
@description('Datastore type for the Backup Vault')
param datastoreType string
@description('Redundancy type for the Backup Vault')
param redundancy string
@description('Backup policy name')
param backupPolicyName string
@description('Name of the Backup Extension')
param backupExtensionName string
@description('Type of Backup Extension')
param backupExtensionType string
@description('Name of the Storage Account')
param storageAccountName string

var backupContainerName = 'tfbackup'

resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
  ___location: resourceGroupLocation
  name: resourceGroupName
}

resource backupRg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
  ___location: backupResourceGroupLocation
  name: backupResourceGroupName
}

resource aksCluster 'Microsoft.ContainerService/managedClusters@2023-05-01' = {
  ___location: resourceGroupLocation
  name: aksClusterName
  properties: {
    dnsPrefix: dnsPrefix
    agentPoolProfiles: [
      {
        name: 'agentpool'
        count: nodeCount
        vmSize: 'Standard_D2_v2'
        type: 'VirtualMachineScaleSets'
        mode: 'System'
      }
    ]
    identity: {
      type: 'SystemAssigned'
    }
    networkProfile: {
      networkPlugin: 'kubenet'
      loadBalancerSku: 'standard'
    }
  }
  dependsOn: [
    rg
    backupRg
  ]
}

resource backupVault 'Microsoft.DataProtection/backupVaults@2023-01-01' = {
  ___location: resourceGroupLocation
  name: backupVaultName
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    dataStoreType: datastoreType
    redundancy: redundancy
  }
  dependsOn: [
    aksCluster
  ]
}

resource backupPolicy 'Microsoft.DataProtection/backupVaults/backupPolicies@2023-01-01' = {
  name: '${backupVaultName}/${backupPolicyName}'
  properties: {
    backupRepeatingTimeIntervals: ['R/2024-04-14T06:33:16+00:00/PT4H']
    defaultRetentionRule: {
      lifeCycle: {
        duration: 'P7D'
        dataStoreType: 'OperationalStore'
      }
    }
  }
  dependsOn: [
    backupVault
  ]
}

resource storageAccount 'Microsoft.Storage/storageAccounts@2022-05-01' = {
  ___location: backupResourceGroupLocation
  name: storageAccountName
  sku: {
    name: 'Standard_LRS'
  }
  kind: 'StorageV2'
  dependsOn: [
    aksCluster
  ]
}

resource backupContainer 'Microsoft.Storage/storageAccounts/blobServices/containers@2021-04-01' = {
  name: '${storageAccount.name}/default/${backupContainerName}'
  properties: {
    publicAccess: 'None'
  }
  dependsOn: [
    storageAccount
  ]
}

resource backupExtension 'Microsoft.KubernetesConfiguration/extensions@2023-05-01' = {
  name: '${aksClusterName}/${backupExtensionName}'
  properties: {
    extensionType: backupExtensionType
    configurationSettings: {
      'configuration.backupStorageLocation.bucket': backupContainerName
      'configuration.backupStorageLocation.config.storageAccount': storageAccountName
      'configuration.backupStorageLocation.config.resourceGroup': backupResourceGroupName
      'configuration.backupStorageLocation.config.subscriptionId': subscription().subscriptionId
      'credentials.tenantId': subscription().tenantId
    }
  }
  dependsOn: [
    backupContainer
  ]
}

output aksClusterId string = aksCluster.id
output backupVaultId string = backupVault.id

템플릿 배포

이 템플릿을 배포하려면 GitHub 또는 원하는 위치에 저장한 다음 셸 창에 다음 PowerShell 스크립트를 붙여넣습니다. 코드를 붙여넣으려면 셸 창을 마우스 오른쪽 단추로 클릭하고 붙여넣기를 선택합니다.

$projectName = Read-Host -Prompt "Enter a project name (limited to eight characters) that is used to generate Azure resource names"
$___location = Read-Host -Prompt "Enter the ___location (for example, centralus)"

$resourceGroupName = "${projectName}rg"
$templateUri = "templateURI"

New-AzResourceGroup -Name $resourceGroupName -Location $___location
New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateUri $templateUri -projectName $projectName 

다음 단계