⚠️ Deprecation notice

This preview integration of IoT Edge 1.x and Kubernetes will not be made generally available, and is no longer supported. The recommended way to run IoT Edge 1.x on Kubernetes is noted in the product's official docs

This example demonstrates how to back the iotedged pod using persistent volumes. iotedged contains certificates and other security state which must be persisted on durable storage in order for the edge deployment to be remain functional should the iotedged pod be restarted and/or relocated to another node.

This tutorial requires a Azure Kubernetes (AKS) cluster with Helm initialized and kubectl installed as noted in the prerequisites.

A persistent volume backed by remote or replicated storage to provide resilience to node failure in a multi-node cluster setup. This example uses azurefile but you can use any persistent volume provider.

Local storage backed persistent volumes provide resilience to pod failure if the new pod happens to land on the same node but does not help in cases where the pod migrates nodes.

See the prerequisites section for more details.

Setup steps

  1. As needed, follow the steps to register an IoT Edge device. Take note of the device connection string.

  2. Create an AKS cluster and connect to it.

  3. Create a Kubernetes namespace for your IoT Edge deployment

    kubectl create ns pv-iotedged
    
  4. Create an Azure Files storage class.

  5. Create a persistent volume claim:

    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: iotedged-data-azurefile
      namespace: pv-iotedged
    spec:
      accessModes:
        - ReadWriteMany
      storageClassName: azurefile
      resources:
        requests:
          storage: 100Mi
    
  6. Specify persistent volume claim name to use for storing iotedged data during install.

    
    # Install IoT Edge CRD, if not already installed
    helm install --repo https://edgek8s.blob.core.windows.net/staging edge-crd edge-kubernetes-crd
    
    # Store the device connection string in a variable (enclose in single quotes)
    export connStr='replace-with-device-connection-string-from-step-1'
    
    # Install
    helm install --repo https://edgek8s.blob.core.windows.net/staging pv-iotedged-example edge-kubernetes \
      --namespace pv-iotedged \
      --set "iotedged.data.persistentVolumeClaim.name=iotedged-data-azurefile" \
      --set "provisioning.deviceConnectionString=$connStr"
    
    
  7. In addition to iotedged, the edgeHub module's message store should also be a backed by a persistent volume to prevent data loss when deployed in a Kubernetes environment. See this tutorial for the steps on how to do this.

Cleanup

# Cleanup
helm del pv-iotedged-example -n pv-iotedged && \
kubectl delete ns pv-iotedged

...will remove all the Kubernetes resources deployed as part of the edge deployment in this tutorial (IoT Edge CRD will not be deleted).