Helm 3- Azure 컨테이너 등록(ACR) 및 Azure Kubernetes 서비스(AKS)를 사용하는 Azure DevOps CI/CD
본고에서 ACR로 발표된 도표를 사용하여 예시적인 헬멧 도표를 ACR에 발표하고 응용 프로그램을Azure Kubernetes 서비스(AKS)에 배치하는 방법을 볼 수 있습니다.또한 ACR의 저장소 범위 내의 토큰을 사용할 예정입니다. 이것은 미리 보기 기능으로 큰 이점을 제공합니다.<-자세히 -->
본 게시판에는 다음과 같은 내용이 소개되어 있습니다.
1) 선결 조건
CI와 CD에 대해 저는 본문에서 Azure DevOps YAML 다중 파이프를 사용할 것입니다. 저희 파이프는 다음과 같이 구분됩니다.
2) CI 단계
3)CD무대

제가 사용하는 코드는
1. 선결 조건
다양한 방법으로 ACR을 통해 인증할 수 있습니다.
저장소 범위 내의 토큰을 사용하도록 ACR 설정
나는 기호화폐를 사용하여 ACR에 우리 자신을 인증할 것이다.가장 큰 장점은 레지스트리 소유자로서 조직 전체에 하나의 ACR 인스턴스를 가질 수 있으며 특정 팀이 선택한 저장소에만 액세스할 수 있다는 것입니다.documentation에서 또 다른 재미있는 장면을 강조했는데 주로...
Premium 레이어를 사용하도록 ACR 인스턴스를 업그레이드하는 것이 첫 번째 단계입니다.
그런 다음
Premium 을 선택하고 Save 을 클릭합니다.
범위 매핑 만들기
일단 고급 레벨에 진입하면 토큰을 만들 수 있습니다.그러나 태그를 만들기 전에 두 개의 범위 맵을 정의합니다.토큰과 연관된 역할 영역 매핑은 ACR에서 수행할 수 있는 작업에 대한 권한을 설정합니다.
chartpull - 읽기 권한을
helmdemo/vote-app 환매 범위로 제한합니다.content/read과 metadata/read 권한을 사용하고 있습니다.chartpush -
helmdemo/vote-app의 내부 쓰기 권한을 환매하는 범위를 제한합니다.content/write과 content/read 권한을 사용하고 있습니다.따라서 범위도를 만들려면
Scope maps 섹션 아래의 Repository permissions으로 이동한 다음 + Add을 클릭하십시오.나로서는 이 범위를 helmdemo에 한정하여 환매할 것이다.
나는 같은 과정에 따라
chartpull scope라는 또 다른 작용역을 만들었는데 그 중에서 content/read, metadata/read개의 작용역을 포함한다.
- Notice that in
 chartpushscope we also allowcontent/readpermission. This is because, you needcontent/readscope along withcontent/writescope if you are going to push charts to ACR (for the repo defined in the scope).- You can also use Azure CLI to do the same. Use
 az acr tokencommand. Refer the documentation for more information.
생성 토큰
일단 작용역을 정의하면 영패를 만들 수 있습니다.
Tokens 섹션에서 Repository permissions 으로 이동한 다음 + Add 을 클릭합니다.그런 다음 태그(예: helmdemopull)를 명명하고 위에서 만든 범위 맵을 선택합니다.내 예에서, 나는 두 개의 영패를 만들었는데, 하나는 pull에 사용되고, 다른 하나는push에 사용된다.
이 과정을 반복해서 다른 영패를 만들 수 있습니다.화면을 새로 고치면 아래의 이런 화면을 볼 수 있을 것이다.

이 영패(
helmdemopull과 helmdemopush)가 비밀번호를 생성하지 않았음을 알 수 있습니다.비밀번호를 만들겠습니다.토큰을 클릭하고 Actions 또는 password1의 password2 열에 있는 아이콘을 클릭합니다.만약 영패가 특정 날짜에만 유효하도록 허락할 계획이라면, 비밀번호의 만료 날짜를 설정할 수도 있습니다.
2.CI 단계
GitHub에서 최신 차트 가져오기
GitHub 리콜 프로토콜에서 최신 원본을 얻기 위해 YAML 파이프라인에
resources절을 추가하고 GitHub의 리콜 프로토콜을 가리켰습니다.GitHub 서비스 연결 이름이 있는 endpoint 매개 변수를 전달해야 합니다.이 작업을 수행하는 방법에 대한 자세한 내용은 here 및 here으로 문의하십시오.resources:
 repositories:
   - repository: helmrepo
     type: github
     name: utkarshpoc/azure-vote-helm-chart
     endpoint: github
ACR에 차트 게시
ACR에 게시하는 절차를 작성하기 전에 파이프에 생성된 영패를 변수로 저장해야 합니다.여기서, 나는 파이프의 변수 UI를 사용하여 영패를 변수로 추가하고 비밀번호를 기밀로 표시했다.

You can also define these in Azure Pipelines Library if you intend to use these tokens in multiple pipelines.
나는 YAML 자체에도 정적 변수와 비비밀 변수가 있기 때문에
variables을 사용하여 원본 코드를 제어한다. 아래와 같다.variables:
  acr.name: acrdemoutkarsh
  acr.repo.name: helmdemo/vote-app
조타도를 발표하는 절차는 매우 간단하다.1. 에이전트에 헬멧 장착3
이 작업은 OOB
HelmInstaller 작업을 사용하여 수행할 수 있습니다.YAML은 다음과 같습니다.여기서 저는 latest을 helmVersion에 사용하지만 특정한 버전(3.x 이상)을 고수할 수 있습니다.- task: HelmInstaller@0
  displayName: install helm
  inputs:
    helmVersion: 'latest'
    installKubectl: false
