Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```
- REGION=westeurope
- RG_NAME=akschallenge
- az group create --name $RG_NAME --location $REGION
- az resource create \
- --resource-group $RG_NAME \
- --resource-type "Microsoft.Insights/components" \
- --name $RG_NAME \
- --location $REGION \
- --properties '{"Application_Type":"web"}'
- APP_INSIGHTS_KEY=$(az resource show -g $RG_NAME -n $RG_NAME --resource-type "Microsoft.Insights/components" --query properties.InstrumentationKey --output tsv)
- version=$(az aks get-versions -l $REGION --query 'orchestrators[-1].orchestratorVersion' -o tsv)
- az group create --name $RG_NAME --location $REGION
- AKS_NAME=aksworkshop-$RANDOM
- az extension add --name aks-preview
- az feature register --name VMSSPreview --namespace Microsoft.ContainerService
- az provider register --namespace Microsoft.ContainerService
- az feature list -o table --query "[?contains(name, 'Microsoft.ContainerService/VMSSPreview')].{Name:name,State:properties.state}"
- az aks create --resource-group $RG_NAME \
- --name $AKS_NAME \
- --location $REGION \
- --enable-addons monitoring,http_application_routing \
- --kubernetes-version $version \
- --generate-ssh-keys \
- --enable-vmss \
- --enable-cluster-autoscaler \
- --min-count 1 \
- --max-count 3
- AKS_NAME=$(az aks list --query [].name --output tsv)
- az aks get-credentials --resource-group $RG_NAME --name $AKS_NAME
- kubectl apply -f https://aksworkshop.io/yaml-solutions/01.%20challenge-02/helm-rbac.yaml
- helm init --service-account tiller
- kubectl get pod -n kube-system -l name=tiller --watch
- helm install stable/mongodb --name orders-mongo --set mongodbUsername=orders-user,mongodbPassword=orders-password,mongodbDatabase=akschallenge
- kubectl get pods --watch
- TEAMNAME=LucyInTheSkyWithDiamonds
- CHALLENGEAPPINSIGHTS_KEY=$APP_INSIGHTS_KEY
- MONGOHOST=$RG_NAME
- MONGOUSER=orders-user
- MONGOPASSWORD=orders-password
- kubectl create secret generic mongodb --from-literal=mongoHost="orders-mongo-mongodb.default.svc.cluster.local" --from-literal=mongoUser="orders-user" --from-literal=mongoPassword="orders-password"
- kubectl apply -f https://aksworkshop.io/yaml-solutions/01.%20challenge-02/captureorder-deployment.yaml
- kubectl get pods -l app=captureorder --watch
- kubectl apply -f https://aksworkshop.io/yaml-solutions/01.%20challenge-02/captureorder-service.yaml
- while : ; do
- IP=$(kubectl get service captureorder -o jsonpath="{.status.loadBalancer.ingress[*].ip}")
- [ -z "$IP" ] || break
- done
- curl -d '{"EmailAddress": "email@domain.com", "Product": "prod-1", "Total": 100}' -H "Content-Type: application/json" -X POST http://$IP/v1/order
- # This is the quicker way to update the templated yaml
- curl -s https://aksworkshop.io/yaml-solutions/01.%20challenge-02/frontend-deployment.yaml | sed "s/_PUBLIC_IP_CAPTUREORDERSERVICE_/$IP/g" | kubectl apply -f -
- kubectl get pods -l app=frontend --watch
- # More on Http Application Routing: https://docs.microsoft.com/en-us/azure/aks/http-application-routing?wt.mc_id=aksworkshop
- # This is going to take some minutes
- az aks enable-addons --resource-group $RG_NAME --name $AKS_NAME --addons http_application_routing
- kubectl apply -f https://aksworkshop.io/yaml-solutions/01.%20challenge-02/frontend-service.yaml
- AKS_DNS=$(az aks show --resource-group $RG_NAME --name $AKS_NAME --query addonProfiles.httpApplicationRouting.config.HTTPApplicationRoutingZoneName -o tsv)
- curl -s https://aksworkshop.io/yaml-solutions/01.%20challenge-02/frontend-ingress.yaml | sed "s/_CLUSTER_SPECIFIC_DNS_ZONE_/$AKS_DNS/g" | kubectl apply -f -
- # You will need to wait a few minutes until you get the response
- kubectl logs -f deploy/addon-http-application-routing-external-dns -n kube-system
- # Now open http://frontend.$AKS_DNS
- curl -s https://aksworkshop.io/yaml-solutions/01.%20challenge-03/logreader-rbac.yaml | kubectl apply -f -
- # this is going to take some time to start
- az container create -g $RG_NAME -n loadtest --image azch/loadtest --restart-policy Never -e SERVICE_IP=$IP
- az container logs -g $RG_NAME -n loadtest --follow
- az container delete -g $RG_NAME -n loadtest
- # Remove explicit number of replicas from deployment (for autoscaling)
- # kubectl patch deploy captureorder -p '{"op" : "remove", "path" : "/spec/replicas"}'
- wget https://aksworkshop.io/yaml-solutions/01.%20challenge-02/captureorder-deployment.yaml
- code captureorder-deployment.yaml
- # Edit the line containing `replicas: 2`
- kubectl apply -f captureorder-deployment.yaml
- ...
- kubectl apply -f https://aksworkshop.io/yaml-solutions/01.%20challenge-04/captureorder-hpa.yaml
- # This will take some time!
- az container create -g $RG_NAME -n loadtest --image azch/loadtest --restart-policy Never -e SERVICE_IP=$IP
- kubectl get pods -l app=captureorder --watch
- az container logs -g $RG_NAME -n loadtest --follow
- az aks update \
- --resource-group $RG_NAME \
- --name $AKS_NAME \
- --update-cluster-autoscaler \
- --min-count 1 \
- --max-count 5
- REGION=westeurope
- REGISTRY_NAME=aksworkshopreg$RANDOM
- az acr create --resource-group $RG_NAME --name $REGISTRY_NAME --sku Standard --location $REGION
- REGISTRY_SERVER=$(az acr show -n $REGISTRY_NAME --query loginServer --output tsv)
- git clone https://github.com/Azure/azch-captureorder.git && cd azch-captureorder
- az acr build -t "captureorder:{{.Run.ID}}" -r $REGISTRY_NAME .
- IMAGE_NAME=$REGISTRY_SERVER/captureorder:$(az acr repository show-tags -n $REGISTRY_NAME --repository captureorder --query [0] --output tsv)
- # Assign permission to AKS service principal to pull from ACR
- CLIENT_ID=$(az aks show --resource-group $RG_NAME --name $AKS_NAME --query "servicePrincipalProfile.clientId" --output tsv)
- ACR_ID=$(az acr show --name $REGISTRY_NAME --resource-group $RG_NAME --query "id" --output tsv)
- az role assignment create --assignee $CLIENT_ID --role acrpull --scope $ACR_ID
- # Alternative: activate admin user
- # az acr update -n $REGISTRY_NAME --admin-enabled true
- # REGISTRY_SERVER=$(az acr show -n $REGISTRY_NAME --query loginServer)
- # REGISTRY_USERNAME=$(az acr credential show --name $REGISTRY_NAME --query username --output tsv)
- # REGISTRY_PASS=$(az acr credential show --name $REGISTRY_NAME --query passwords[0].value --output tsv)
- # kubectl create secret docker-registry acr-auth --docker-server $REGISTRY_SERVER --docker-username $REGISTRY_USERNAME --docker-password $REGISTRY_PASS
- # now you need to update the deployment:
- #```
- #spec:
- # imagePullSecrets:
- # - name: acr-auth
- # containers:
- #```
- # Patch the new image
- CONTAINER_NAME=$(kubectl get pods -l app=captureorder -o jsonpath={.items[*].spec.containers[*].name})
- kubectl set image deployments captureorder $CONTAINER_NAME=$IMAGE_NAME
- kubectl get deployments captureorder -o wide --watch
- kubectl get deployment captureorder -ojsonpath='{$.spec.template.spec.containers[:1].image}'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement