「マイクロソフト系技術情報 Wiki」は、「Open棟梁Project」,「OSSコンソーシアム .NET開発基盤部会」によって運営されています。
Azure の マネージド Kubernetes(k8s)
朱書きはリスタート手順
Kubernetesのアーキテクチャに追加されたアーキテクチャ。
AKSのコンテナ・レジストリは、Azure Container Registry (ACR)と言う。
>az aks install-cli
>set PATH=%PATH%;C:\Users\nishi\.azure-kubectl
>kubectl version Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.8", ...
>git clone https://github.com/Azure-Samples/azure-voting-app-redis.git cd azure-voting-app-redis
>docker-compose up -d
>docker-compose down
コンテナ・レジストリ ≒ Azure Container Registry (ACR)
>az login You have logged in. Now let us find all the subscriptions to which you have access...
>az account list {...json...}
>az account set -s <subscription id>
>az account show {...json...}
>az group create --name daisukenishino --location japaneast {...json...}
>az acr create --resource-group daisukenishino --name daisukenishinoacr --sku basic {...json...}
>az acr login -n daisukenishinoacr Login Succeeded
>az acr list --resource-group daisukenishino --query "[].{acrLoginServer:loginServer}" --output table AcrLoginServer ---------------------------- daisukenishinoacr.azurecr.io
>docker images REPOSITORY TAG IMAGE ID CREATED SIZE azure-vote-front latest 63465cde7b05 7 days ago 965MB
>docker tag azure-vote-front daisukenishinoacr.azurecr.io/azure-vote-front:v1
>docker push daisukenishinoacr.azurecr.io/azure-vote-front:v1 The push refers to repository [daisukenishinoacr.azurecr.io/azure-vote-front] ...
>az acr repository list --name daisukenishinoacr --output table Result ---------------- azure-vote-front
>az acr repository show-tags --name daisukenishinoacr --repository azure-vote-front --output table Result -------- v1
>az ad sp create-for-rbac --skip-assignment { "appId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "displayName": "azure-cli-2019-12-12-08-08-32", "name": "http://azure-cli-2019-12-12-08-08-32", "password": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "tenant": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" }
>az ad sp list > sp_list.txt
>az ad sp delete --id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Removing role assignments
>az acr show --resource-group daisukenishino --name daisukenishinoacr --query "id" --output tsv /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/daisukenishino/providers/Microsoft.ContainerRegistry/registries/daisukenishinoacr
>az role assignment create --assignee "<appId>" --scope "<acrId>" --role acrpull {...json...}
>az aks create --resource-group daisukenishino --name daisukenishinoaks --node-count 2 --service-principal "<appId>" --client-secret "<password>" --generate-ssh-keys SSH key files 'C:\Users\nishi\.ssh\id_rsa' and 'C:\Users\nishi\.ssh\id_rsa.pub' have been generated under ~/.ssh to allow SSH access to the VM. If using machines without permanent storage like Azure Cloud Shell without an attached file share, back up your keys to a safe location {...json...}
>az aks get-credentials --resource-group daisukenishino --name daisukenishinoaks Merged "daisukenishinoaks" as current context in C:\Users\nishi\.kube\config
>kubectl get nodes NAME STATUS ROLES AGE VERSION aks-nodepool1-nnnnnnnn-vmss000000 Ready agent 21m v1.13.12 aks-nodepool1-nnnnnnnn-vmss000001 Ready agent 21m v1.13.12
>kubectl get nodes -o wide NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME ...
>kubectl describe node <NodeName> ...
>kubectl version Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.8", ...} Server Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.12", ...}
>kubectl cluster-info Kubernetes master is running at https://... CoreDNS is running at https://... kubernetes-dashboard is running at https://... Metrics-server is running at https://... To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
>kubectl config get-contexts
>kubectl get namespaces NAME STATUS AGE default Active 37m kube-public Active 37m kube-system Active 37m
>kubectl get services -o wide NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 41m <none>
>kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard
>az aks browse --resource-group daisukenishino --name daisukenishinoaks Merged "daisukenishinoaks" as current context in C:\Users\nishi\AppData\Local\Temp\xxxxxxxxxxx Proxy running on http://127.0.0.1:8001/ Press CTRL+C to close the tunnel... バッチ ジョブを終了しますか (Y/N)? Y >
containers: - name: azure-vote-front image: microsoft/azure-vote-front:v1
containers: - name: azure-vote-front image: daisukenishinoacr.azurecr.io/azure-vote-front:v1
>kubectl apply -f azure-vote-all-in-one-redis.yaml deployment.apps/azure-vote-back created service/azure-vote-back created deployment.apps/azure-vote-front created service/azure-vote-front created
>kubectl get service azure-vote-front --watch NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE azure-vote-front LoadBalancer 10.0.121.183 <pending> 80:31338/TCP 50s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE azure-vote-front LoadBalancer 10.0.121.183 xxx.xxx.xxx.xxx 80:31338/TCP 50s
>kubectl get deployments -o wide NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR azure-vote-back 1/1 1 1 8m13s azure-vote-back redis app=azure-vote-back azure-vote-front 1/1 1 1 8m13s azure-vote-front daisukenishinoacr.azurecr.io/azure-vote-front:v1 app=azure-vote-front
>kubectl describe deployment azure-vote-front
>kubectl describe replicaset azure-vote-front-xnnnnnnx
>kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES azure-vote-back-xxxxxxxxxx-xxxxx ... azure-vote-front-xxxxxxxxxx-xxxxx ...
>kubectl describe pods <PodName>
>kubectl get services -o wide NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR azure-vote-back ClusterIP 10.0.36.57 <none> 6379/TCP 18m app=azure-vote-back azure-vote-front LoadBalancer 10.0.121.183 xxx.xxx.xxx.xxx 80:31338/TCP 18m app=azure-vote-front kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 18h <none>
>kubectl describe service azure-vote-front ...バック
>kubectl describe service azure-vote-back ...
>kubectl get pods NAME READY STATUS RESTARTS AGE ... ... ... ... ...
>kubectl scale --replicas=5 deployment/azure-vote-front deployment.extensions/azure-vote-front scaled
>kubectl get deployments -l app=azure-vote-front NAME READY UP-TO-DATE AVAILABLE AGE azure-vote-front 5/5 5 5 72m
>kubectl get replicasets -l app=azure-vote-front NAME DESIRED CURRENT READY AGE azure-vote-front-64b548d9cf 5 5 5 72m
>kubectl get pods NAME READY STATUS RESTARTS AGE ... ... ... ... ...
>kubectl get pods -l app=azure-vote-front -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES azure-vote-front-xxxxxxxxxx-xxxxx ...
>kubectl describe node aks-nodepooln-...
>kubectl describe service azure-vote-front
>kubectl scale --replicas=1 deployment/azure-vote-front deployment.extensions/azure-vote-front scaled
>kubectl get pods NAME READY STATUS RESTARTS AGE azure-vote-back-xxxxxxxxxx-xxxxx 1/1 Running 0 81m azure-vote-front-xxxxxxxxxx-xxxxx 1/1 Running 0 81m
>kubectl autoscale deployment azure-vote-front --cpu-percent=50 --min=3 --max=10 horizontalpodautoscaler.autoscaling/azure-vote-front autoscaled
>kubectl get hpa --watch NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE azure-vote-front Deployment/azure-vote-front 0%/50% 3 10 3 5m29s
>kubectl get pods NAME READY STATUS RESTARTS AGE azure-vote-back-xxxxxxxxxx-xxxxx 1/1 Running 0 90m azure-vote-front-xxxxxxxxxx-xxxxx 1/1 Running 0 5m34s azure-vote-front-xxxxxxxxxx-xxxxx 1/1 Running 0 5m34s azure-vote-front-xxxxxxxxxx-xxxxx 1/1 Running 0 90m
ポッドが増えた場合、ノードが不足するので、ノードを追加する必要がある。
>az aks scale --resource-group daisukenishino --name daisukenishinoaks --node-count 3 {...json...}
>kubectl get nodes NAME STATUS ROLES AGE VERSION aks-nodepool1-nnnnnnnn-vmss000000 Ready agent 21h v1.13.12 aks-nodepool1-nnnnnnnn-vmss000001 Ready agent 21h v1.13.12 aks-nodepool1-nnnnnnnn-vmss000002 Ready agent 3m54s v1.13.12
>kubectl get pods -o wide --watch
>kubectl run -i --tty load-generator --image=busybox /bin/sh kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead. If you don't see a command prompt, try pressing enter. / # while true; do wget -q -O- http://xxx.xxx.xxx.xxx/; done ...ココで負荷テストが実行される。... ...終了するには「ctrl+c」を押下する。... / # exit Session ended, resume using 'kubectl attach load-generator-xxxxxxxxxx-xxxxx -c load-generator -i -t' command when the pod is running >kubectl attach load-generator-xxxxxxxxxx-xxxxx -c load-generator -i -t If you don't see a command prompt, try pressing enter. / #
>kubectl delete deployments load-generator deployment.extensions "load-generator" deleted
>docker-compose up --build -d
>docker-compose up -d
>docker tag azure-vote-front daisukenishinoacr.azurecr.io/azure-vote-front:v2
>az acr login -n daisukenishinoacr Login Succeeded >docker push daisukenishinoacr.azurecr.io/azure-vote-front:v2 The push refers to repository [daisukenishinoacr.azurecr.io/azure-vote-front] ...
>az acr repository show-tags --name daisukenishinoacr --repository azure-vote-front --output table Result -------- v1 v2
>kubectl get pods -o wide --watch
>kubectl set image deployment azure-vote-front azure-vote-front=daisukenishinoacr.azurecr.io/azure-vote-front:v2
>kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES azure-vote-back-xxxxxxxxxx-xxxxx 1/1 Running 0 3h59m 10.244.1.3 aks-nodepool1-nnnnnnnn-vmss000000 <none> <none> azure-vote-front-xxxxxxxxxx-xxxxx 1/1 Running 0 6m1s 10.244.1.13 aks-nodepool1-nnnnnnnn-vmss000000 <none> <none> azure-vote-front-xxxxxxxxxx-xxxxx 1/1 Running 0 6m8s 10.244.2.3 aks-nodepool1-nnnnnnnn-vmss000002 <none> <none> azure-vote-front-xxxxxxxxxx-xxxxx 1/1 Running 0 6m8s 10.244.2.2 aks-nodepool1-nnnnnnnn-vmss000002 <none> <none>
>kubectl get service azure-vote-front NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE azure-vote-front LoadBalancer 10.0.121.183 xxx.xxx.xxx.xxx 80:31338/TCP 4h28m
>kubectl get replicasets -o wide -l app=azure-vote-front NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR azure-vote-front-xxxxxxxxxx 0 0 0 4h17m azure-vote-front daisukenishinoacr.azurecr.io/azure-vote-front:v1 app=azure-vote-front,pod-template-hash=xxxxxxxxxx azure-vote-front-yyyyyyyyyy 3 3 3 23m azure-vote-front daisukenishinoacr.azurecr.io/azure-vote-front:v2 app=azure-vote-front,pod-template-hash=yyyyyyyyyy
>kubectl describe deployments azure-vote-front Events: Type Reason Age From Message ---- ------ ---- ---- ------- v1のReplicaSetのpodがdown v2のReplicaSetのpodがup ... みたいなログが出る。
>kubectl describe deploy ... RollingUpdateStrategy: 1 max unavailable, 1 max surge ...
>az aks get-upgrades --resource-group daisukenishino --name daisukenishinoaks { "agentPoolProfiles": null, "controlPlaneProfile": { "kubernetesVersion": "1.13.12", "name": null, "osType": "Linux", "upgrades": [ { "isPreview": null, "kubernetesVersion": "1.14.7" }, { "isPreview": null, "kubernetesVersion": "1.14.8" } ] }, "id": "", "name": "default", "resourceGroup": "daisukenishino", "type": "Microsoft.ContainerService/managedClusters/upgradeprofiles" }
>az aks upgrade --resource-group daisukenishino --name daisukenishinoaks --kubernetes-version 1.14.7 Kubernetes may be unavailable during cluster upgrades. Are you sure you want to perform this operation? (y/n): y Since control-plane-only argument is not specified, this will upgrade the control plane AND all nodepools to version 1.14.7. Continue? (y/N): y {...json...}
>az aks get-upgrades --resource-group daisukenishino --name daisukenishinoaks { "agentPoolProfiles": null, "controlPlaneProfile": { "kubernetesVersion": "1.14.7", "name": null, "osType": "Linux", "upgrades": [ { "isPreview": null, "kubernetesVersion": "1.14.8" }, { "isPreview": true, "kubernetesVersion": "1.15.4" }, { "isPreview": true, "kubernetesVersion": "1.15.5" } ] }, "id": "", "name": "default", "resourceGroup": "daisukenishino", "type": "Microsoft.ContainerService/managedClusters/upgradeprofiles" }
>kubectl get service azure-vote-front NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE azure-vote-front LoadBalancer 10.0.121.183 xxx.xxx.xxx.xxx 80:31338/TCP 4h28m
>az group delete --name daisukenishino --yes --no-wait
MC_ResourceGroupName_AKSName_AzureLocationName
先ずは、ストレージとして、永続ボリュームを作成する。
(非永続ボリュームの確認は、Qiitaの記事の手順を確認するだけに留める)
kind: StorageClass apiVersion: storage.k8s.io/v1beta1 metadata: name: azure-disk provisioner: kubernetes.io/azure-disk parameters: storageaccounttype: Premium_LRS kind: Managed --- kind: PersistentVolumeClaim apiVersion: v1 metadata: name: mssql-data annotations: volume.beta.kubernetes.io/storage-class: azure-disk spec: accessModes: - ReadWriteOnce resources: requests: storage: 8Gi
>kubectl apply -f mssql-storage.yaml storageclass.storage.k8s.io/azure-disk created persistentvolumeclaim/mssql-data created
>kubectl get pv
>kubectl get sc -o wide NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE pvc-... 8Gi RWO Delete Bound default/mssql-data azure-disk 15s
>kubectl get pvc NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE mssql-data Bound pvc-... 8Gi RWO azure-disk 2m9s
>kubectl describe pvc mssql-data ...
>kubectl delete pvc mssql-data persistentvolumeclaim "mssql-data" deleted
>kubectl get pv No resources found.
>kubectl apply -f mssql-storage.yaml storageclass.storage.k8s.io/azure-disk unchanged persistentvolumeclaim/mssql-data created
>kubectl get pv --watch ...
シークレットの作成や SQL Server 2017 の配置
>kubectl create secret generic mssql --from-literal=SA_PASSWORD="xxxxx" secret/mssql created
>kubectl get secret mssql -o yaml ...yaml...
apiVersion: apps/v1beta1 kind: Deployment metadata: name: mssql-deployment spec: replicas: 1 template: metadata: labels: app: mssql spec: terminationGracePeriodSeconds: 10 containers: - name: mssql image: mcr.microsoft.com/mssql/server:2017-latest ports: - containerPort: 1433 env: - name: MSSQL_PID value: "Developer" - name: ACCEPT_EULA value: "Y" - name: MSSQL_SA_PASSWORD valueFrom: secretKeyRef: name: mssql key: SA_PASSWORD volumeMounts: - name: mssqldb mountPath: /var/opt/mssql volumes: - name: mssqldb persistentVolumeClaim: claimName: mssql-data --- apiVersion: v1 kind: Service metadata: name: mssql-deployment spec: selector: app: mssql ports: - protocol: TCP port: 1433 targetPort: 1433 type: LoadBalancer
>kubectl apply -f sqldeployment.yaml deployment.apps/mssql-deployment created service/mssql-deployment created
>kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 31m mssql-deployment LoadBalancer 10.0.148.142 xxx.xxx.xxx.xxx 1433:xxxxx/TCP 18s
>kubectl get pods --watch NAME READY STATUS RESTARTS AGE mssql-deployment-xxxxxxxxxx-xxxxx 1/1 Running 0 3m33s
>sqlcmd -S <External IP Address> -U SA -P "xxxxxxx"
>kubectl get pods NAME READY STATUS RESTARTS AGE mssql-deployment-xxxxxxxxxx-xxxxx 1/1 Running 0 23m
>kubectl delete pod mssql-deployment-xxxxxxxxxx-xxxxx pod "mssql-deployment-xxxxxxxxxx-xxxxx" deleted
>kubectl get pods --watch NAME READY STATUS RESTARTS AGE mssql-deployment-yyyyyyyyyy-yyyyy 1/1 Running 0 3m33s
>kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES mssql-deployment-yyyyyyyyyy-yyyyy 1/1 Running 0 5m45s 10.244.1.4 aks-nodepool1-nnnnnnnn-vmss000001 <none> <none>
>kubectl drain aks-nodepool1-nnnnnnnn-vmss000001 --ignore-daemonsets --delete-local-data node/aks-nodepool1-nnnnnnnn-vmss000001 cordoned WARNING: ignoring DaemonSet-managed Pods: kube-system/kube-proxy-xxxxx evicting pod "coredns-xxxxxxxxxx-xxxxx" pod/coredns-xxxxxxxxxx-xxxxx evicted node/aks-nodepool1-nnnnnnnn-vmss000001 evicted
>kubectl get nodes NAME STATUS ROLES AGE VERSION aks-nodepool1-nnnnnnnn-vmss000000 Ready agent 91m v1.14.8 aks-nodepool1-nnnnnnnn-vmss000001 Ready,SchedulingDisabled agent 91m v1.14.8
>kubectl delete pod mssql-deployment-yyyyyyyyyy-yyyyy
>kubectl get pods -o wide --watch NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES mssql-deployment-zzzzzzzzzz-zzzzz 1/1 Running 0 2m53s 10.244.1.4 aks-nodepool1-nnnnnnnn-vmss000000 <none> <none>
>kubectl uncordon aks-nodepool1-nnnnnnnn-vmss000001 node/aks-nodepool1-nnnnnnnn-vmss000001 uncordoned
>az group delete --name daisukenishino --yes --no-wait
kind: StorageClass apiVersion: storage.k8s.io/v1beta1 metadata: name: azure-disk provisioner: kubernetes.io/azure-disk parameters: storageaccounttype: Premium_LRS kind: Managed --- kind: PersistentVolumeClaim apiVersion: v1 metadata: name: mssql-data annotations: volume.beta.kubernetes.io/storage-class: azure-disk spec: accessModes: - ReadWriteOnce resources: requests: storage: 8Gi --- apiVersion: v1 kind: Secret metadata: name: mssql type: Opaque data: SA_PASSWORD: "TXlDMG05bCZ4UEBzc3cwcmQ=" --- apiVersion: apps/v1beta1 kind: Deployment metadata: name: mssql-deployment spec: replicas: 1 template: metadata: labels: app: mssql spec: terminationGracePeriodSeconds: 10 containers: - name: mssql image: mcr.microsoft.com/mssql/server:2017-latest ports: - containerPort: 1433 env: - name: MSSQL_PID value: "Developer" - name: ACCEPT_EULA value: "Y" - name: MSSQL_SA_PASSWORD valueFrom: secretKeyRef: name: mssql key: SA_PASSWORD volumeMounts: - name: mssqldb mountPath: /var/opt/mssql volumes: - name: mssqldb persistentVolumeClaim: claimName: mssql-data --- apiVersion: v1 kind: Service metadata: name: mssql-deployment spec: selector: app: mssql ports: - protocol: TCP port: 1433 targetPort: 1433 type: LoadBalancer
>kubectl apply -f sql2017.yaml
>kubectl get service --watch NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 4h26m mssql-deployment LoadBalancer 10.0.100.250 52.156.45.201 1433:30117/TCP 4h19m
>kubectl apply -f sql2017.yaml --force storageclass.storage.k8s.io/azure-disk unchanged persistentvolumeclaim/mssql-data unchanged secret/mssql unchanged deployment.apps/mssql-deployment unchanged service/mssql-deployment configured
>kubectl get service --watch NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 4h27m mssql-deployment ClusterIP 10.0.254.191 <none> 1433/TCP 6s
services.AddDistributedRedisCache(option => { option.Configuration = "webapplication1-back"; option.InstanceName = "redis"; });
>az acr update -n daisukenishinoacr --admin-enabled true {...json...}
>docker images REPOSITORY TAG IMAGE ID CREATED SIZE daisukenishinoacr.azurecr.io:443/webapplication1 latest f8253a6af02f 17 minutes ago 354MBwebapplication1 latest f8253a6af02f 17 minutes ago 354MB
>az acr repository list --name daisukenishinoacr --output table Result --------------- webapplication1Tag
>az acr repository show-tags --name daisukenishinoacr --repository webapplication1 --output table Result -------- latest
>docker rmi <IMAGE ID> -f
>az acr repository delete --name daisukenishinoacr --image webapplication1:latest This operation will delete the manifest 'sha256:3ebc46eb04906582a80aaa89edde8611eefece5af2518756cf451db74223825e' and all the following images: 'webapplication1:latest'. Are you sure you want to continue? (y/n): y
>docker images REPOSITORY TAG IMAGE ID CREATED SIZE daisukenishinoacr.azurecr.io:443/webapplication1 yyyymmddhhmmss a41aed558746 42 seconds ago 354MB webapplication1 latest a41aed558746 42 seconds ago 354MB
>az acr repository list --name daisukenishinoacr --output table Result --------------- webapplication1Tag
>az acr repository show-tags --name daisukenishinoacr --repository webapplication1 --output table Result -------- yyyymmddhhmmss
apiVersion: apps/v1beta1 kind: Deployment metadata: name: webapplication1-back spec: replicas: 1 template: metadata: labels: app: webapplication1-back spec: nodeSelector: "beta.kubernetes.io/os": linux containers: - name: webapplication1-back image: redis ports: - containerPort: 6379 name: redis --- apiVersion: v1 kind: Service metadata: name: webapplication1-back spec: ports: - port: 6379 selector: app: webapplication1-back ---
apiVersion: apps/v1 kind: Deployment metadata: name: webapplication1 namespace: default labels: app: webapplication1 spec: replicas: 1 selector: matchLabels: app: webapplication1 template: metadata: name: webapplication1 labels: app: webapplication1 spec: containers: - name: webapplication1 image: daisukenishinoacr.azurecr.io/webapplication1:<Tag> resources: requests: cpu: "250m" memory: "512Mi" limits: cpu: "500m" memory: "1Gi" imagePullPolicy: Always restartPolicy: Always terminationGracePeriodSeconds: 30 --- apiVersion: v1 kind: Service metadata: name: webapplication1 labels: app: webapplication1 spec: type: LoadBalancer ports: - protocol: TCP port: 80 selector: app: webapplication1
>kubectl apply -f webapplication1.yaml
>kubectl get service --watch
>az acr repository show-tags --name daisukenishinoacr --repository webapplication1 --output table Result -------- yyyymmddhhmmss
image: daisukenishinoacr.azurecr.io/webapplication1:<Tag>
image: daisukenishinoacr.azurecr.io/webapplication1:yyyymmddhhmmss
>kubectl apply -f webapplication1.yaml --force
>az aks enable-addons --resource-group daisukenishino --name daisukenishinoacr --addons http_application_routing
>az aks show --resource-group daisukenishino --name daisukenishinoacr --query addonProfiles.httpApplicationRouting.config.HTTPApplicationRoutingZoneName -o table Result ---------------------------------------- xxxxxxxxxxxxxxxxxxxx.japaneast.aksapp.io
>kubectrl apply -f webapplication1.yaml --force
>kubectl get svc
>kubectl get ingress
>kubectrl apply -f webapplication1.yaml --force
おいおいヤる予
おいおいヤる予
おいおいヤる予
おいおいヤる予
おいおいヤる予
上記のMicrosoft Docsのチュートリアルの深堀しているQiita記事(MS社員)。
https://tech-lab.sios.jp/archives/category/azure/