-
Notifications
You must be signed in to change notification settings - Fork 28.4k
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
Conversation
- 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.
There was a problem hiding this 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.
docs/running-on-kubernetes.md
Outdated
@@ -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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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." |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
sbin/build-push-docker-images.sh
Outdated
-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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo int -> in.
There was a problem hiding this 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!
docs/running-on-kubernetes.md
Outdated
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 |
There was a problem hiding this comment.
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
Test build #85685 has finished for PR 20154 at commit
|
Test build #85688 has finished for PR 20154 at commit
|
Test build #85697 has finished for PR 20154 at commit
|
Test build #85696 has finished for PR 20154 at commit
|
Merging to master / 2.3. |
- 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]>
There was a problem hiding this 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)
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. |
@vanzin it seems using |
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. |
## 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]>
that's good, I think we should still address the finer point of #20154 (review)
|
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.