potiuk commented on a change in pull request #5837: [AIRFLOW-5223] Use KinD for 
Kubernetes in CI
URL: https://github.com/apache/airflow/pull/5837#discussion_r324486045
 
 

 ##########
 File path: scripts/ci/kubernetes/docker/build.sh
 ##########
 @@ -20,29 +20,14 @@ IMAGE=${IMAGE:-airflow}
 TAG=${TAG:-latest}
 DIRNAME=$(cd "$(dirname "$0")" && pwd)
 AIRFLOW_ROOT="${DIRNAME}/../../../.."
-PYTHON_DOCKER_IMAGE=python:3.6-slim
 
 set -e
 
-# Don't rebuild the image more than once on travis
-if [[ -n "${TRAVIS}" || -z "${AIRFLOW_CI_REUSE_K8S_IMAGE}" ]] && \
-    docker image inspect "${IMAGE}:${TAG}" > /dev/null 2>/dev/null; then
-  echo "Re-using existing image"
-  exit 0
-fi
-
-if [[ "${VM_DRIVER:-none}" != "none" ]]; then
-    if ENVCONFIG=$(minikube docker-env); then
-      eval "${ENVCONFIG}"
-    fi
-fi
-
 echo "Airflow directory ${AIRFLOW_ROOT}"
 echo "Airflow Docker directory ${DIRNAME}"
 
 cd "${AIRFLOW_ROOT}"
-docker run -ti --rm -v "${AIRFLOW_ROOT}:/airflow" \
-    -w /airflow "${PYTHON_DOCKER_IMAGE}" 
./scripts/ci/kubernetes/docker/compile.sh
+python setup.py compile_assets sdist -q
 
 Review comment:
   I see now. I understand that in your solution you do the same what dind 
image does and instead of using an external dind image, you start docker engine 
inside the airflow-testing image. I understand this is the idea.
   
   That's a bit different to what initially thought. I think there is a big 
value on making the airflow-testing image without dind-modifications. Instead 
it could use docker engine run outside of the airflow-testing image in separate 
`dind` image. The /var/lib/docker.sock is indeed not a good solution either - I 
think using the docker engine from host in general is not a good idea 
(especially if we move to GitLabCI/CloudBuild when we run everything inside 
Kubernetes already). But we have another option - we can start separate ding 
image and connect to it using DOCKER_HOST configuration. It will be using TCP 
rather than socket, but the performance penalty should be small.
   
   I've implemented something similar in GitLab CI POC. You can see the 
implementation here: https://github.com/apache/airflow/pull/6115 . It might be 
an inspiration for you:
   
   * it does not use pass /var/lib/docker.sock (for the reasons mentioned by 
you)
   
   * it starts a separate `dind` image before running docker-compose command 
(as a service in case of GitLab CI). This way from within kubernetes we can 
reach it using DOCKER_HOST="tcp://localhost:2375" and dind image is run in the 
same network (network_mode = host) as the script that runs docker-compose.
   
   * I used it for a different purpose - I used it to build docker images from 
within Kubernetes cluster. In case of GitLab build, the images are built by 
another docker image (Docker-builder) which uses DOCKER_HOST to connect to the 
docker engine run as dind image. 
   
   * But I think you could use the very same approach for kind.  When you run 
docker-compose, you could run the `dind` image as a separate image and connect 
to it from within airflow-testing image (setting DOCKER_HOST appropriately).
   
   I think this will be very small change to your implementation - primary 
difference will be that you will not have to start/stop docker service - it 
will be already running (this was the source of my original comment). And you 
would not have to have /var/lib/docker  as volume (it will be done in dind 
image already).
   
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to