简体   繁体   中英

Deployment template for multiple init containers azure iot edge

I have 2 init containers and 1 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 kube.netes 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?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM