how to install python packages in kubernetes pods

Viewed 1316

I have a custom airflow image that has some python packages in it. I am running it in local kubernetes cluster. I have created a DAG in my airflow that uses one of the python packages and it works totally fine. But if I use some other python package that's not in my custom base image(imageio or anyother image), it gives me module not found error.

So I added the line "RUN pip3 install imageio==2.8.0" (or any other package) in my Dockerfile, first of all, it gave me the warning: python install warning

Now the import error is no more there but if I run my DAG it fails without outputting any logs. So next I added the line "ENV PATH="/usr/local/airflow/.local/bin:${PATH}" but still the same thing.

I am guessing my DAG is not able to find the extra python packages that are being installed, or more clearly somehow the pods being created don't have those extra python packages with them.

However, if I do "docker run -it {image_name} bash" and type import imageio inside a python shell, it works fine.

Is there some config file in which I will need to mention the extra python packages that I want so that the pods running the DAGs will register those packages?

or is there a way to specify it in the values.yaml file?

0 Answers
Related