|
| 1 | +--- |
| 2 | +title: Attach your application using the Azure IoT Operations data processor or Kubernetes native application (preview) |
| 3 | +description: Learn how to attach your app using the Azure IoT Operations data processor or Kubernetes native application in Edge Storage Accelerator. |
| 4 | +author: sethmanheim |
| 5 | +ms.author: sethm |
| 6 | +ms.topic: how-to |
| 7 | +ms.date: 04/08/2024 |
| 8 | +zone_pivot_groups: attach-app |
| 9 | +--- |
| 10 | + |
| 11 | +# Attach your application (preview) |
| 12 | + |
| 13 | +This article assumes you created a Persistent Volume (PV) and a Persistent Volume Claim (PVC). For information about creating a PV, see [Create a persistent volume](create-pv.md). For information about creating a PVC, see [Create a Persistent Volume Claim](create-pvc.md). |
| 14 | + |
| 15 | +::: zone pivot="attach-iot-op" |
| 16 | +## Configure the Azure IoT Operations data processor |
| 17 | + |
| 18 | +When you use Azure IoT Operations (AIO), the Data Processor is spawned without any mounts for Edge Storage Accelerator. You can perform the following tasks: |
| 19 | + |
| 20 | +- Add a mount for the Edge Storage Accelerator PVC you created previously. |
| 21 | +- Reconfigure all pipelines' output stage to output to the Edge Storage Accelerator mount you just created. |
| 22 | + |
| 23 | +## Add Edge Storage Accelerator to your aio-dp-runner-worker-0 pods |
| 24 | + |
| 25 | +These pods are part of a **statefulSet**. You can't edit the statefulSet in place to add mount points. Instead, follow this procedure: |
| 26 | + |
| 27 | +1. Dump the statefulSet to yaml: |
| 28 | + |
| 29 | + ```bash |
| 30 | + kubectl get statefulset -o yaml -n azure-iot-operations aio-dp-runner-worker > stateful_worker.yaml |
| 31 | + ``` |
| 32 | + |
| 33 | +1. Edit the statefulSet to include the new mounts for ESA in volumeMounts and volumes: |
| 34 | + |
| 35 | + ```yaml |
| 36 | + volumeMounts: |
| 37 | + - mountPath: /etc/bluefin/config |
| 38 | + name: config-volume |
| 39 | + readOnly: true |
| 40 | + - mountPath: /var/lib/bluefin/registry |
| 41 | + name: nfs-volume |
| 42 | + - mountPath: /var/lib/bluefin/local |
| 43 | + name: runner-local |
| 44 | + ### Add the next 2 lines ### |
| 45 | + - mountPath: /mnt/esa |
| 46 | + name: esa4 |
| 47 | + |
| 48 | + volumes: |
| 49 | + - configMap: |
| 50 | + defaultMode: 420 |
| 51 | + name: file-config |
| 52 | + name: config-volume |
| 53 | + - name: nfs-volume |
| 54 | + persistentVolumeClaim: |
| 55 | + claimName: nfs-provisioner |
| 56 | + ### Add the next 3 lines ### |
| 57 | + - name: esa4 |
| 58 | + persistentVolumeClaim: |
| 59 | + claimName: esa4 |
| 60 | + ``` |
| 61 | + |
| 62 | +1. Delete the existing statefulSet: |
| 63 | + |
| 64 | + ```bash |
| 65 | + kubectl delete statefulset -n azure-iot-operations aio-dp-runner-worker |
| 66 | + ``` |
| 67 | + |
| 68 | + This deletes all `aio-dp-runner-worker-n` pods. This is an outage-level event. |
| 69 | + |
| 70 | +1. Create a new statefulSet of aio-dp-runner-worker(s) with the ESA mounts: |
| 71 | + |
| 72 | + ```bash |
| 73 | + kubectl apply -f stateful_worker.yaml -n azure-iot-operations |
| 74 | + ``` |
| 75 | + |
| 76 | + When the `aio-dp-runner-worker-n` pods start, they include mounts to ESA. The PVC should convey this in the state. |
| 77 | + |
| 78 | +1. Once you reconfigure your Data Processor workers to have access to the ESA volumes, you must manually update the pipeline configuration to use a local path that corresponds to the mounted location of your ESA volume on the worker PODs. |
| 79 | + |
| 80 | + In order to modify the pipeline, use `kubectl edit pipeline <name of your pipeline>`. In that pipeline, replace your output stage with the following YAML: |
| 81 | + |
| 82 | + ```yaml |
| 83 | + output: |
| 84 | + batch: |
| 85 | + path: .payload |
| 86 | + time: 60s |
| 87 | + description: An example file output stage |
| 88 | + displayName: Sample File output |
| 89 | + filePath: '{{{instanceId}}}/{{{pipelineId}}}/{{{partitionId}}}/{{{YYYY}}}/{{{MM}}}/{{{DD}}}/{{{HH}}}/{{{mm}}}/{{{fileNumber}}}' |
| 90 | + format: |
| 91 | + type: jsonStream |
| 92 | + rootDirectory: /mnt/esa |
| 93 | + type: output/file@v1 |
| 94 | + ``` |
| 95 | + |
| 96 | +::: zone-end |
| 97 | + |
| 98 | +::: zone pivot="attach-kubernetes" |
| 99 | +## Configure a Kubernetes native application |
| 100 | + |
| 101 | +1. To configure a generic single pod (Kubernetes native application) against the Persistent Volume Claim (PVC), create a file named `configPod.yaml` with the following contents: |
| 102 | + |
| 103 | + ```yaml |
| 104 | + kind: Deployment |
| 105 | + apiVersion: apps/v1 |
| 106 | + metadata: |
| 107 | + name: example-static |
| 108 | + labels: |
| 109 | + app: example-static |
| 110 | + ### Uncomment the next line and add your namespace only if you are not using the default namespace (if you are using azure-iot-operations) as specified from Line 6 of your pvc.yaml. If you are not using the default namespace, all future kubectl commands require "-n YOUR_NAMESPACE" to be added to the end of your command. |
| 111 | + # namespace: YOUR_NAMESPACE |
| 112 | + spec: |
| 113 | + replicas: 1 |
| 114 | + selector: |
| 115 | + matchLabels: |
| 116 | + app: example-static |
| 117 | + template: |
| 118 | + metadata: |
| 119 | + labels: |
| 120 | + app: example-static |
| 121 | + spec: |
| 122 | + containers: |
| 123 | + - image: mcr.microsoft.com/cbl-mariner/base/core:2.0 |
| 124 | + name: mariner |
| 125 | + command: |
| 126 | + - sleep |
| 127 | + - infinity |
| 128 | + volumeMounts: |
| 129 | + ### This name must match the 'volumes.name' attribute in the next section. ### |
| 130 | + - name: blob |
| 131 | + ### This mountPath is where the PVC is attached to the pod's filesystem. ### |
| 132 | + mountPath: "/mnt/blob" |
| 133 | + volumes: |
| 134 | + ### User-defined 'name' that's used to link the volumeMounts. This name must match 'volumeMounts.name' as specified in the previous section. ### |
| 135 | + - name: blob |
| 136 | + persistentVolumeClaim: |
| 137 | + ### This claimName must refer to the PVC resource 'name' as defined in the PVC config. This name must match what your PVC resource was actually named. ### |
| 138 | + claimName: YOUR_CLAIM_NAME_FROM_YOUR_PVC |
| 139 | + ``` |
| 140 | + |
| 141 | + > [!NOTE] |
| 142 | + > If you are using your own namespace, all future `kubectl` commands require `-n YOUR_NAMESPACE` to be appended to the command. For example, you must use `kubectl get pods -n YOUR_NAMESPACE` instead of the standard `kubectl get pods`. |
| 143 | + |
| 144 | +1. To apply this .yaml file, run the following command: |
| 145 | + |
| 146 | + ```bash |
| 147 | + kubectl apply -f "configPod.yaml" |
| 148 | + ``` |
| 149 | + |
| 150 | +1. Use `kubectl get pods` to find the name of your pod. Copy this name, as you need it for the next step. |
| 151 | + |
| 152 | +1. Run the following command and replace `POD_NAME_HERE` with your copied value from the previous step: |
| 153 | + |
| 154 | + ```bash |
| 155 | + kubectl exec -it POD_NAME_HERE -- bash |
| 156 | + ``` |
| 157 | + |
| 158 | +1. Change directories into the `/mnt/blob` mount path as specified from your `configPod.yaml`. |
| 159 | + |
| 160 | +1. As an example, to write a file, run `touch file.txt`. |
| 161 | + |
| 162 | +1. In the Azure portal, navigate to your storage account and find the container. This is the same container you specified in your `pv.yaml` file. When you select your container, you see `file.txt` populated within the container. |
| 163 | + |
| 164 | +::: zone-end |
| 165 | + |
| 166 | +## Next steps |
| 167 | + |
| 168 | +After you complete these steps, begin monitoring your deployment using Azure Monitor and Kubernetes Monitoring or third-party monitoring with Prometheus and Grafana: |
| 169 | + |
| 170 | +[Third-party monitoring](third-party-monitoring.md) |
0 commit comments