Running python script after container is up (Kubernetes)

2/6/2020

I'm using the following docker image: https://github.com/budtmo/docker-android It's Docker image for Android emulators.

I'm run It using Kubernetes with the following deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: android-deployment
spec:
  selector:
    matchLabels:
      app: android-emulator
    replicas: 10
  template:
    metadata:
    labels:
        app: android-emulator
     spec:
       containers:
       - name: android-emulator
         image: budtmo/docker-android-x86-8.1
         ports:
         - containerPort: 6080
         - containerPort: 5554
         - containerPort: 5555
         env:
         - name: DEVICE
           value: "Samsung Galaxy S8"

After the container is running its automatic start the Android emulator (don't know exactly how). I need to run python script automatic after the container is up for each running container, How can I do it? What should I change in my deployment file?

-- samisaviv
docker
kubernetes

1 Answer

2/6/2020

You could simply create a Dockerfile to build your own image from the budtmo/docker-android-x86-8.1 base image and deploy this. Within the Dockerfile you define the start command or entrypoint.

UPDATE

I think I understand, correct me, if I am wrong: You want run your python script against the Android emulator running in Kubernetes.

As I said, I am not really firm with Kubernetes but couldn't you run the Android emulator as an init container, and the python script itself in the "main" container?

Like described here: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/

-- Jan Held
Source: StackOverflow