Deployment template for multiple init containers azure iot edge

Madanala, Jayashree 151 Reputation points
2023-02-01T05:08:48.9333333+00:00

I have 2 init containers and 1 main container and want to deploy into azure iot edge. Requirement is these 2 init containers should run in order first before main container starts.

I was able to do this in kubernetes pod and also docker compose(using depends on) Not sure how to do this in deployment manifest for azure iot edge. Is init containers supported in azure iot-edge?

Below is the snapshot of podspec i was using earlier, Can you help me how to achieve this in deployment manifest file for azure iot edge.

apiVersion: v1
kind: Pod
metadata:
  name: <<sample>>
spec:
  containers:
  - env:
    image: <<image_path>>
    imagePullPolicy: IfNotPresent
    name: <<image name>>
    ports:
    - containerPort: 443
      hostPort: 443
      name: https
      protocol: TCP
    resources: {}
    volumeMounts:
    - mountPath: "/shared/path"
      name: data
      subPath: v1/data
  imagePullSecrets:
  - name: <<imagePull_name>>
  initContainers:
  - image: <<image-init-path1>>
    imagePullPolicy: IfNotPresent
    name: <<image_name>>
    volumeMounts:
    - mountPath: "/shared/path"
      name: data
      subPath: v1/data
  - image: <<image-init-path2>>
    imagePullPolicy: IfNotPresent
    name: <<image_name>>
    volumeMounts:
    - mountPath: "/shared/path"
      name: data
      subPath: v1/data
  nodeName: test-name
  volumes:
  - name: data
    persistentVolumeClaim:
      claimName: pvc-data
Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
530 questions
Azure IoT SDK
Azure IoT SDK
An Azure software development kit that facilitates building applications that connect to Azure IoT services.
207 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Matthijs van der Veer 4,376 Reputation points MVP
    2023-02-01T07:53:00.7833333+00:00

    While you can specify the startup order of a container on IoT Edge, the runtime will not wait for the module to be up or running before starting the next. Azure IoT Edge doesn't offer any functionality for your scenario.

    A way around this would be to write the main container to check if the other two are done running. Possible ways to achieve this:

    1. Send a Direct Method from the main container to the init containers, and have them respond with a certain code when done.
    2. Send a message to the main container from the init containers when they finish the job.
    3. The containers could communicate with each other over HTTP do achieve the same.
    3 people found this answer helpful.
    0 comments No comments