Skip to content

Commit fad6ee9

Browse files
committed
incorporate Anthony's comments
1 parent 24fe3c4 commit fad6ee9

File tree

5 files changed

+77
-254
lines changed

5 files changed

+77
-254
lines changed

articles/aks/TOC.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
href: learn/quick-kubernetes-deploy-powershell.md
2626
- name: Use the Azure portal
2727
href: learn/quick-kubernetes-deploy-portal.md
28-
- name: Use Bicep extension
28+
- name: Use Bicep Kubernetes provider
2929
displayName: Resource Manager,arm,template
3030
href: learn/quick-kubernetes-deploy-bicep-extensibility-kubernetes-provider.md
3131
- name: Use Bicep

articles/aks/learn/quick-kubernetes-deploy-bicep-extensibility-kubernetes-provider.md

Lines changed: 28 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Quickstart - Deploy Azure applications to Azure Kubernetes Services by us
33
description: Learn how to quickly create a Kubernetes cluster and deploy Azure applications in Azure Kubernetes Service (AKS) by using Bicep extensibility Kubernetes provider.
44
services: container-service
55
ms.topic: quickstart
6-
ms.date: 01/31/2023
6+
ms.date: 02/03/2023
77
#Customer intent: As a developer or cluster operator, I want to quickly create an AKS cluster and deploy an application so that I can see how to run applications using the managed Kubernetes service in Azure.
88
---
99

@@ -178,6 +178,11 @@ Use the following procedure to add the application definition:
178178
:::image type="content" source="./media/quick-kubernetes-deploy-bicep-extensibility-kubernetes-provider/bicep-extensibility-kubernetes-provider-import-kubernetes-manifest.png" alt-text="Screenshot of Visual Studio Code import Kubernetes Manifest":::
179179

180180
1. In the prompt, select **azure-vote.yml**. This process creates an **azure-vote.bicep** in the same folder.
181+
1. At the end of **azure-vote.bicep**, add the following line to output the load balancer public IP.
182+
183+
```bicep
184+
output frontendIp string = coreService_azureVoteFront.status.loadBalancer.ingress[0].ip
185+
```
181186

182187
1. Before the `output` statement in **main.bicep**, add the following Bicep to reference the newly created **azure-vote.bicep** module:
183188

@@ -190,6 +195,14 @@ Use the following procedure to add the application definition:
190195
}
191196
```
192197

198+
1. At the end of **main.bicep**, add the following line to output the load balancer public IP:
199+
200+
```bicep
201+
output lbPublicIp string = kubernetes.outputs.frontendIp
202+
```
203+
204+
1. Save both **main.bicep** and **azure-vote.bicep**.
205+
193206
## Deploy the Bicep file
194207

195208
1. Deploy the Bicep file using either Azure CLI or Azure PowerShell.
@@ -219,94 +232,24 @@ Use the following procedure to add the application definition:
219232

220233
It takes a few minutes to create the AKS cluster. Wait for the cluster to be successfully deployed before you move on to the next step.
221234

222-
## Validate the Bicep deployment
223-
224-
### Connect to the cluster
225-
226-
To manage a Kubernetes cluster, use the Kubernetes command-line client, [kubectl][kubectl]. `kubectl` is already installed if you use Azure Cloud Shell.
227-
228-
### [Azure CLI](#tab/azure-cli)
229-
230-
1. Install `kubectl` locally using the [az aks install-cli][az-aks-install-cli] command:
231-
232-
```azurecli
233-
az aks install-cli
234-
```
235-
236-
2. 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.
237-
238-
```azurecli-interactive
239-
az aks get-credentials --resource-group myResourceGroup --name myAKSCluster
240-
```
241-
242-
3. Verify the connection to your cluster using the [kubectl get][kubectl-get] command. This command returns a list of the cluster nodes.
243-
244-
```console
245-
kubectl get nodes
246-
```
247-
248-
The following output example shows the three nodes created in the previous steps. Make sure the node status is *Ready*:
249-
250-
```output
251-
NAME STATUS ROLES AGE VERSION
252-
aks-agentpool-41324942-0 Ready agent 6m44s v1.12.6
253-
aks-agentpool-41324942-1 Ready agent 6m46s v1.12.6
254-
aks-agentpool-41324942-2 Ready agent 6m45s v1.12.6
255-
```
256-
257-
### [Azure PowerShell](#tab/azure-powershell)
258-
259-
1. Install `kubectl` locally using the [Install-AzAksKubectl][install-azakskubectl] cmdlet:
260-
261-
```azurepowershell
262-
Install-AzAksKubectl
263-
```
264-
265-
2. Configure `kubectl` to connect to your Kubernetes cluster using the [Import-AzAksCredential][import-azakscredential] cmdlet. The following cmdlet downloads credentials and configures the Kubernetes CLI to use them.
235+
2. From the deployment output, look for the **outputs** section. For example:
266236

267-
```azurepowershell-interactive
268-
Import-AzAksCredential -ResourceGroupName myResourceGroup -Name myAKSCluster
269-
```
270-
271-
3. Verify the connection to your cluster using the [kubectl get][kubectl-get] command. This command returns a list of the cluster nodes.
272-
273-
```azurepowershell-interactive
274-
kubectl get nodes
275-
```
276-
277-
The following output example shows the three nodes created in the previous steps. Make sure the node status is *Ready*:
278-
279-
```plaintext
280-
NAME STATUS ROLES AGE VERSION
281-
aks-agentpool-41324942-0 Ready agent 6m44s v1.12.6
282-
aks-agentpool-41324942-1 Ready agent 6m46s v1.12.6
283-
aks-agentpool-41324942-2 Ready agent 6m45s v1.12.6
237+
```bicep
238+
"outputs": {
239+
"controlPlaneFQDN": {
240+
"type": "String",
241+
"value": "myaks0201-d34ae860.hcp.eastus.azmk8s.io"
242+
},
243+
"lbPublicIp": {
244+
"type": "String",
245+
"value": "52.179.23.131"
246+
}
247+
},
284248
```
285249

