You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#Customer intent: As a developer or cluster operator, I want to deploy an AKS cluster and deploy an application so I can see how to run applications using the managed Kubernetes service in Azure.
11
10
---
12
11
13
12
# Quickstart: Deploy an Azure Kubernetes Service (AKS) cluster using Azure CLI
14
13
15
-
Azure Kubernetes Service (AKS) is a managed Kubernetes service that lets you quickly deploy and manage clusters. In this quickstart, you learn to:
14
+
[](https://ms.portal.azure.com/#view/Microsoft_Azure_CloudNative/SubscriptionSelectionPage.ReactView/tutorialKey/CreateAKSDeployment/isLearnMode~/true)
15
+
16
+
Azure Kubernetes Service (AKS) is a managed Kubernetes service that lets you quickly deploy and manage clusters. In this quickstart, you learn how to:
16
17
17
18
- Deploy an AKS cluster using the Azure CLI.
18
19
- Run a sample multi-container application with a group of microservices and web front ends simulating a retail scenario.
@@ -32,74 +33,72 @@ This quickstart assumes a basic understanding of Kubernetes concepts. For more i
32
33
- Make sure that the identity you're using to create your cluster has the appropriate minimum permissions. For more details on access and identity for AKS, see [Access and identity options for Azure Kubernetes Service (AKS)](../concepts-identity.md).
33
34
- If you have multiple Azure subscriptions, select the appropriate subscription ID in which the resources should be billed using the [az account set](/cli/azure/account#az-account-set) command.
34
35
36
+
## Define environment variables
37
+
38
+
Define the following environment variables for use throughout this quickstart:
39
+
40
+
```bash
41
+
export RANDOM_ID="$(openssl rand -hex 3)"
42
+
export SSL_EMAIL_ADDRESS="$(az account show --query user.name --output tsv)"
An [Azure resource group][azure-resource-group] is a logical group in which Azure resources are deployed and managed. When you create a resource group, you're prompted to specify a location. This location is the storage location of your resource group metadata and where your resources run in Azure if you don't specify another region during resource creation.
38
52
39
-
The following example creates a resource group named *myResourceGroup* in the *eastus* location.
53
+
Create a resource group using the [`az group create`][az-group-create] command.
40
54
41
-
Create a resource group using the [az group create][az-group-create] command.
42
-
43
-
```azurecli
44
-
az group create --name myResourceGroup --location eastus
55
+
```azurecli-interactive
56
+
az group create --name $MY_RESOURCE_GROUP_NAME --location $REGION
45
57
```
46
58
47
-
The following sample output resembles successful creation of the resource group:
To create an AKS cluster, use the [az aks create][az-aks-create] command. The following example creates a cluster named *myAKSCluster* with one node and enables a system-assigned managed identity.
65
-
66
-
```azurecli
67
-
az aks create \
68
-
--resource-group myResourceGroup \
69
-
--name myAKSCluster \
70
-
--enable-managed-identity \
71
-
--node-count 1 \
72
-
--generate-ssh-keys
73
-
```
77
+
Create an AKS cluster using the [`az aks create`][az-aks-create] command.
74
78
75
-
After a few minutes, the command completes and returns JSON-formatted information about the cluster.
79
+
```azurecli-interactive
80
+
az aks create --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_AKS_CLUSTER_NAME --enable-managed-identity --node-count 1 --generate-ssh-keys
81
+
```
76
82
77
-
> [!NOTE]
78
-
> When you create a new cluster, AKS automatically creates a second resource group to store the AKS resources. For more information, see [Why are two resource groups created with AKS?](../faq.md#why-are-two-resource-groups-created-with-aks)
83
+
> [!NOTE]
84
+
> When you create a new cluster, AKS automatically creates a second resource group to store the AKS resources. For more information, see [Why are two resource groups created with AKS?](../faq.md#why-are-two-resource-groups-created-with-aks)
79
85
80
86
## Connect to the cluster
81
87
82
-
To manage a Kubernetes cluster, use the Kubernetes command-line client, [kubectl][kubectl]. `kubectl` is already installed if you use Azure Cloud Shell. To install `kubectl` locally, call the [az aks install-cli][az-aks-install-cli] command.
88
+
To manage a Kubernetes cluster, use the Kubernetes command-line client, [kubectl][kubectl]. `kubectl` is already installed if you use Azure Cloud Shell. To install `kubectl` locally, use the [`az aks install-cli`][az-aks-install-cli] command.
83
89
84
90
1. Configure `kubectl` to connect to your Kubernetes cluster using the [az aks get-credentials][az-aks-get-credentials] command. This command downloads credentials and configures the Kubernetes CLI to use them.
85
91
86
-
```azurecli
87
-
az aks get-credentials --resource-group myResourceGroup --name myAKSCluster
92
+
```azurecli-interactive
93
+
az aks get-credentials --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_AKS_CLUSTER_NAME
88
94
```
89
95
90
96
1. Verify the connection to your cluster using the [kubectl get][kubectl-get] command. This command returns a list of the cluster nodes.
91
97
92
-
```azurecli
98
+
```bash
93
99
kubectl get nodes
94
100
```
95
101
96
-
The following sample output shows the single node created in the previous steps. Make sure the node status is *Ready*.
To deploy the application, you use a manifest file to create all the objects required to run the [AKS Store application](https://github.com/Azure-Samples/aks-store-demo). A [Kubernetes manifest file][kubernetes-deployment] defines a cluster's desired state, such as which container images to run. The manifest includes the following Kubernetes deployments and services:
@@ -349,67 +348,75 @@ To deploy the application, you use a manifest file to create all the objects req
349
348
350
349
If you create and save the YAML file locally, then you can upload the manifest file to your default directory in CloudShell by selecting the **Upload/Download files** button and selecting the file from your local file system.
351
350
352
-
1. Deploy the application using the [kubectl apply][kubectl-apply] command and specify the name of your YAML manifest.
351
+
1. Deploy the application using the [`kubectl apply`][kubectl-apply] command and specify the name of your YAML manifest.
353
352
354
-
```azurecli
353
+
```bash
355
354
kubectl apply -f aks-store-quickstart.yaml
356
355
```
357
356
358
-
The following sample output shows the deployments and services:
359
-
360
-
```output
361
-
deployment.apps/rabbitmq created
362
-
service/rabbitmq created
363
-
deployment.apps/order-service created
364
-
service/order-service created
365
-
deployment.apps/product-service created
366
-
service/product-service created
367
-
deployment.apps/store-front created
368
-
service/store-front created
369
-
```
370
-
371
357
## Test the application
372
358
373
-
When the application runs, a Kubernetes service exposes the application front end to the internet. This process can take a few minutes to complete.
374
-
375
-
1. Check the status of the deployed pods using the [kubectl get pods][kubectl-get] command. Make sure all pods are `Running` before proceeding.
376
-
377
-
```console
378
-
kubectl get pods
379
-
```
380
-
381
-
1. Check for a public IP address for the store-front application. Monitor progress using the [kubectl get service][kubectl-get] command with the `--watch` argument.
382
-
383
-
```azurecli
384
-
kubectl get service store-front --watch
385
-
```
386
-
387
-
The **EXTERNAL-IP** output for the `store-front` service initially shows as *pending*:
1. Open a web browser to the external IP address of your service to see the Azure Store app in action.
404
-
405
-
:::image type="content" source="media/quick-kubernetes-deploy-cli/aks-store-application.png" alt-text="Screenshot of AKS Store sample application." lightbox="media/quick-kubernetes-deploy-cli/aks-store-application.png":::
359
+
You can validate that the application is running by visiting the public IP address or the application URL.
360
+
361
+
Get the application URL using the following commands:
362
+
363
+
```bash
364
+
runtime="5 minute"
365
+
endtime=$(date -ud "$runtime" +%s)
366
+
while [[ $(date -u +%s) -le $endtime ]]
367
+
do
368
+
STATUS=$(kubectl get pods -l app=store-front -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}')
369
+
echo $STATUS
370
+
if [ "$STATUS" == 'True' ]
371
+
then
372
+
export IP_ADDRESS=$(kubectl get service store-front --output 'jsonpath={..status.loadBalancer.ingress[0].ip}')
echo "You can now visit your web server at $IP_ADDRESS"
408
+
```
409
+
410
+
:::image type="content" source="media/quick-kubernetes-deploy-cli/aks-store-application.png" alt-text="Screenshot of AKS Store sample application." lightbox="media/quick-kubernetes-deploy-cli/aks-store-application.png":::
406
411
407
412
## Delete the cluster
408
413
409
-
If you don't plan on going through the [AKS tutorial][aks-tutorial], clean up unnecessary resources to avoid Azure charges. Call the [az group delete][az-group-delete] command to remove the resource group, container service, and all related resources.
414
+
If you don't plan on going through the [AKS tutorial][aks-tutorial], clean up unnecessary resources to avoid Azure charges.
410
415
411
-
```azurecli
412
-
az group delete --name myResourceGroup --yes --no-wait
416
+
Remove the resource group, container service, and all related resources using the [`az group delete`][az-group-delete] command.
417
+
418
+
```azurecli-interactive
419
+
az group delete --name $MY_RESOURCE_GROUP_NAME --yes --no-wait
413
420
```
414
421
415
422
> [!NOTE]
@@ -441,4 +448,3 @@ To learn more about AKS and walk through a complete code-to-deployment example,
0 commit comments