現在正在參加 Kubernetes in Azure workshop,
有實作 Azure Container Registry ( ACR ) , 快速小記一下
OS: Mac OS X EI Capitan 10.11.6
目前 Azure 上面的管理都是透過 azure-cli 來管理
所以這次就在 Mac 上面裝 Azure-clie, 參考官方文件上面的說明 https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest
先裝 Homebrew in Mac
在終端機執行下列指令 就可以安裝 homebrew
$/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
先執行 brew update
$ brew update
Already up-to-date.
安裝 azure-cli 套件
$ brew install azure-cli
我是使用 互動的方式登入
$ az login
To sign in, use a web browser to open the page https://aka.ms/devicelogin and enter the code GUXXXXV9 to authenticate.
然後輸入他提供的機器碼以及驗證登入
建立資源群組
$ az group create --name sakanaResourceGroupACSK8S --location japanwest
{
"id": "/subscriptions/6a2bdf3b-xxxx-xxxx-xxxx-3371d3401feb/resourceGroups/sakanaResourceGroupACSK8S",
"location": "japanwest",
"managedBy": null,
"name": "sakanaResourceGroupACSK8S",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null
}
$ az group create --name sakanaResourceGroupACR --location japanwest
{
"id": "/subscriptions/6a2bdf3b-xxxx-xxxx-xxxx-3371d3401feb/resourceGroups/sakanaResourceGroupACSK8S",
"location": "japanwest",
"managedBy": null,
"name": "sakanaResourceGroupACR",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null
}
還沒建立容器登錄前, 先觀察容器登錄
使用 az 指令建立容器登錄
$ az acr create --resource-group sakanaResourceGroupACR --name sakanaACR --sku Basic --admin-enable true
Create a new service principal and assign access:
az ad sp create-for-rbac --scopes /subscriptions/6a2bdf3b-xxxx-xxxx-xxxx-3371d3401feb/resourceGroups/sakanaResourceGroupACR/providers/Microsoft.ContainerRegistry/registries/sakanaACR --role Owner --password <password>
Use an existing service principal and assign access:
az role assignment create --scope /subscriptions/6a2bdf3b-xxxx-xxxx-xxxx-3371d3401feb/resourceGroups/sakanaResourceGroupACR/providers/Microsoft.ContainerRegistry/registries/sakanaACR --role Owner --assignee <app-id>
{
"adminUserEnabled": true,
"creationDate": "2018-01-18T02:35:16.660690+00:00",
"id": "/subscriptions/6a2bdf3b-xxxx-xxxx-xxxx-3371d3401feb/resourceGroups/sakanaResourceGroupACR/providers/Microsoft.ContainerRegistry/registries/sakanaACR",
"location": "japanwest",
"loginServer": "sakanaacr.azurecr.io",
"name": "sakanaACR",
"provisioningState": "Succeeded",
"resourceGroup": "sakanaResourceGroupACR",
"sku": {
"name": "Basic",
"tier": "Basic"
},
"status": null,
"storageAccount": null,
"tags": {},
"type": "Microsoft.ContainerRegistry/registries"
}
- --sku 是Azure Container Registry (ACR) 具有多個服務層 (稱為SKU)
- --admin-enable 官方文件上面沒有講得很清楚, 待查詢
再次觀察
登入 Azure Contaier Registry
$ az acr login --name sakanaACR
Login Succeeded
列出 目前的 ACR login server
$ az acr list --resource-group sakanaResourceGroupACR --query "[].{acrLoginServer:loginServer}" --output table
AcrLoginServer
--------------------
sakanaacr.azurecr.io
上面這個sakanaacr.azurecr.io就是等等要 push 的目的地, 也是 ACR-FULL-NAME
上課練習是把 azure-vote-front:redis-v1 放到 ACR 上面, 但是這邊想要試試看別的 image
先觀察 目前的 docker image
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
opensuse latest c98336369400 2 months ago 108MB
$ docker tag opensuse sakanaacr.azurecr.io/opensuse
再次觀察
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
opensuse latest c98336369400 2 months ago 108MB
sakanaacr.azurecr.io/opensuse latest c98336369400 2 months ago 108MB
還沒有 push 之前去觀察剛剛 sakanaACR 的 Repositories
Push image 到 Azure Container Register
$ docker push sakanaacr.azurecr.io/opensuse
The push refers to repository [sakanaacr.azurecr.io/opensuse]
3900d76accd7: Pushed
latest: digest: sha256:4571cf6d40391a432e1d653d3a4f384d482c5559abb1f21046a3b803f1fd00bf size: 529
再次在 Azure 上面觀察
:) 以後就多一個放 images 的地點了
使用指令方式列出 ACR 內的 Docker image
$ az acr repository list --name sakanaACR --output table
Result
--------
opensuse
清除實驗資源
刪除 Resource Group
$ az group delete --name sakanaResourceGroupACSK8S
Are you sure you want to perform this operation? (y/n): y
$ az group delete --name sakanaResourceGroupACR
Are you sure you want to perform this operation? (y/n): y
因為把剛剛建立的 Resource Group 刪除, 所以底下的 ACR 還有相關物件也一併刪除
Reference:
之後 Docker image registry 又多一個選擇了
~ enjoy it
沒有留言:
張貼留言