286-
---
287-
288-
### Test the application
289-
290-
When the application runs, a Kubernetes service exposes the application front end to the internet. This process can take a few minutes to complete.
291-
292-
Monitor progress using the [kubectl get service][kubectl-get] command with the `--watch` argument.
293-
294-
```console
295-
kubectl get service azure-vote-front --watch
296-
```
250+
Make a note of the value of lbPublicIp.
297251

298-
The **EXTERNAL-IP** output for the `azure-vote-front` service will initially show as *pending*.
299-
300-
```output
301-
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
302-
azure-vote-front LoadBalancer 10.0.37.27 <pending> 80:30572/TCP 6s
303-
```
304-
305-
Once the **EXTERNAL-IP** address changes from *pending* to an actual public IP address, use `CTRL-C` to stop the `kubectl` watch process. The following example output shows a valid public IP address assigned to the service:
306-
307-
```output
308-
azure-vote-front LoadBalancer 10.0.37.27 52.179.23.131 80:30572/TCP 2m
309-
```
252+
## Validate the Bicep deployment
310253

311254
To see the Azure Vote app in action, open a web browser to the external IP address of your service.
312255

articles/azure-resource-manager/bicep/bicep-extensibility-kubernetes-provider.md

Lines changed: 21 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Bicep extensibility Kubernetes provider
33
description: Learn how to Bicep Kubernetes provider to deploy .NET applications to Azure Kubernetes Service clusters.
44
ms.topic: conceptual
5-
ms.date: 02/01/2023
5+
ms.date: 02/03/2023
66
---
77

88
# Bicep extensibility Kubernetes provider (Preview)
@@ -13,152 +13,50 @@ Learn how to Bicep extensibility Kubernetes provider to deploy .NET applications
1313

1414
This preview feature can be enabled by configuring the [bicepconfig.json](./bicep-config.md):
1515

16-
```bicep
16+
```json
1717
{
1818
"experimentalFeaturesEnabled": {
1919
"extensibility": true,
2020
}
2121
}
2222
```
2323

24-
## Import schema for Kubernetes provider
24+
## Import Kubernetes provider
25+
26+
Deployments of Kubernetes must be contained within a [Bicep module file](./modules.md). To import the Kubernetes provider, use the [import statement](./bicep-import-providers.md). After importing the provider, you can refactor the Bicep module file as usual, such as by using variables and parameters. The Kubernetes manifest in YML does not include any programmability support by contract.
2527

26-
Use the following syntax to import schema for Kubernetes provider:
28+
The following sample imports the Kubernetes provider:
2729

2830
```bicep
29-
resource aks 'Microsoft.ContainerService/managedClusters@2022-05-02-preview' existing = {
30-
name: clusterName
31-
}
31+
@secure()
32+
param kubeConfig string
3233
3334
import '[email protected]' with {
3435
namespace: 'default'
35-
kubeConfig: aks.listClusterAdminCredential().kubeconfigs[0].value
36+
kubeConfig: kubeConfig
3637
}
3738
```
3839

39-
The AKS cluster can be a new resource or an existing resource. The [Import Kubernetes manifest command](./visual-studio-code.md#bicep-commands) from Visual Studio Code can automatically add the code snippet automatically.
40-
41-
## Define Kubernetes deployments and services
42-
43-
*** Do I need to cover how a Kubernetes YML is transformed into Bicep?
44-
45-
```yml
46-
apiVersion: apps/v1
47-
kind: Deployment
48-
metadata:
49-
name: azure-vote-back
50-
spec:
51-
replicas: 1
52-
selector:
53-
matchLabels:
54-
app: azure-vote-back
55-
template:
56-
metadata:
57-
labels:
58-
app: azure-vote-back
59-
spec:
60-
nodeSelector:
61-
"kubernetes.io/os": linux
62-
containers:
63-
- name: azure-vote-back
64-
image: mcr.microsoft.com/oss/bitnami/redis:6.0.8
65-
env:
66-
- name: ALLOW_EMPTY_PASSWORD
67-
value: "yes"
68-
resources:
69-
requests:
70-
cpu: 100m
71-
memory: 128Mi
72-
limits:
73-
cpu: 250m
74-
memory: 256Mi
75-
ports:
76-
- containerPort: 6379
77-
name: redis
78-
---
79-
apiVersion: v1
80-
kind: Service
81-
metadata:
82-
name: azure-vote-back
83-
spec:
84-
ports:
85-
- port: 6379
86-
selector:
87-
app: azure-vote-back
88-
```
40+
- **namespace**: Specify the namespace of the provider.
41+
- **KubeConfig**: Specify a base64 encoded value of the [Kubernetes cluster admin credentials](/rest/api/aks/managed-clusters/list-cluster-admin-credentials).
42+
43+
The following sample shows how to pass `kubeConfig` value from parent Bicep file:
8944

9045
```bicep
91-
resource appsDeployment_azureVoteBack 'apps/Deployment@v1' = {
92-
metadata: {
93-
name: 'azure-vote-back'
94-
}
95-
spec: {
96-
replicas: 1
97-
selector: {
98-
matchLabels: {
99-
app: 'azure-vote-back'
100-
}
101-
}
102-
template: {
103-
metadata: {
104-
labels: {
105-
app: 'azure-vote-back'
106-
}
107-
}
108-
spec: {
109-
nodeSelector: {
110-
'kubernetes.io/os': 'linux'
111-
}
112-
containers: [
113-
{
114-
name: 'azure-vote-back'
115-
image: 'mcr.microsoft.com/oss/bitnami/redis:6.0.8'
116-
env: [
117-
{
118-
name: 'ALLOW_EMPTY_PASSWORD'
119-
value: 'yes'
120-
}
121-
]
122-
resources: {
123-
requests: {
124-
cpu: '100m'
125-
memory: '128Mi'
126-
}
127-
limits: {
128-
cpu: '250m'
129-
memory: '256Mi'
130-
}
131-
}
132-
ports: [
133-
{
134-
containerPort: 6379
135-
name: 'redis'
136-
}
137-
]
138-
}
139-
]
140-
}
141-
}
142-
}
46+
resource aks 'Microsoft.ContainerService/managedClusters@2022-05-02-preview' existing = {
47+
name: 'demoAKSCluster'
14348
}
14449
145-
resource coreService_azureVoteBack 'core/Service@v1' = {
146-
metadata: {
147-
name: 'azure-vote-back'
148-
}
149-
spec: {
150-
ports: [
151-
{
152-
port: 6379
153-
}
154-
]
155-
selector: {
156-
app: 'azure-vote-back'
157-
}
50+
module kubernetes './kubernetes.bicep' = {
51+
name: 'buildbicep-deploy'
52+
params: {
53+
kubeConfig: aks.listClusterAdminCredential().kubeconfigs[0].value
15854
}
15955
}
16056
```
16157

58+
The AKS cluster can be a new resource or an existing resource. The [Import Kubernetes manifest command](./visual-studio-code.md#bicep-commands) from Visual Studio Code can automatically add the import snippet automatically.
59+
16260
## Visual Studio Code import
16361

16462
From Visual Studio Code, you can import Kubernetes manifest files to create Bicep module files. For more information, see [Visual Studio Code](./visual-studio-code.md#bicep-commands)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: Import Bicep extensibility providers
3+
description: Describes how to import Bicep extensibility providers.
4+
ms.topic: conceptual
5+
ms.date: 02/03/2023
6+
---
7+
8+
# Import Bicep extensibility providers
9+
10+
This article describes the syntax you use to import Bicep extensibility providers.
11+
12+
## Import providers
13+
14+
The syntax for importing providers is:
15+
16+
```bicep
17+
import '<provider-name>@<provider-version>' with {
18+
<provider-properties>
19+
}
20+
```
21+
22+
See [Bicep extensibility Kubernetes provider](./bicep-extensibility-kubernetes-provider.md) for an example of using the Import statement.
23+
24+
## Next steps
25+
26+
- To learn about how to use the Kubernetes provider, see [Bicep extensibility Kubernetes provider](./bicep-extensibility-kubernetes-provider.md).
27+
- To go through a Kubernetes provider tutorial, see [Quickstart - Deploy Azure applications to Azure Kubernetes Services by using Bicep Kubernetes provider.](../../aks/learn/quick-kubernetes-deploy-bicep-extensibility-kubernetes-provider.md).

0 commit comments

Comments
 (0)