Info |
---|
사전 조건 (참조: https://docs.microsoft.com/ko-kr/azure/aks/kubernetes-walkthrough)
|
Code Block | ||
---|---|---|
| ||
## Microsoft 리포지토리 키를 가져옵니다. [root@workspace-vm ~]# sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc [root@workspace-vm deploy~]# cd ~/ ## 로컬 azure-cli 리포지토리 정보를 만듭니다. [root@workspace-vm ~]# sudo sh -c 'echo -e "[azure-cli]\nname=Azure CLI\nbaseurl=https://packages.microsoft.com/yumrepos/azure-cli\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/azure-cli.repo' [root@workspace-vm ~]# ## azure-cli를 설치 합니다. [root@workspace-vm ~]# sudo yum install azure-cli Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile |
Code Block |
---|
## Azure에 로그인 합니다. [root@workspace-vm ~]# az login To sign in, use a web browser to open the page curl -L https://akamicrosoft.ms/InstallAzureCli | bashcom/devicelogin and enter the code HT3WTWGFJ to authenticate. [ %{ Total % Received % Xferd Average Speed Time Time Time Current"cloudName": "AzureCloud", "id": "c6c1cb6d-3a2b-4912-xxxx-xxxxxxxxxx", "isDefault": false, "name": "종량제", "state": "Disabled", "tenantId": "075f7662-60f9-46bb-xxxx-xxxxxxxxxx", "user": { "name": "sooabia22@mycompany.co.kr", "type": "user" } }, { Dload Upload "cloudName": "AzureCloud", Total Spent "id": "24ebf866-0c20-435b-xxxx-xxxxxxxxxx", Left Speed"isDefault": true, 0 "name": "Visual Studio 0Enterprise", 0"state": "Enabled", "tenantId": "075f7662-60f9-46bb-xxxx-xxxxxxxxxx", 0 "user": { 0 0 "name": "sooabia22@mycompany.co.kr", 0 "type": "user" 0 --:--:-- --:--:-- --:--:-- 0 100 1369 100 1369 0 0 993 0 0:00:01 0:00:01 --:--:-- 5900 Downloading Azure CLI install script from https://azurecliprod.blob.core.windows.net/install.py to /tmp/azure_cli_install_tmp_FM39Xy. ######################################################################## 100.0% ## 변경 내용을 적용하려면 셸을 다시 시작해야 합니다.} } ] [root@workspace-vm ~]# [root@workspace-vm ~]# az account show { "environmentName": "AzureCloud", "id": "24ebf866-0c20-435b-xxxx-xxxxxxxxxx", "isDefault": true, "name": "Visual Studio Enterprise", "state": "Enabled", "tenantId": "075f7662-60f9-46bb-xxxx-xxxxxxxxxx", "user": { "name": "sooabia22@mycompany.co.kr", "type": "user" } } |
Info |
---|
Azure AKS 생성하기 |
Code Block |
---|
[root@workspace-vm ~]# az aks install-cli
Downloading client to "/usr/local/bin/kubectl" from "https://storage.googleapis.com/kubernetes-release/release/v1.14.1/bin/linux/amd64/kubectl"
Please ensure that /usr/local/bin is in your search PATH, so the `kubectl` command can be found.
[root@workspace-vm ~]# az aks get-credentials --resource-group aks-rg --name sanse-aks
Merged "sanse-aks" as current context in /root/.kube/config
[root@workspace-vm ~]#
[root@workspace-vm ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
aks-agentpool-31134750-0 Ready agent 3h39m v1.12.7
aks-agentpool-31134750-1 Ready agent 3h39m v1.12.7
[root@workspace-vm ~]# |
Code Block | ||
---|---|---|
| ||
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
spec:
selector:
matchLabels:
app: redis
replicas: 1
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis
ports:
- containerPort: 6379
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: reactor-demo
spec:
selector:
matchLabels:
app: reactor-demo
replicas: 3
template:
metadata:
labels:
app: reactor-demo
spec:
containers:
- name: reactor-demo
image: sooabia/reactor-demo:1.0
ports:
- containerPort: 8080
---
kind: Service
apiVersion: v1
metadata:
name: spring-service
spec:
selector:
app: reactor-demo
ports:
- protocol: TCP
port: 80
targetPort: 8080
type: LoadBalancer |
Code Block |
---|
## Azure AKS에 배포하기
[root@workspace-vm deploy]# kubectl apply -f k8s-deploy-aks.yml
deployment.apps/redis-deployment created
deployment.apps/reactor-demo created
service/reactor-service created
service/redis created
[root@workspace-vm deploy]#
[root@workspace-vm deploy]# kubectl get pod
NAME READY STATUS RESTARTS AGE
reactor-demo-8b77f949f-7fpwc 1/1 Running 0 9s
reactor-demo-8b77f949f-8lm8d 1/1 Running 0 9s
reactor-demo-8b77f949f-pltqf 1/1 Running 0 9s
redis-deployment-c899fb5b5-cx8nl 1/1 Running 0 9s
[root@workspace-vm deploy]#
[root@workspace-vm deploy]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 3h46m
reactor-service LoadBalancer 10.0.238.114 <pending> 80:32070/TCP 15s
redis ClusterIP 10.0.3.79 <none> 6379/TCP 14s
[root@workspace-vm deploy]#
[root@workspace-vm deploy]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 3h46m
reactor-service LoadBalancer 10.0.238.114 52.231.28.109 80:32070/TCP 48s
redis ClusterIP 10.0.3.79 <none> 6379/TCP 47s
[root@workspace-vm deploy]# |
Code Block |
---|
## 어플리케이션 호출하기
[root@workspace-vm deploy]# curl -XPOST http://52.231.28.109:80/link -H "Content-Type: application/json" -d '{"link":"http://wiki.iisanse.com"}'
{"shortenedLink":"http://localhost:8080/dXOOvO"} |
Code Block |
---|
## 삭제하기
[root@workspace-vm deploy]# kubectl delete -f k8s-deploy-aks.yml
deployment.apps "redis-deployment" deleted
deployment.apps "reactor-demo" deleted
service "reactor-service" deleted
service "redis" deleted |