Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-22960][k8s] Make build-push-docker-images.sh more dev-friendly. #20154

Closed
wants to merge 5 commits into from

Conversation

vanzin
Copy link
Contributor

@vanzin vanzin commented Jan 4, 2018

  • Make it possible to build images from a git clone.
  • Make it easy to use minikube to test things.

Also fixed what seemed like a bug: the base image wasn't getting the tag
provided in the command line. Adding the tag allows users to use multiple
Spark builds in the same kubernetes cluster.

Tested by deploying images on minikube and running spark-submit from a dev
environment; also by building the images with different tags and verifying
"docker images" in minikube.

- Make it possible to build images from a git clone.
- Make it easy to use minikube to test things.

Also fixed what seemed like a bug: the base image wasn't getting the tag
provided in the command line. Adding the tag allows users to use multiple
Spark builds in the same kubernetes cluster.

Tested by deploying images on minikube and running spark-submit from a dev
environment; also by building the images with different tags and verifying
"docker images" in minikube.
@vanzin
Copy link
Contributor Author

vanzin commented Jan 4, 2018

@foxish @liyinan926

Copy link
Contributor

@foxish foxish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @vanzin. I think this is a definite improvement for the dev workflow. I have a few comments on the minikube specific bits however.

@@ -16,6 +16,8 @@ Kubernetes scheduler that has been added to Spark.
you may setup a test cluster on your local machine using
[minikube](https://kubernetes.io/docs/getting-started-guides/minikube/).
* We recommend using the latest release of minikube with the DNS addon enabled.
* Be aware that the default minikube configuration is not enough for running Spark applications.
You will need to increase the available memory and number of CPUs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we're going into detail, we should specify a certain config here. 6G of memory and at least 2 CPUs? @liyinan926, do you recall what we typically need for SparkPi?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Driver + default minikube overhead uses 1.25 CPUs from what I remember seeing in the dashboard. Don't remember the memory usage. So I'd say 4 CPUs + 4g of memory (to allow driver + single executor), 6g if you want two executors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember 3 cpus are the minimum, considering that kube-system pods will use some CPU cores. For me, 4G of memory worked fine.

if ! which minikube 1>/dev/null; then
error "Cannot find minikube."
fi
eval $(minikube docker-env)
Copy link
Contributor

@foxish foxish Jan 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think building docker images right into the minikube VM's docker daemon is uncommon and not something we'd want to recommend. Users on minikube should also use a proper registry - (for example, there is a registry addon) that could be used.

While this might be good to document as a local developer workflow, I'm apprehensive about adding a new flag just for this particular mode. Also one could invoke eval $(minikube docker-env) and then use the build command to get the same effect.

Copy link
Contributor Author

@vanzin vanzin Jan 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started calling that command separately, but it's really annoying. This option is useful not just for Spark devs, but for people who want to try their own apps on minikube before trying them on a larger cluster, for example.

building docker images right into the minikube VM's docker daemon is uncommon

What's the alternative? Deploying your own registry? I struggled with that for hours and it's nearly impossible to get docker to talk to an insecure registry (or one with a self signed cert like minikube's). This approach just worked (tm).

Copy link
Contributor

@foxish foxish Jan 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point - this is considerably easier. I spoke with a minikube maintainer and it seems this is not as uncommon as I initially thought. So, this change looks good, but I'd prefer that we add some more explanation to the usage section, that this will build an image within the minikube environment - and also linking to https://kubernetes.io/docs/getting-started-guides/minikube/#reusing-the-docker-daemon.

cc/ @aaron-prindle

fi

if [ ! -d "$IMG_PATH" ]; then
error "Cannot find docker images. This script must be run from a runnable distribution of Apache Spark."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this comment? I presume now it should say runnable distribution, or from source.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The source directory is sort of a "runnable distribution" if Spark is built. I'd rather keep the message simple since it's mostly targeted at end users (not devs).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

-m Use minikube's Docker daemon.

Using minikube when building images will do so directly into minikube's Docker daemon.
There is no need to push the images into minikube int that case, they'll be automatically
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo int -> in.

Copy link
Contributor

@foxish foxish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after nits. Thanks!

Status and logs of failed executor pods can be checked in similar ways. Finally, deleting the driver pod will clean up the entire spark
application, includling all executors, associated service, etc. The driver pod can be thought of as the Kubernetes representation of
Status and logs of failed executor pods can be checked in similar ways. Finally, deleting the driver pod will clean up the entire spark
application, includling all executors, associated service, etc. The driver pod can be thought of as the Kubernetes representation of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also just noticed another typo here. includling -> including

@SparkQA
Copy link

SparkQA commented Jan 4, 2018

Test build #85685 has finished for PR 20154 at commit 2ce48f9.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jan 4, 2018

Test build #85688 has finished for PR 20154 at commit e1ea8a7.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jan 5, 2018

Test build #85697 has finished for PR 20154 at commit ef99214.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Jan 5, 2018

Test build #85696 has finished for PR 20154 at commit 9a2d6d3.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@vanzin
Copy link
Contributor Author

vanzin commented Jan 5, 2018

Merging to master / 2.3.

asfgit pushed a commit that referenced this pull request Jan 5, 2018
- Make it possible to build images from a git clone.
- Make it easy to use minikube to test things.

Also fixed what seemed like a bug: the base image wasn't getting the tag
provided in the command line. Adding the tag allows users to use multiple
Spark builds in the same kubernetes cluster.

Tested by deploying images on minikube and running spark-submit from a dev
environment; also by building the images with different tags and verifying
"docker images" in minikube.

Author: Marcelo Vanzin <[email protected]>

Closes #20154 from vanzin/SPARK-22960.

(cherry picked from commit 0428368)
Signed-off-by: Marcelo Vanzin <[email protected]>
@asfgit asfgit closed this in 0428368 Jan 5, 2018
Copy link
Member

@felixcheung felixcheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to note, to publish to the ASF official project on Docker Hub https://hub.docker.com/u/apache/, ASF INFRA supports the use of Docker Hub's automated build, which doesn't use script or ARGS and typically only with the Dockerfile itself docker/hub-feedback#508 (workaround suggested in this)

@vanzin
Copy link
Contributor Author

vanzin commented Jan 5, 2018

ARGs can have default values, so we could do that if we decide to use the Docker Hub infra. Also the docker file depends on the Spark build being present locally, so that's probably another thing that would not work as expected there.

@liyinan926
Copy link
Contributor

liyinan926 commented Jan 5, 2018

@vanzin it seems using ARG in FROM is only supported since Docker version 17.06. It does not work for earlier versions of Docker. I verified that it didn't work on an older version of Docker. See https://stackoverflow.com/questions/40273070/docker-build-arg-in-source-file. I think we should revert the base_image arg.

@vanzin
Copy link
Contributor Author

vanzin commented Jan 5, 2018

That kinda sucks. It means the base image cannot have a tag so working with multiple Spark versions will be a little weird. Anyway, feel free to open a PR to revert that part.

@vanzin vanzin deleted the SPARK-22960 branch January 5, 2018 22:35
asfgit pushed a commit that referenced this pull request Jan 6, 2018
## What changes were proposed in this pull request?

This PR reverts the `ARG base_image` before `FROM` in the images of driver, executor, and init-container, introduced in #20154. The reason is Docker versions before 17.06 do not support this use (`ARG` before `FROM`).

## How was this patch tested?

Tested manually.

vanzin foxish kimoonkim

Author: Yinan Li <[email protected]>

Closes #20170 from liyinan926/master.

(cherry picked from commit bf65cd3)
Signed-off-by: Marcelo Vanzin <[email protected]>
@felixcheung
Copy link
Member

that's good, I think we should still address the finer point of #20154 (review)

  • if docker hub can't build spark-base then pretty much we are crossing out the possibility of releasing the docker images with 2.3.0 release as ASF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants