-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstruction.txt
More file actions
91 lines (78 loc) · 3.26 KB
/
instruction.txt
File metadata and controls
91 lines (78 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#instructions to manually provision and run application
#git repo used in project git clone https://github.com/Azure-Samples/azure-voting-app-redis.git
#in directory made from repo run
docker-compose up -d
to create containers and start application
docker images shows created images
docker ps shows running containers
docker-compose down stops containers
#create azure resource group
az group create --name $GROUPNAME --location eastus
#create azure container registry
az acr create --resource-group $GROUPNAME --name $ACRNAME --sku Basic
#login to acr
az acr login --name $ACRNAME
#find acr login server
az acr list --resource-group $GROUPNAME --query "[].{acrLoginServer:loginServer}" --output table
#tag image
docker tag azure-vote-front $LOGINSERVER/azure-vote-front:v1
#push image to acr (make sure you are logged in to acr or else unauthorized error)
docker push $LOGINSERVER/azure-vote-front:v1
#get list of images in acr
az acr repository list --name $ACRNAME --output table
#get tags for acr image
az acr repository show-tags --name $ACRNAME --repository azure-vote-front --output table
#create active directory service principal for AKS cluster to interact with Azure resources
az ad sp create-for-rbac --skip-assignment (returns appID,displayName,name,password,tenant)
#get acr resource id $ACRID
az acr show --resource-group $GROUPNAME --name $ACRNAME --query "id" --output tsv
#create role for aks to use acr images
az role assignment create --assignee $APPID --scope $ACRID --role Reader
#create AKS cluster
az aks create \
--resource-group $GROUPNAME \
--name $CLUSTERNAME \
--node-count 1 \
--service-principal $APPID \
--client-secret $ADPASS \
--generate-ssh-keys
#cli for kubernetes (kubectl)
az aks install-cli
#configure kubectl
az aks get-credentials --resource-group $GROUPNAME --name $CLUSTERNAME
#show nodes
kubectl get nodes
#don't forget to make changes to .yaml for to use acr for azure-vote-front
#deploy application
kubectl apply -f azure-vote-all-in-one-redis.yaml
#monitor deployment
kubectl get service azure-vote-front --watch
#scalling
#manual
kubectl scale --replicas=5 deployment/azure-vote-front
#autoscale first get aks cluster version
az aks show --resource-group $GROUPNAME --name $CLUSTERNAME --query kubernetesVersion
#if aks cluster version is less than 1.10
git clone https://github.com/kubernetes-incubator/metrics-server.git
kubectl create -f metrics-server/deploy/1.8+/
#set autoscale
kubectl autoscale deployment azure-vote-front --cpu-percent=50 --min=3 --max=10
#update application
#build another image
docker-compose up --build -d
#tag new name
docker tag azure-vote-front $LOGINSERVER/azure-vote-front:<newTag>
#push new image
docker push $LOGINSERVER/azure-vote-front:<newTag>
#to provide maxium uptime need multiple front end instances
kubectl scale --replicas=3 deployment/azure-vote-front
kubectl set image deployment azure-vote-front azure-vote-front=$LOGINSERVER/azure-vote-front:<newTag>
#track progress
kubectl get pods
#update AKS cluster
#check for AKS upgrades
az aks get-upgrades --resource-group $GROUPNAME --name $CLUSTERNAME --output table
#upgrade cluster
az aks upgrade --resource-group $GROUPNAME --name $CLUSTERNAME --kubernetes-version 1.10.9
#delete everything
az group delete --name $GROUPNAME --yes --no-wait