2. Helm을 사용하여 ACR에 로그인
우리는 간단한
script 절차를 사용하여 등록표에 로그인할 수 있다.- script: |
    helm registry login $(acr.name).azurecr.io --username $(acr.push.username) --password $(acr.push.password)
  displayName: login to acr using helm
그러나 만약 당신이 이것을 운행한다면, 이 글을 쓸 때, 당신은 다음과 같은 오류를 얻게 될 것이다.Error: this feature has been marked as experimental and is not enabled by default. 
Please set HELM_EXPERIMENTAL_OCI=1 in your environment to use this feature
잘못 말한 바와 같이 개방식 컨테이너 제안(OCI) 표준을 따르는 키맵을 발표하는 것은 실험적이기 때문에 HELM_EXPERIMENTAL_OCI을 1으로 설정해야 합니다.이 기능은 YAML의 variables 섹션을 업데이트하여 구현할 수 있습니다.업데이트된yaml은 다음과 같습니다.variables:
  acr.name: acrdemoutkarsh
  acr.repo.name: helmdemo/vote-app
  HELM_EXPERIMENTAL_OCI: 1
3. 차트를 저장하고 ACR로 밀어넣기
다음 단계에서는 이 차트를 로컬로 저장하고 ACR 레지스트리 URL을 사용하여 차트의 앨리어스를 만듭니다.따라서 YAML은 다음과 같습니다.
- script: |
    helm chart save $(build.sourcesdirectory)/src/azure-vote-helm-chart/ $(acr.name).azurecr.io/$(acr.repo.name):latest
  displayName: save the chart and set the alias
마지막으로, 우리는 helm chart push 명령을 사용하여 키맵을 ACR로 전송합니다.- script: |
    helm chart push $(acr.name).azurecr.io/$(acr.repo.name):latest
  displayName: push the chart to acr
그래서 우리 CI 단계는 이미 끝났어.2. CD 무대
ACR에서 최신 버전 차트 가져오기
첫 번째 단계는 최신 버전의 도표 (라벨
latest) 를 저희 에이전트에 끌어다 놓고 폴더로 압축하는 것입니다.우리는 파이프에서 이렇게 할 수 있다. 아래와 같다.새 stage name cd을 추가했습니다. 이것은 stage ci에 의존합니다.- stage: cd
    displayName: CD
    dependsOn: ci
    jobs:
    - deployment: helm_publish_aks
      displayName: deploy to aks
      environment: 
        name: PROD
        resourceName: helmdemo
        resourceType: Kubernetes
      strategy:
        runOnce:
          deploy:
            steps:
            - task: HelmInstaller@0
              displayName: install helm
              inputs:
                helmVersion: 'latest'
                installKubectl: false
            - script: |
                echo "$(acr.pull.password)" | helm registry login $(acr.name).azurecr.io --username $(acr.pull.username) --password-stdin
              displayName: login to acr using helm
            - bash: |
                  helm chart pull $(acr.name).azurecr.io/$(acr.repo.name):latest
              displayName: get helm chart on agent
            - bash: |
                helm chart export $(acr.name).azurecr.io/$(acr.repo.name):latest --destination $(build.stagingdirectory)
              displayName: export the chart to folder
Because each job in Azure DevOps run in a separate agent, I have to ensure agent has Helm tool, so install Helm tool again in the first step. Also, note that I am using token with scope-map permission set only to pull charts.
AKS에 차트 배포
현재 최신 도표는 우리의 ACR에서 추출되었고 에이전트에서 사용할 수 있으며 나머지 유일한 단계는 AKS에 배치하는 것입니다.우리는
HelmDeploy 임무를 사용하여 완성할 수 있다.- task: HelmDeploy@0
  displayName: deploy chart to aks
  inputs:
    connectionType: 'Azure Resource Manager'
    azureSubscription: '$(azure.service.connection)'
    azureResourceGroup: 'demos'
    kubernetesCluster: 'aksdemoutkarsh'
    namespace: 'helmdemo'
    command: 'upgrade'
    chartType: 'FilePath'
    chartPath: '$(build.stagingdirectory)/azure-vote/'
    releaseName: 'helmdemo'
    arguments: '--create-namespace --install'
Azure DevOps에서 배포된 서비스 보기
Azure DevOps 환경에 Kubernetes cluster as a resource을 추가한 경우 배포된 서비스를 Azure DevOps에서 직접 확인할 수 있습니다.

YAML에서 배포된 서비스와 노출된 포트를 볼 수도 있습니다.

노출된 포트를 찾으면 프로그램을 볼 수 있습니다.

결론
그렇지!여기까지 읽었다면 고맙습니다🙏🏼. 보시다시피 영패와 OCI 부품의 지원 아래 ACR은 같은 용기 등록표 중 가장 좋은 것이다.또한 AKS(탐색 서비스, 로그, yaml 등)와의 심도 있는 통합을 통해 Azure DevOps는 당신의 팀에 대량의 생산성을 가져다 줍니다.네가 이 문장의 내용이 풍부하다고 느끼기를 바란다.그렇다면 공유하고 밀어주세요!
Reference
이 문제에 관하여(Helm 3- Azure 컨테이너 등록(ACR) 및 Azure Kubernetes 서비스(AKS)를 사용하는 Azure DevOps CI/CD), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/onlyutkarsh/helm-3-ci-cd-with-azure-devops-using-azure-container-registry-acr-and-azure-kubernetes-service-aks-im8텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)