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://go.microsoft.com/fwlink/?linkid=2262758)
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,71 @@ 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
35
-
## Create a resource group
36
-
37
-
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.
36
+
## Define environment variables
38
37
39
-
The following example creates a resource group named *myResourceGroup* in the *eastus* location.
38
+
Define the following environment variables for use throughout this quickstart:
40
39
41
-
Create a resource group using the [az group create][az-group-create] command.
az group create --name myResourceGroup --location eastus
45
-
```
48
+
## Create a resource group
46
49
47
-
The following sample output resembles successful creation of the resource group:
50
+
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.
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
-
```
76
+
Create an AKS cluster using the [`az aks create`][az-aks-create] command. The following example creates a cluster with one node and enables a system-assigned managed identity.
74
77
75
-
After a few minutes, the command completes and returns JSON-formatted information about the cluster.
78
+
```azurecli-interactive
79
+
az aks create --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_AKS_CLUSTER_NAME --enable-managed-identity --node-count 1 --generate-ssh-keys
80
+
```
76
81
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)
82
+
> [!NOTE]
83
+
> 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
84
80
85
## Connect to the cluster
81
86
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.
87
+
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
88
84
89
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
90
86
-
```azurecli
87
-
az aks get-credentials --resource-group myResourceGroup --name myAKSCluster
91
+
```azurecli-interactive
92
+
az aks get-credentials --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_AKS_CLUSTER_NAME
88
93
```
89
94
90
95
1. Verify the connection to your cluster using the [kubectl get][kubectl-get] command. This command returns a list of the cluster nodes.
91
96
92
-
```azurecli
97
+
```azurecli-interactive
93
98
kubectl get nodes
94
99
```
95
100
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,71 +347,73 @@ To deploy the application, you use a manifest file to create all the objects req
349
347
350
348
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
349
352
-
1. Deploy the application using the [kubectl apply][kubectl-apply] command and specify the name of your YAML manifest.
350
+
1. Deploy the application using the [`kubectl apply`][kubectl-apply] command and specify the name of your YAML manifest.
353
351
354
-
```azurecli
352
+
```azurecli-interactive
355
353
kubectl apply -f aks-store-quickstart.yaml
356
354
```
357
355
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
356
## Test the application
372
357
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":::
358
+
You can validate that the application is running by visiting the public IP address or the application URL.
359
+
360
+
Get the application URL using the following commands:
361
+
362
+
```azurecli-interactive
363
+
runtime="5 minute"
364
+
endtime=$(date -ud "$runtime" +%s)
365
+
while [[ $(date -u +%s) -le $endtime ]]
366
+
do
367
+
STATUS=$(kubectl get pods -l app=store-front -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}')
368
+
echo $STATUS
369
+
if [ "$STATUS" == 'True' ]
370
+
then
371
+
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"
407
+
```
408
+
409
+
:::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
410
407
411
## Delete the cluster
408
412
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.
410
-
411
-
```azurecli
412
-
az group delete --name myResourceGroup --yes --no-wait
413
-
```
413
+
If you don't plan on going through the [AKS tutorial][aks-tutorial], clean up unnecessary resources to avoid Azure charges. You can remove the resource group, container service, and all related resources using the [`az group delete`][az-group-delete] command.
414
414
415
-
> [!NOTE]
416
-
> The AKS cluster was created with a system-assigned managed identity, which is the default identity option used in this quickstart. The platform manages this identity so you don't need to manually remove it.
415
+
> [!NOTE]
416
+
> The AKS cluster was created with a system-assigned managed identity, which is the default identity option used in this quickstart. The platform manages this identity so you don't need to manually remove it.
417
417
418
418
## Next steps
419
419
@@ -441,4 +441,3 @@ To learn more about AKS and walk through a complete code-to-deployment example,
0 commit comments