Skip to content

Commit 26c4ddf

Browse files
committed
Dapr updates for improved troubleshooting and simpler deployment
Signed-off-by: Ryan Winter <[email protected]>
1 parent b4d856a commit 26c4ddf

File tree

3 files changed

+39
-41
lines changed

3 files changed

+39
-41
lines changed

articles/iot-operations/create-edge-apps/howto-deploy-dapr.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ To create the yaml file, use the following component definitions:
4444
> [!div class="mx-tdBreakAll"]
4545
> | Component | Description |
4646
> |-|-|
47-
> | `metadata.name` | The component name is important and is how a Dapr application references the component. |
48-
> | `metadata.annotations` | Component annotations used by Dapr sidecar injector, defining the image location and required volume mounts
49-
> | `spec.type` | [The type of the component](https://docs.dapr.io/operations/components/pluggable-components-registration/#define-the-component), which needs to be declared exactly as shown |
50-
> | `spec.metadata.keyPrefix` | Defines the key prefix used when communicating to the statestore backend. See the [Dapr documentation](https://docs.dapr.io/developing-applications/building-blocks/state-management/howto-share-state) for more information |
51-
> | `spec.metadata.hostname` | The MQTT broker hostname. Defaults to `aio-mq-dmqtt-frontend` |
52-
> | `spec.metadata.tcpPort` | The MQTT broker port number. Default is `8883` |
53-
> | `spec.metadata.useTls` | Define if TLS is used by the MQTT broker. Defaults to `true` |
54-
> | `spec.metadata.caFile` | The certificate chain path for validating the MQTT broker. Required if `useTls` is `true`. This file must be mounted in the pod with the specified volume name |
55-
> | `spec.metadata.satAuthFile ` | The Service Account Token (SAT) file is used to authenticate the Dapr components with the MQTT broker. This file must be mounted in the pod with the specified volume name |
47+
> | `metadata:name` | The component name is important and is how a Dapr application references the component. |
48+
> | `metadata:annotations:dapr.io/component-container` | Component annotations used by Dapr sidecar injector, defining the image location, volume mounts and logging configuration |
49+
> | `spec:type` | [The type of the component](https://docs.dapr.io/operations/components/pluggable-components-registration/#define-the-component), which needs to be declared exactly as shown |
50+
> | `spec:metadata:keyPrefix` | Defines the key prefix used when communicating to the statestore backend. See the [Dapr documentation](https://docs.dapr.io/developing-applications/building-blocks/state-management/howto-share-state) for more information |
51+
> | `spec:metadata:hostname` | The MQTT broker hostname. Default is `aio-mq-dmqtt-frontend` |
52+
> | `spec:metadata:tcpPort` | The MQTT broker port number. Default is `8883` |
53+
> | `spec:metadata:useTls` | Define if TLS is used by the MQTT broker. Default is `true` |
54+
> | `spec:metadata:caFile` | The certificate chain path for validating the MQTT broker. Required if `useTls` is `true`. This file must be mounted in the pod with the specified volume name |
55+
> | `spec:metadata:satAuthFile ` | The Service Account Token (SAT) file is used to authenticate the Dapr components with the MQTT broker. This file must be mounted in the pod with the specified volume name |
5656
5757
1. Save the following yaml, which contains the Azure IoT Operations component definitions, to a file named `components.yaml`:
5858

@@ -70,6 +70,10 @@ To create the yaml file, use the following component definitions:
7070
"volumeMounts": [
7171
{ "name": "mqtt-client-token", "mountPath": "/var/run/secrets/tokens" },
7272
{ "name": "aio-ca-trust-bundle", "mountPath": "/var/run/certs/aio-mq-ca-cert" }
73+
],
74+
"env": [
75+
{ "name": "pubSubLogLevel", "value": "Information" },
76+
{ "name": "stateStoreLogLevel", "value": "Information" }
7377
]
7478
}
7579
spec:

articles/iot-operations/create-edge-apps/howto-develop-dapr-apps.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,20 @@ After you finish writing the Dapr application, build the container:
5050

5151
## Deploy a Dapr application
5252

53-
The following [Deployment](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/) definition contains the volumes required to deploy the application along with the required containers. This deployment utilizes the Dapr sidecar injector to automatically add the pluggable component pod.
53+
The following [Deployment](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/) definition contains volumes for SAT authentication and TLS certificate chain, as well as utilizing Dapr sidecar injection to automatically add the pluggable components to the Pod.
5454

55-
The yaml contains both a ServiceAccount, used to generate SATs for authentication with MQTT broker and the Dapr application Deployment.
56-
57-
To create the yaml file, use the following definitions:
55+
The following definition components will typically require customization to your specific application:
5856

5957
> | Component | Description |
6058
> |-|-|
61-
> | `volumes.mqtt-client-token` | The System Authentication Token used for authenticating the Dapr pluggable components with the MQTT broker |
62-
> | `volumes.aio-ca-trust-bundle` | The chain of trust to validate the MQTT broker TLS cert. This defaults to the test certificate deployed with Azure IoT Operations |
63-
> | `containers.mq-dapr-app` | The Dapr application container you want to deploy |
59+
> | `template:metadata:annotations:dapr.io/inject-pluggable-components` | Allows the IoT Operations pluggable components to be [automatically injected](https://docs.dapr.io/operations/components/pluggable-components-registration/) into the pod |
60+
> | `template:metadata:annotations:dapr.io/app-port` | Tells Dapr which port your application is listening on. If your application us not using this feature (such as a pubsub subscription), then remove this line |
61+
> | `volumes:mqtt-client-token` | The System Authentication Token used for authenticating the Dapr pluggable components with the MQTT broker |
62+
> | `volumes:aio-ca-trust-bundle` | The chain of trust to validate the MQTT broker TLS cert. This defaults to the test certificate deployed with Azure IoT Operations |
63+
> | `containers:mq-dapr-app` | The Dapr application container you want to deploy |
64+
65+
> [!CAUTION]
66+
> If your Dapr application is not listening for traffic from the Dapr sidecar, then remove the `dapr.io/app-port` and `dapr.io/app-protocol` [annotations](https://docs.dapr.io/reference/arguments-annotations-overview/) otherwise the Dapr sidecar will fail to initialize.
6467

6568
1. Save the following yaml to a file named `dapr-app.yaml`:
6669

@@ -76,21 +79,20 @@ To create the yaml file, use the following definitions:
7679
apiVersion: apps/v1
7780
kind: Deployment
7881
metadata:
79-
name: mq-dapr-app
82+
name: my-dapr-app
8083
namespace: azure-iot-operations
8184
spec:
82-
replicas: 1
8385
selector:
8486
matchLabels:
85-
app: mq-dapr-app
87+
app: my-dapr-app
8688
template:
8789
metadata:
8890
labels:
89-
app: mq-dapr-app
91+
app: my-dapr-app
9092
annotations:
9193
dapr.io/enabled: "true"
9294
dapr.io/inject-pluggable-components: "true"
93-
dapr.io/app-id: "mq-dapr-app"
95+
dapr.io/app-id: "my-dapr-app"
9496
dapr.io/app-port: "6001"
9597
dapr.io/app-protocol: "grpc"
9698
spec:
@@ -124,23 +126,22 @@ To create the yaml file, use the following definitions:
124126
kubectl get pods -w
125127
```
126128

127-
The workload pod should report all pods running after a short interval, as shown in the following example output:
129+
The pod should report 3 containers running after a short interval, as shown in the following example output:
128130

129131
```output
130-
pod/dapr-workload created
131132
NAME READY STATUS RESTARTS AGE
132133
...
133-
dapr-workload 3/3 Running 0 30s
134+
my-dapr-app 3/3 Running 0 30s
134135
```
135136

136137
## Troubleshooting
137138

138-
If the application doesn't start or you see the pods in `CrashLoopBackoff`, the logs for `daprd` are most helpful. The `daprd` is a container that automatically deploys with your Dapr application.
139+
If the application doesn't start or you see the containers in `CrashLoopBackoff`, the logs for the `daprd` container often contains useful information.
139140
140-
Run the following command to view the logs:
141+
Run the following command to view the logs for the daprd component:
141142
142143
```bash
143-
kubectl logs dapr-workload daprd
144+
kubectl logs -l app=my-dapr-app -c daprd
144145
```
145146
146147
## Next steps

articles/iot-operations/create-edge-apps/tutorial-event-driven-with-dapr.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,27 +106,20 @@ To start, create a yaml file that uses the following definitions:
106106
1. Confirm that the application deployed successfully. The pod should report all containers are ready after a short interval, as shown with the following command:
107107

108108
```bash
109-
kubectl get pods -n azure-iot-operations
109+
kubectl get pods -l app=mq-event-driven-dapr -n azure-iot-operations
110110
```
111111

112112
With the following output:
113113

114114
```output
115-
NAME READY STATUS RESTARTS AGE
116-
...
117-
mq-event-driven-dapr 3/3 Running 0 30s
115+
NAME READY STATUS RESTARTS AGE
116+
mq-event-driven-dapr 3/3 Running 0 30s
118117
```
119118

120119
## Deploy the simulator
121120

122121
Simulate test data by deploying a Kubernetes workload. It simulates a sensor by sending sample temperature, vibration, and pressure readings periodically to the MQTT broker using an MQTT client on the `sensor/data` topic.
123122

124-
1. Patch BrokerListener to allow unauthenticated connection, to simplify injection of simulated data:
125-
126-
```bash
127-
kubectl patch BrokerListener listener -n azure-iot-operations --type=json -p='[{ "op": "add", "path": "/spec/ports/1", "value": {"port":1883} }]'
128-
```
129-
130123
1. Deploy the simulator from the Explore IoT Operations repository:
131124

132125
```bash
@@ -274,7 +267,7 @@ The above tutorial uses a prebuilt container of the Dapr application. If you wou
274267
git clone https://github.com/Azure-Samples/explore-iot-operations
275268
```
276269

277-
1. Change to the Dapr tutorial directory in the [Explore IoT Operations](https://github.com/Azure-Samples/explore-iot-operations) repository:
270+
1. Change to the Dapr tutorial directory:
278271

279272
```bash
280273
cd explore-iot-operations/tutorials/mq-event-driven-dapr/src
@@ -297,12 +290,12 @@ The above tutorial uses a prebuilt container of the Dapr application. If you wou
297290

298291
## Troubleshooting
299292

300-
If the application doesn't start or you see the pods in `CrashLoopBackoff`, the logs for `daprd` are most helpful. The `daprd` is a container that is automatically deployed with your Dapr application.
293+
If the application doesn't start or you see the containers in `CrashLoopBackoff`, the logs for the `daprd` container often contains useful information.
301294

302-
Run the following command to view the logs:
295+
Run the following command to view the logs for the daprd component:
303296

304297
```bash
305-
kubectl logs dapr-workload daprd
298+
kubectl logs -l app=mq-event-driven-dapr -n azure-iot-operations -c daprd
306299
```
307300

308301
## Next steps

0 commit comments

Comments
 (0)