<출처> https://docs.microsoft.com/en-us/windows/wsl/install
Azure SA 업무환경 설정
Azure VM 생성 - Windows 11
구독, 리소스 그룹을 선택 및 입력한다.
Image는 Windows 11 pro를 선택하고 Size는 Standard D4s v5 (4 vcpus, 16 GiB memory)를 선택하여 VM 생성을 시작한다.
업무 환경 구성
사전 작업
생성된 VM 서버 접속 후 Windows features 에서 Hyper-V와 Virtual Machine Platform을 선택한다.
Don't restart를 선택한다.
WSL 설치
Terminal 또는 Windows PowerShell을 관리자 권한으로 실행 하고 다음과 같이 명령을 입력한다.
# 온라인 스토어를 통해 다운로드할 수 있는 사용 가능한 Linux 배포판 목록을 확인 wsl -l -o # 지정 배포판 설치 : wsl --install -d <Distribution Name> wsl --install --distribution Ubuntu-22.04 |
설치 가능한 목록을 확인한다. 여기서는 Ubuntu-22.04를 기준으로 한다.
설치가 완료되면 시스템을 재부팅 한다.
재부팅 후 자동으로 터미널이 팝업되어 설치가 마무리 된다. username과 password 입력을 수행한다.
Windows PowerShell을 관리자 권한으로 실행 하고 다음과 같이 명령을 입력한다.
wsl -l -v |
Docker Desktop for Windows 설치
여기에서 Docker Desktop for Windows를 다운로드 및 기본으로 설치 후 Close and log out을 클릭하여 재부팅 한다.
재부팅이 완료되고 Docker Desktop이 시작되면 설정 아이콘을 클릭하고 들어가 Resoures > WSL Integration에서 Ubuntu-22.04를 활성화 하고 Apply & Restart를 클릭한다.
Terminal을 실행하고 다음과 같이 명령을 입력한다.
# Docker 상태 점검 (on Windows) docker ps # wsl 환경으로 전환 wsl # Docker 상태 점검 및 버전 확인 (on Linux) docker ps docker version |
PS C:\Users\zerobig> docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES PS C:\Users\zerobig> wsl To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details. zerobig@sa-winvm:/mnt/c/Users/zerobig$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES zerobig@sa-winvm:/mnt/c/Users/zerobig$ docker version Client: Docker Engine - Community Cloud integration: v1.0.35+desktop.5 Version: 24.0.6 API version: 1.43 Go version: go1.20.7 Git commit: ed223bc Built: Mon Sep 4 12:32:16 2023 OS/Arch: linux/amd64 Context: default Server: Docker Desktop Engine: Version: 24.0.6 API version: 1.43 (minimum version 1.12) Go version: go1.20.7 Git commit: 1a79695 Built: Mon Sep 4 12:32:16 2023 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.22 GitCommit: 8165feabfdfe38c65b599c4993d227328c231fca runc: Version: 1.1.8 GitCommit: v1.1.8-0-g82f18fe docker-init: Version: 0.19.0 GitCommit: de40ad0 zerobig@sa-winvm:/mnt/c/Users/zerobig$ |
Git Bash 설치
For Windows
여기로 이동하여 최신 버전을 기본값으로 설치한다. 2022년 7월 17일 현재 최신 버전은 2.37.1이다.
For Linux(WSL) → 불필요. 이미 설됨
Git은 대부분의 Linux용 Windows 하위 시스템 배포판과 함께 이미 설치되어 있지만 최신 버전으로 업데이트할 수 있다. 또한 git 구성 파일을 설정해야 한다.
git version sudo apt-get install git git version |
Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. 새로운 크로스 플랫폼 PowerShell 사용 https://aka.ms/pscore6 PS C:\Users\zerobig> wsl zerobig@ZEROBIG-NT800:/mnt/c/Users/zerobig$ git version git version 2.25.1 zerobig@ZEROBIG-NT800:/mnt/c/Users/zerobig$ sudo apt-get install git [sudo] password for zerobig: Reading package lists... Done Building dependency tree Reading state information... Done git is already the newest version (1:2.25.1-1ubuntu3). git set to manually installed. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. zerobig@ZEROBIG-NT800:/mnt/c/Users/zerobig$ git version git version 2.25.1 zerobig@ZEROBIG-NT800:/mnt/c/Users/zerobig$ |
Git 구성 파일 설정
bash (Ubuntu-20.04)터미널에서 다음 명령을 수행하여 사용자 이름을 설정한다.
git config --global user.name "Your Name" |
추가로 이메일 정보를 설정한다.
git config --global user.email "youremail@domain.com" |
Terraform 설치
For Windows
먼저 여기에서 최신 Terraform 버전을 다운로드 받는다.
다운로드 완료 후 C:\ 드라이브 밑에 Terraform이라는 디렉토리를 생성하고 다운로드한 Terrraform 압축파일을 해당 디렉토리 내에 압축해제하여 위치시킨다.
윈도우즈 키와 R키를 누르고 “sysdm.cpl ,3”를 입력하여 실행한다.
환경 변수를 선택하고 시스템 변수 에서 Path를 클릭한다.
새로 만들기(N)을 선택하고 다음과 같이 Terraform 디렉토리 패스 정보를 입력하고 확인을 선택한다.
새로 Windows Terminal 창을 띄우고 다음 명령을 수행하여 Terraform 버전을 확인한다.
# Terraform 버전 확인 terraform version |
For Linux(WSL)
다음 명령을 수행하여 설치를 진행하고 결과를 검증한다.
# Install HashiCorp's Debian package repository sudo apt-get update && sudo apt-get install -y gnupg software-properties-commo # Install the HashiCorp GPG key wget -O- https://apt.releases.hashicorp.com/gpg | \ gpg --dearmor | \ sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg # Verify the key's fingerprint. gpg --no-default-keyring \ --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg \ --fingerprint # Add the official HashiCorp repository to your system echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] \ https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \ sudo tee /etc/apt/sources.list.d/hashicorp.list # Download the package information and Install Terraform from the new repository. sudo apt update sudo apt-get install terraform # Verify the installation terraform -v # Enable tab completion terraform -install-autocomplete source ~/.bashrc |
AZ CLI 설치
For Windows
먼저 여기에서 최신 버전을 다운로드 받고 기본으로 설치를 진행한다.
For Linux(WSL)
다음 명령을 수행하여 설치를 진행하고 결과를 검증한다.
# Download installation script and Execute it curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash # Verify the installation az version |
Azure Az PowerShell 모듈 설치
여기를 참조하여 다운로드 및 설치한다.
이 모듈을 설치하면 일반적으로 사용 가능한 Az PowerShell 모듈이 다운로드되고, cmdlet을 사용할 수 있게 된다.
중요 Az PowerShell 모듈은 모든 플랫폼에서 Azure 리소스를 관리하는 데 권장되는 PowerShell 모듈입니다. |
# Check the PowerShell version $PSVersionTable.PSVersion # Set the PowerShell script execution policy to remote signed or less restrictive Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser # Install the Az module for the current user only Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force |
PS C:\Restore_20220903\2022-AzureHandsOn\mslearn-bicep> $PSVersionTable.PSVersion Major Minor Build Revision ----- ----- ----- -------- 5 1 19041 1682 PS C:\Restore_20220903\2022-AzureHandsOn\mslearn-bicep> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser PS C:\Restore_20220903\2022-AzureHandsOn\mslearn-bicep> Install-ModuleName Az -Scope CurrentUser -Repository PSGallery -Force 계속하려면 NuGet 공급자가 필요합니다. NuGet 기반 리포지토리를 조작하려면 PowerShellGet에 NuGet 공급자 버전 '2.8.5.201' 이상이 필요합니다. 'C:\Program 'C:\Users\zerobig\AppData\Local\PackageManagement\ProviderAssemblies' 에 서 NuGet 공급자를 사용할 수 있어야 합니다. 또한 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'를 실행하여 NuGet 공급자를 설치할 수 있습니다. 지금 PowerShellGet에서 NuGet 공급자를 설치하고 가져오시겠습니까? [Y] 예(Y) [N] 아니요(N) [S] 일시 중단(S) [?] 도움말 (기본값은 "Y"): Y PS C:\Restore_20220903\2022-AzureHandsOn\mslearn-bicep> |
kuberctl 설치
For Windows
먼저 여기에서 최신 버전을 다운로드 받고 기본으로 설치를 진행한다.
kubectl 디렉토리에 다운로드 받은 실행 파일을 위치시키고 terraform과 같은 방식으로 환경변수 path에 등록한다.
For Linux(WSL)
다음 명령을 수행하여 설치를 진행하고 결과를 검증한다.
# Download the latest release curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" # Validate the binary curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256" echo "$(cat kubectl.sha256) kubectl" | sha256sum --check # Install kubectl sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl # Verify the installation kubectl version --client # Enable kubectl autocompletion kubectl completion bash | sudo tee /etc/bash_completion.d/kubectl > /dev/null source ~/.bashrc |
VS Code 설치
다운로드 후 설치한다.
설치 과정에서 추가 작업 선택 화면에서 다음 두 개를 체크하고 진행한다.
Visual Studio 설치 (옵션)
여기를 클릭하여 다운로드 및 설치한다.
Terraform을 사용하여 Azure Kubernetes Service로 Kubernetes 클러스터 만들기
소스 준비
git clone https://github.com/zer0big/TerroformAksDeployDemo.git cd TerroformAksDeployDemo/ code . |
aks-demo# git clone https://github.com/zer0big/TerroformAksDeployDemo.git Cloning into 'TerroformAksDeployDemo'... remote: Enumerating objects: 15, done. remote: Counting objects: 100% (15/15), done. remote: Compressing objects: 100% (14/14), done. remote: Total 15 (delta 2), reused 11 (delta 1), pack-reused 0 Unpacking objects: 100% (15/15), 9.43 KiB | 32.00 KiB/s, done. aks-demo# cd TerroformAksDeployDemo/ aks-demo# code . |
Terraform 배포
az login terraform init terraform plan terraform apply -auto-approve |
zerobig@sa-winvm:/mnt/c/Users/zerobig/TerroformAksDeployDemo$ terraform init Initializing the backend... Initializing provider plugins... - Reusing previous version of hashicorp/azurerm from the dependency lock file - Installing hashicorp/azurerm v3.46.0... - Installed hashicorp/azurerm v3.46.0 (signed by HashiCorp) Terraform has been successfully initialized! You may now begin working with Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. All Terraform commands should now work. If you ever set or change modules or backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary. zerobig@sa-winvm:/mnt/c/Users/zerobig/TerroformAksDeployDemo$ terraform plan Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: # azurerm_container_registry.zerobigaks-demo will be created + resource "azurerm_container_registry" "zerobigaks-demo" { + admin_enabled = false + admin_password = (sensitive value) + admin_username = (known after apply) + encryption = (known after apply) + export_policy_enabled = true + id = (known after apply) + location = "koreacentral" + login_server = (known after apply) + name = "tdgzeroacrdemo" + network_rule_bypass_option = "AzureServices" + network_rule_set = (known after apply) + public_network_access_enabled = true + resource_group_name = "RG-TDG-CMS-2023-AKSDemo" + retention_policy = (known after apply) + sku = "Standard" + trust_policy = (known after apply) + zone_redundancy_enabled = false } # azurerm_kubernetes_cluster.zerobigaks-demo will be created + resource "azurerm_kubernetes_cluster" "zerobigaks-demo" { + api_server_authorized_ip_ranges = (known after apply) + dns_prefix = "zerobigaksdemo" + fqdn = (known after apply) + http_application_routing_zone_name = (known after apply) + id = (known after apply) + image_cleaner_enabled = false + image_cleaner_interval_hours = 48 + kube_admin_config = (sensitive value) + kube_admin_config_raw = (sensitive value) + kube_config = (sensitive value) + kube_config_raw = (sensitive value) + kubernetes_version = (known after apply) + location = "koreacentral" + name = "tdgzeroaksdemo" + node_resource_group = (known after apply) + oidc_issuer_url = (known after apply) + portal_fqdn = (known after apply) + private_cluster_enabled = false + private_cluster_public_fqdn_enabled = false + private_dns_zone_id = (known after apply) + private_fqdn = (known after apply) + public_network_access_enabled = true + resource_group_name = "RG-TDG-CMS-2023-AKSDemo" + role_based_access_control_enabled = true + run_command_enabled = true + sku_tier = "Free" + tags = { + "Environment" = "DEV" } + workload_identity_enabled = false + default_node_pool { + kubelet_disk_type = (known after apply) + max_pods = (known after apply) + name = "default" + node_count = 2 + node_labels = (known after apply) + orchestrator_version = (known after apply) + os_disk_size_gb = (known after apply) + os_disk_type = "Managed" + os_sku = (known after apply) + scale_down_mode = "Delete" + type = "VirtualMachineScaleSets" + ultra_ssd_enabled = false + vm_size = "Standard_D2_v2" + workload_runtime = (known after apply) } + identity { + principal_id = (known after apply) + tenant_id = (known after apply) + type = "SystemAssigned" } } # azurerm_resource_group.rg will be created + resource "azurerm_resource_group" "rg" { + id = (known after apply) + location = "koreacentral" + name = "RG-TDG-CMS-2023-AKSDemo" } # azurerm_role_assignment.enablePulling will be created + resource "azurerm_role_assignment" "enablePulling" { + id = (known after apply) + name = (known after apply) + principal_id = (known after apply) + principal_type = (known after apply) + role_definition_id = (known after apply) + role_definition_name = "AcrPull" + scope = (known after apply) + skip_service_principal_aad_check = true } Plan: 4 to add, 0 to change, 0 to destroy. Changes to Outputs: + aks_fqdn = (known after apply) + aks_id = (known after apply) + aks_node_rg = (known after apply) ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now. zerobig@sa-winvm:/mnt/c/Users/zerobig/TerroformAksDeployDemo$ zerobig@sa-winvm:/mnt/c/Users/zerobig/TerroformAksDeployDemo$ zerobig@sa-winvm:/mnt/c/Users/zerobig/TerroformAksDeployDemo$ zerobig@sa-winvm:/mnt/c/Users/zerobig/TerroformAksDeployDemo$ terraform apply -auto-approve Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: + create Terraform will perform the following actions: # azurerm_container_registry.zerobigaks-demo will be created + resource "azurerm_container_registry" "zerobigaks-demo" { + admin_enabled = false + admin_password = (sensitive value) + admin_username = (known after apply) + encryption = (known after apply) + export_policy_enabled = true + id = (known after apply) + location = "koreacentral" + login_server = (known after apply) + name = "tdgzeroacrdemo" + network_rule_bypass_option = "AzureServices" + network_rule_set = (known after apply) + public_network_access_enabled = true + resource_group_name = "RG-TDG-CMS-2023-AKSDemo" + retention_policy = (known after apply) + sku = "Standard" + trust_policy = (known after apply) + zone_redundancy_enabled = false } # azurerm_kubernetes_cluster.zerobigaks-demo will be created + resource "azurerm_kubernetes_cluster" "zerobigaks-demo" { + api_server_authorized_ip_ranges = (known after apply) + dns_prefix = "zerobigaksdemo" + fqdn = (known after apply) + http_application_routing_zone_name = (known after apply) + id = (known after apply) + image_cleaner_enabled = false + image_cleaner_interval_hours = 48 + kube_admin_config = (sensitive value) + kube_admin_config_raw = (sensitive value) + kube_config = (sensitive value) + kube_config_raw = (sensitive value) + kubernetes_version = (known after apply) + location = "koreacentral" + name = "tdgzeroaksdemo" + node_resource_group = (known after apply) + oidc_issuer_url = (known after apply) + portal_fqdn = (known after apply) + private_cluster_enabled = false + private_cluster_public_fqdn_enabled = false + private_dns_zone_id = (known after apply) + private_fqdn = (known after apply) + public_network_access_enabled = true + resource_group_name = "RG-TDG-CMS-2023-AKSDemo" + role_based_access_control_enabled = true + run_command_enabled = true + sku_tier = "Free" + tags = { + "Environment" = "DEV" } + workload_identity_enabled = false + default_node_pool { + kubelet_disk_type = (known after apply) + max_pods = (known after apply) + name = "default" + node_count = 2 + node_labels = (known after apply) + orchestrator_version = (known after apply) + os_disk_size_gb = (known after apply) + os_disk_type = "Managed" + os_sku = (known after apply) + scale_down_mode = "Delete" + type = "VirtualMachineScaleSets" + ultra_ssd_enabled = false + vm_size = "Standard_D2_v2" + workload_runtime = (known after apply) } + identity { + principal_id = (known after apply) + tenant_id = (known after apply) + type = "SystemAssigned" } } # azurerm_resource_group.rg will be created + resource "azurerm_resource_group" "rg" { + id = (known after apply) + location = "koreacentral" + name = "RG-TDG-CMS-2023-AKSDemo" } # azurerm_role_assignment.enablePulling will be created + resource "azurerm_role_assignment" "enablePulling" { + id = (known after apply) + name = (known after apply) + principal_id = (known after apply) + principal_type = (known after apply) + role_definition_id = (known after apply) + role_definition_name = "AcrPull" + scope = (known after apply) + skip_service_principal_aad_check = true } Plan: 4 to add, 0 to change, 0 to destroy. Changes to Outputs: + aks_fqdn = (known after apply) + aks_id = (known after apply) + aks_node_rg = (known after apply) azurerm_resource_group.rg: Creating... azurerm_resource_group.rg: Creation complete after 1s [id=/subscriptions/98483591-af84-4569-ba3d-0711ced77b32/resourceGroups/RG-TDG-CMS-2023-AKSDemo] azurerm_container_registry.zerobigaks-demo: Creating... azurerm_kubernetes_cluster.zerobigaks-demo: Creating... azurerm_container_registry.zerobigaks-demo: Still creating... [10s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [10s elapsed] azurerm_container_registry.zerobigaks-demo: Creation complete after 17s [id=/subscriptions/98483591-af84-4569-ba3d-0711ced77b32/resourceGroups/RG-TDG-CMS-2023-AKSDemo/providers/Microsoft.ContainerRegistry/registries/tdgzeroacrdemo] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [20s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [30s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [40s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [50s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [1m0s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [1m10s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [1m20s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [1m30s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [1m40s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [1m50s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [2m0s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [2m10s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [2m20s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [2m30s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [2m40s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [2m50s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [3m0s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [3m10s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [3m20s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [3m30s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Still creating... [3m40s elapsed] azurerm_kubernetes_cluster.zerobigaks-demo: Creation complete after 3m45s [id=/subscriptions/98483591-af84-4569-ba3d-0711ced77b32/resourceGroups/RG-TDG-CMS-2023-AKSDemo/providers/Microsoft.ContainerService/managedClusters/tdgzeroaksdemo] azurerm_role_assignment.enablePulling: Creating... azurerm_role_assignment.enablePulling: Still creating... [10s elapsed] azurerm_role_assignment.enablePulling: Still creating... [20s elapsed] azurerm_role_assignment.enablePulling: Creation complete after 26s [id=/subscriptions/98483591-af84-4569-ba3d-0711ced77b32/resourceGroups/RG-TDG-CMS-2023-AKSDemo/providers/Microsoft.ContainerRegistry/registries/tdgzeroacrdemo/providers/Microsoft.Authorization/roleAssignments/41ac72ed-cc01-d35e-a12c-23c90fbebfe6] Apply complete! Resources: 4 added, 0 changed, 0 destroyed. Outputs: aks_fqdn = "zerobigaksdemo-9fctjqgz.hcp.koreacentral.azmk8s.io" aks_id = "/subscriptions/98483591-af84-4569-ba3d-0711ced77b32/resourceGroups/RG-TDG-CMS-2023-AKSDemo/providers/Microsoft.ContainerService/managedClusters/tdgzeroaksdemo" aks_node_rg = "MC_RG-TDG-CMS-2023-AKSDemo_tdgzeroaksdemo_koreacentral" |
Terraform 배포 결과 확인
Azure Portal로 이동하여 배포 결과를 확인한다.
ACR에 대한 AKS 관리 ID Role 부여 현황을 확인한다.
AKS 클러스터 검증
# Define variables # Get AKS credentials # Get Node Info |
Application 배포 및 검증
ACR 이미지 등록
별도 터미널 창을 열어 이미지 태그 및 푸시
# Docker tag and Push to ACR |
Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. 새로운 크로스 플랫폼 PowerShell 사용 https://aka.ms/pscore6 PS C:\Users\zerobig> docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES PS C:\Users\zerobig> docker images REPOSITORY TAG IMAGE ID CREATED SIZE appmod-contapp latest 8629e2fcf972 4 days ago 121MB zeroacrdemo.azurecr.io/ap latest 8629e2fcf972 4 days ago 121MB zeroacrdemo.azurecr.io/appmod-contapp latest 8629e2fcf972 4 days ago 121MB zeroacrtf.azurecr.io/appmod-contapp latest 8629e2fcf972 4 days ago 121MB PS C:\Users\zerobig> docker tag appmod-contapp osd2023zeroacrdemo.azurecr.io/appmod-contapp:latest PS C:\Users\zerobig> az acr login -n osd2023zeroacrdemo Login Succeeded PS C:\Users\zerobig> docker push osd2023zeroacrdemo.azurecr.io/appmod-contapp:latest The push refers to repository [osd2023zeroacrdemo.azurecr.io/appmod-contapp] 7374f8b571a9: Pushed ceaf9e1ebef5: Pushed 9b9b7f3d56a0: Pushed f1b5933fe4b5: Pushed latest: digest: sha256:ddf9994cb1630255c2fcec8b60617811ca751e59aaf7bcc99677028cd43f78c1 size: 1159 PS C:\Users\zerobig> |
YAML Manifest 구성
apiVersion: apps/v1 kind: Deployment metadata: name: zeroaksdemo spec: replicas: 2 selector: matchLabels: app: zero-aks-app template: metadata: labels: app: zero-aks-app spec: containers: - name: zero-aks-demo image: zeroacrtf.azurecr.io/web:latest ports: - containerPort: 8080 --- apiVersion: v1 kind: Service metadata: name: zero-aks-app spec: ports: - name: http-port port: 80 targetPort: 8080 selector: app: zero-aks-app type: LoadBalancer |
YAML Manifest 배포 및 결과 검증
zerobig@ZEROBIG-NT800:/mnt/d/2023_Azure/HandsOn/Terraform$ kubectl apply -f contapp-deploy-svc.yaml deployment.apps/zeroaksdemo created service/zero-aks-app created zerobig@ZEROBIG-NT800:/mnt/d/2023_Azure/HandsOn/Terraform$ kubectl get pod --watch NAME READY STATUS RESTARTS AGE zeroaksdemo-5874694c78-2k6zk 1/1 Running 0 7s zeroaksdemo-5874694c78-4xrbt 1/1 Running 0 7s ^Czerobig@ZEROBIG-NT800:/mnt/d/2023_Azure/HandsOn/Terraform$ kubectl get svc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 17m zero-aks-app LoadBalancer 10.0.104.234 20.214.218.34 80:30193/TCP 3m2s zerobig@ZEROBIG-NT800:/mnt/d/2023_Azure/HandsOn/Terraform$ |