Stand up fleet of docker containers to simulate IOT devices?

7/13/2019

I'm trying to design a good way to bring up a fleet of docker containers that act as IOT devices, each with a slightly different configuration.

In each container I would haven an app that simulated some hardware device, e.g. temperature sensor, and each one would have a unique "identity". Example sensor1, sensor2, sensor3, etc and some other configurations that could vary.

I would also want to scale up and scale down the number of virtual devices based on the use case being tested.

The ways I can think of doing this would be to either pass unique properties to each container via a shell script, or have each container access a database or some other store where it would retrieve its unique configuration on startup from a pool of available configurations.

This way the same app would run in each container but its configuration would be unique. Then they would start sending data to some endpoint where I process their telemetry payloads as a data stream.

For a Kubernetes solution it would seem the containers would have to connect to some common datastore to get their configuration since it would not be possible to pass a unique set of properties to each container?

-- ChrisRTech
docker
docker-swarm
kubernetes

1 Answer

7/17/2019
  1. Regarding the identity, David already mentioned the StatefulSet.

Like a Deployment , a StatefulSet manages Pods that are based on an identical container spec. Unlike a Deployment, a StatefulSet maintains a sticky identity for each of their Pods. These pods are created from the same spec, but are not interchangeable: each has a persistent identifier that it maintains across any rescheduling.

  1. Regarding the scaling. If I understand you correctly, you need a ReplicaSet.

A ReplicaSet is defined with fields, including a selector that specifies how to identify Pods it can acquire, a number of replicas indicating how many Pods it should be maintaining, and a pod template specifying the data of new Pods it should create to meet the number of replicas criteria. A ReplicaSet then fulfills its purpose by creating and deleting Pods as needed to reach the desired number. When a ReplicaSet needs to create new Pods, it uses its Pod template.

  1. For the configuration/properties part, ConfigMaps are what you need.

ConfigMaps bind configuration files, command-line arguments, environment variables, port numbers, and other configuration artifacts to your Pods' containers and system components at runtime.

Please let me know if that helped.

-- OhHiMark
Source: StackOverflow