Skip to content

Commit e26d4bd

Browse files
Merge pull request #106503 from TimShererWithAquent/us1669724g
Azure CLI syntax blocks.
2 parents 7e3bc32 + 5a4feb7 commit e26d4bd

11 files changed

+104
-96
lines changed

articles/aks/openfaas.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ In order to complete the steps within this article, you need the following.
2424

2525
## Add the OpenFaaS helm chart repo
2626

27+
Go to [https://shell.azure.com](https://shell.azure.com) to open Azure Cloud Shell in your browser.
28+
2729
OpenFaaS maintains its own helm charts to keep up to date with all the latest changes.
2830

29-
```azurecli-interactive
31+
```console
3032
helm repo add openfaas https://openfaas.github.io/faas-netes/
3133
helm repo update
3234
```
@@ -37,13 +39,13 @@ As a good practice, OpenFaaS and OpenFaaS functions should be stored in their ow
3739

3840
Create a namespace for the OpenFaaS system and functions:
3941

40-
```azurecli-interactive
42+
```console
4143
kubectl apply -f https://raw.githubusercontent.com/openfaas/faas-netes/master/namespaces.yml
4244
```
4345

4446
Generate a password for the OpenFaaS UI Portal and REST API:
4547

46-
```azurecli-interactive
48+
```console
4749
# generate a random password
4850
PASSWORD=$(head -c 12 /dev/urandom | shasum| cut -d' ' -f1)
4951

@@ -58,7 +60,7 @@ The password we create here will be used by the helm chart to enable basic authe
5860

5961
A Helm chart for OpenFaaS is included in the cloned repository. Use this chart to deploy OpenFaaS into your AKS cluster.
6062

61-
```azurecli-interactive
63+
```console
6264
helm upgrade openfaas --install openfaas/openfaas \
6365
--namespace openfaas \
6466
--set basic_auth=true \
@@ -68,7 +70,7 @@ helm upgrade openfaas --install openfaas/openfaas \
6870

6971
Output:
7072

71-
```
73+
```output
7274
NAME: openfaas
7375
LAST DEPLOYED: Wed Feb 28 08:26:11 2018
7476
NAMESPACE: openfaas
@@ -96,7 +98,7 @@ kubectl get service -l component=gateway --namespace openfaas
9698

9799
Output.
98100

99-
```console
101+
```output
100102
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
101103
gateway ClusterIP 10.0.156.194 <none> 8080/TCP 7m
102104
gateway-external LoadBalancer 10.0.28.18 52.186.64.52 8080:30800/TCP 7m
@@ -116,7 +118,7 @@ Set `$OPENFAAS_URL` to the public IP found above.
116118

117119
Log in with the Azure CLI:
118120

119-
```azurecli-interactive
121+
```console
120122
export OPENFAAS_URL=http://52.186.64.52:8080
121123
echo -n $PASSWORD | ./faas-cli login -g $OPENFAAS_URL -u admin --password-stdin
122124
```
@@ -131,13 +133,13 @@ Click on **Deploy New Function** and search for **Figlet**. Select the Figlet fu
131133

132134
Use curl to invoke the function. Replace the IP address in the following example with that of your OpenFaas gateway.
133135

134-
```azurecli-interactive
136+
```console
135137
curl -X POST http://52.186.64.52:8080/function/figlet -d "Hello Azure"
136138
```
137139

138140
Output:
139141

140-
```console
142+
```output
141143
_ _ _ _ _
142144
| | | | ___| | | ___ / \ _____ _ _ __ ___
143145
| |_| |/ _ \ | |/ _ \ / _ \ |_ / | | | '__/ _ \
@@ -178,46 +180,46 @@ Now populate the Cosmos DB with test data. Create a file named `plans.json` and
178180

179181
```json
180182
{
181-
"name" : "two_person",
182-
"friendlyName" : "Two Person Plan",
183-
"portionSize" : "1-2 Person",
184-
"mealsPerWeek" : "3 Unique meals per week",
185-
"price" : 72,
186-
"description" : "Our basic plan, delivering 3 meals per week, which will feed 1-2 people.",
187-
"__v" : 0
183+
"name" : "two_person",
184+
"friendlyName" : "Two Person Plan",
185+
"portionSize" : "1-2 Person",
186+
"mealsPerWeek" : "3 Unique meals per week",
187+
"price" : 72,
188+
"description" : "Our basic plan, delivering 3 meals per week, which will feed 1-2 people.",
189+
"__v" : 0
188190
}
189191
```
190192

191193
Use the *mongoimport* tool to load the CosmosDB instance with data.
192194

193195
If needed, install the MongoDB tools. The following example installs these tools using brew, see the [MongoDB documentation][install-mongo] for other options.
194196

195-
```azurecli-interactive
197+
```console
196198
brew install mongodb
197199
```
198200

199201
Load the data into the database.
200202

201-
```azurecli-interactive
203+
```console
202204
mongoimport --uri=$COSMOS -c plans < plans.json
203205
```
204206

205207
Output:
206208

207-
```console
209+
```output
208210
2018-02-19T14:42:14.313+0000 connected to: localhost
209211
2018-02-19T14:42:14.918+0000 imported 1 document
210212
```
211213

212214
Run the following command to create the function. Update the value of the `-g` argument with your OpenFaaS gateway address.
213215

214-
```azurecli-interctive
216+
```console
215217
faas-cli deploy -g http://52.186.64.52:8080 --image=shanepeckham/openfaascosmos --name=cosmos-query --env=NODE_ENV=$COSMOS
216218
```
217219

218220
Once deployed, you should see your newly created OpenFaaS endpoint for the function.
219221

220-
```console
222+
```output
221223
Deployed. 202 Accepted.
222224
URL: http://52.186.64.52:8080/function/cosmos-query
223225
```

articles/aks/spark-job.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export AZURE_STORAGE_CONNECTION_STRING=`az storage account show-connection-strin
181181

182182
Upload the jar file to the Azure storage account with the following commands.
183183

184-
```bash
184+
```azurecli
185185
CONTAINER_NAME=jars
186186
BLOB_NAME=SparkPi-assembly-0.1.0-SNAPSHOT.jar
187187
FILE_TO_UPLOAD=target/scala-2.11/SparkPi-assembly-0.1.0-SNAPSHOT.jar
@@ -236,8 +236,10 @@ Submit the job using `spark-submit`.
236236
This operation starts the Spark job, which streams job status to your shell session. While the job is running, you can see Spark driver pod and executor pods using the kubectl get pods command. Open a second terminal session to run these commands.
237237

238238
```console
239-
$ kubectl get pods
239+
kubectl get pods
240+
```
240241

242+
```output
241243
NAME READY STATUS RESTARTS AGE
242244
spark-pi-2232778d0f663768ab27edc35cb73040-driver 1/1 Running 0 16s
243245
spark-pi-2232778d0f663768ab27edc35cb73040-exec-1 0/1 Init:0/1 0 4s
@@ -265,7 +267,7 @@ kubectl get pods --show-all
265267

266268
Output:
267269

268-
```bash
270+
```output
269271
NAME READY STATUS RESTARTS AGE
270272
spark-pi-2232778d0f663768ab27edc35cb73040-driver 0/1 Completed 0 1m
271273
```
@@ -278,7 +280,7 @@ kubectl logs spark-pi-2232778d0f663768ab27edc35cb73040-driver
278280

279281
Within these logs, you can see the result of the Spark job, which is the value of Pi.
280282

281-
```bash
283+
```output
282284
Pi is roughly 3.152155760778804
283285
```
284286

articles/aks/update-credentials.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ The output is similar to the following example. Make a note of your own `appId`
6464

6565
Now define variables for the service principal ID and client secret using the output from your own [az ad sp create-for-rbac][az-ad-sp-create] command, as shown in the following example. The *SP_ID* is your *appId*, and the *SP_SECRET* is your *password*:
6666

67-
```azurecli-interactive
67+
```console
6868
SP_ID=7d837646-b1f3-443d-874c-fd83c7c739c5
6969
SP_SECRET=a5ce83c9-9186-426d-9183-614597c7f2f7
7070
```

articles/aks/use-network-policies.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ These network policy rules are defined as YAML manifests. Network policies can b
3838

3939
Azure provides two ways to implement network policy. You choose a network policy option when you create an AKS cluster. The policy option can't be changed after the cluster is created:
4040

41-
* Azures own implementation, called *Azure Network Policies*.
41+
* Azure's own implementation, called *Azure Network Policies*.
4242
* *Calico Network Policies*, an open-source network and network security solution founded by [Tigera][tigera].
4343

4444
Both implementations use Linux *IPTables* to enforce the specified policies. Policies are translated into sets of allowed and disallowed IP pairs. These pairs are then programmed as IPTable filter rules.
@@ -168,7 +168,7 @@ wget -qO- http://backend
168168

169169
The following sample output shows that the default NGINX webpage returned:
170170

171-
```
171+
```output
172172
<!DOCTYPE html>
173173
<html>
174174
<head>
@@ -200,15 +200,16 @@ spec:
200200
ingress: []
201201
```
202202
203+
Go to [https://shell.azure.com](https://shell.azure.com) to open Azure Cloud Shell in your browser.
204+
203205
Apply the network policy by using the [kubectl apply][kubectl-apply] command and specify the name of your YAML manifest:
204206
205-
```azurecli-interactive
207+
```console
206208
kubectl apply -f backend-policy.yaml
207209
```
208210

209211
### Test the network policy
210212

211-
212213
Let's see if you can use the NGINX webpage on the back-end pod again. Create another test pod and attach a terminal session:
213214

214215
```console
@@ -218,8 +219,10 @@ kubectl run --rm -it --image=alpine network-policy --namespace development --gen
218219
At the shell prompt, use `wget` to see if you can access the default NGINX webpage. This time, set a timeout value to *2* seconds. The network policy now blocks all inbound traffic, so the page can't be loaded, as shown in the following example:
219220

220221
```console
221-
$ wget -qO- --timeout=2 http://backend
222+
wget -qO- --timeout=2 http://backend
223+
```
222224

225+
```output
223226
wget: download timed out
224227
```
225228

@@ -260,7 +263,7 @@ spec:
260263
261264
Apply the updated network policy by using the [kubectl apply][kubectl-apply] command and specify the name of your YAML manifest:
262265
263-
```azurecli-interactive
266+
```console
264267
kubectl apply -f backend-policy.yaml
265268
```
266269

@@ -278,7 +281,7 @@ wget -qO- http://backend
278281

279282
Because the ingress rule allows traffic with pods that have the labels *app: webapp,role: frontend*, the traffic from the front-end pod is allowed. The following example output shows the default NGINX webpage returned:
280283

281-
```
284+
```output
282285
<!DOCTYPE html>
283286
<html>
284287
<head>
@@ -303,8 +306,10 @@ kubectl run --rm -it --image=alpine network-policy --namespace development --gen
303306
At the shell prompt, use `wget` to see if you can access the default NGINX webpage. The network policy blocks the inbound traffic, so the page can't be loaded, as shown in the following example:
304307

305308
```console
306-
$ wget -qO- --timeout=2 http://backend
309+
wget -qO- --timeout=2 http://backend
310+
```
307311

312+
```output
308313
wget: download timed out
309314
```
310315

@@ -339,7 +344,7 @@ wget -qO- http://backend.development
339344

340345
Because the labels for the pod match what is currently permitted in the network policy, the traffic is allowed. The network policy doesn't look at the namespaces, only the pod labels. The following example output shows the default NGINX webpage returned:
341346

342-
```
347+
```output
343348
<!DOCTYPE html>
344349
<html>
345350
<head>
@@ -383,7 +388,7 @@ In more complex examples, you could define multiple ingress rules, like a *names
383388
384389
Apply the updated network policy by using the [kubectl apply][kubectl-apply] command and specify the name of your YAML manifest:
385390
386-
```azurecli-interactive
391+
```console
387392
kubectl apply -f backend-policy.yaml
388393
```
389394

@@ -398,8 +403,10 @@ kubectl run --rm -it frontend --image=alpine --labels app=webapp,role=frontend -
398403
At the shell prompt, use `wget` to see that the network policy now denies traffic:
399404

400405
```console
401-
$ wget -qO- --timeout=2 http://backend.development
406+
wget -qO- --timeout=2 http://backend.development
407+
```
402408

409+
```output
403410
wget: download timed out
404411
```
405412

@@ -423,7 +430,7 @@ wget -qO- http://backend
423430

424431
Traffic is allowed because the pod is scheduled in the namespace that matches what's permitted in the network policy. The following sample output shows the default NGINX webpage returned:
425432

426-
```
433+
```output
427434
<!DOCTYPE html>
428435
<html>
429436
<head>

articles/aks/virtual-nodes-cli.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ az provider list --query "[?contains(namespace,'Microsoft.ContainerInstance')]"
2525

2626
The *Microsoft.ContainerInstance* provider should report as *Registered*, as shown in the following example output:
2727

28-
```
28+
```output
2929
Namespace RegistrationState
3030
--------------------------- -------------------
3131
Microsoft.ContainerInstance Registered
@@ -115,7 +115,7 @@ az ad sp create-for-rbac --skip-assignment
115115

116116
The output is similar to the following example:
117117

118-
```
118+
```output
119119
{
120120
"appId": "bef76eb3-d743-4a97-9534-03e9388811fc",
121121
"displayName": "azure-cli-2018-11-21-18-42-00",
@@ -197,9 +197,7 @@ kubectl get nodes
197197

198198
The following example output shows the single VM node created and then the virtual node for Linux, *virtual-node-aci-linux*:
199199

200-
```
201-
$ kubectl get nodes
202-
200+
```output
203201
NAME STATUS ROLES AGE VERSION
204202
virtual-node-aci-linux Ready agent 28m v1.11.2
205203
aks-agentpool-14693408-0 Ready agent 32m v1.11.2
@@ -248,9 +246,11 @@ kubectl apply -f virtual-node.yaml
248246

249247
Use the [kubectl get pods][kubectl-get] command with the `-o wide` argument to output a list of pods and the scheduled node. Notice that the `aci-helloworld` pod has been scheduled on the `virtual-node-aci-linux` node.
250248

249+
```console
250+
kubectl get pods -o wide
251251
```
252-
$ kubectl get pods -o wide
253252

253+
```output
254254
NAME READY STATUS RESTARTS AGE IP NODE
255255
aci-helloworld-9b55975f-bnmfl 1/1 Running 0 4m 10.241.0.4 virtual-node-aci-linux
256256
```
@@ -282,9 +282,7 @@ curl -L http://10.241.0.4
282282

283283
The demo application is displayed, as shown in the following condensed example output:
284284

285-
```
286-
$ curl -L 10.241.0.4
287-
285+
```output
288286
<html>
289287
<head>
290288
<title>Welcome to Azure Container Instances!</title>
@@ -298,9 +296,11 @@ Close the terminal session to your test pod with `exit`. When your session is en
298296

299297
If you no longer wish to use virtual nodes, you can disable them using the [az aks disable-addons][az aks disable-addons] command.
300298

299+
If necessary, go to [https://shell.azure.com](https://shell.azure.com) to open Azure Cloud Shell in your browser.
300+
301301
First, delete the helloworld pod running on the virtual node:
302302

303-
```azurecli-interactive
303+
```console
304304
kubectl delete -f virtual-node.yaml
305305
```
306306

0 commit comments

Comments
 (0)