Skip to content

Commit 9a3f3ca

Browse files
committed
Use code from repo instead of inline
1 parent 7fb331c commit 9a3f3ca

File tree

1 file changed

+12
-44
lines changed

1 file changed

+12
-44
lines changed

articles/iot-operations/manage-mqtt-broker/howto-test-connection.md

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -37,54 +37,22 @@ Before you begin, [install or configure IoT Operations](../get-started-end-to-en
3737

3838
The first option is to connect from within the cluster. This option uses the default configuration and requires no extra updates. The following examples show how to connect from within the cluster using plain Alpine Linux and a commonly used MQTT client, using the service account and default root CA certificate.
3939

40-
First, create a file named `client.yaml` with the following configuration:
40+
Download `client.yaml` deployment from the GitHub sample repository.
4141

42-
```yaml
43-
apiVersion: v1
44-
kind: ServiceAccount
45-
metadata:
46-
name: mqtt-client
47-
namespace: azure-iot-operations
48-
---
49-
apiVersion: v1
50-
kind: Pod
51-
metadata:
52-
name: mqtt-client
53-
# Namespace must match MQTT broker BrokerListener's namespace
54-
# Otherwise use the long hostname: aio-broker.azure-iot-operations.svc.cluster.local
55-
namespace: azure-iot-operations
56-
spec:
57-
# Use the "mqtt-client" service account created from above
58-
# Otherwise create it with `kubectl create serviceaccount mqtt-client -n azure-iot-operations`
59-
serviceAccountName: mqtt-client
60-
containers:
61-
# Mosquitto and mqttui on Alpine
62-
- image: alpine
63-
name: mqtt-client
64-
command: ["sh", "-c"]
65-
args: ["apk add mosquitto-clients mqttui && sleep infinity"]
66-
volumeMounts:
67-
- name: broker-sat
68-
mountPath: /var/run/secrets/tokens
69-
- name: trust-bundle
70-
mountPath: /var/run/certs
71-
volumes:
72-
- name: broker-sat
73-
projected:
74-
sources:
75-
- serviceAccountToken:
76-
path: broker-sat
77-
audience: aio-internal # Must match audience in BrokerAuthentication
78-
expirationSeconds: 86400
79-
- name: trust-bundle
80-
configMap:
81-
name: azure-iot-operations-aio-ca-trust-bundle # Default root CA cert
82-
```
42+
> [!IMPORTANT]
43+
> Don't use the MQTT client in production. The client is for testing purposes only.
8344
84-
Then, use `kubectl` to deploy the configuration. It should only take a few seconds to start.
45+
```bash
46+
wget https://raw.githubusercontent.com/Azure-Samples/explore-iot-operations/main/samples/quickstarts/mqtt-client.yaml -O mqtt-client.yaml
47+
```
48+
Apply the deployment file with kubectl.
8549

8650
```bash
87-
kubectl apply -f client.yaml
51+
kubectl apply -f mqtt-client.yaml
52+
```
53+
54+
```output
55+
pod/mqtt-client created
8856
```
8957

9058
Once the pod is running, use `kubectl exec` to run commands inside the pod.

0 commit comments

Comments
 (0)