Run multiple docker-android containers (adb) on Kubernetes

7/28/2019

I'm trying of running my cicd tests (as a personal challenge), for android, on Kubernetes. I ran the docker-android container (https://github.com/budtmo/docker-android), and followed the guide on my computer, and it worked (I managed to run one container on my linux pc, and control the device via the website, and the command line). The problem is that I ran only one device, and I want to run multiple containers (for multiple tests simultaneity).

How can I run multiple containers of this image on kubernetes (or is it possible)? Do I need to allocate new different ports for every simulator?

P.S On the github link, they tagged "kubernetes", so I guess it means its possible.

-- Yagel
android
docker
kubernetes

1 Answer

7/29/2019

You can run as many containers as you want.

Briefly it could be done in two steps:

  1. Create a Deployment specifying all containers with their configurations. In your case they all will use the same image but will have different devices, Android versions, etc.

  2. Configure Services for your applications so that the applications will be exposed.

Note, you can use exactly the same ports for your applications, they won't interfere. The services will take care of mapping needed ports inside containers.

Use case:

Usually such configuration is used with CI servers. For instance, you commit a change to a branch called fix-123. The CI server creates a deployment with, say, 2 containers: Galaxy S6 and Pixel 2. The services expose the containers as:

fix-123-galaxy-s6.your-kubernetes-cluster.com
fix-123-pixel-2.your-kubernetes-cluster.com

Later you might crete a new branch called feature-456 and your CI system will expose your containers to:

feature-456-galaxy-s6.your-kubernetes-cluster.com
feature-456-pixel-2.your-kubernetes-cluster.com 

All four will live together without interference.

-- Sasha Shpota
Source: StackOverflow