-
Notifications
You must be signed in to change notification settings - Fork 117
Allow customizing external URI provision + External URI can be set via annotations #147
Allow customizing external URI provision + External URI can be set via annotations #147
Conversation
|
@mccheah FYI, the Travis build failed not because of unit tests but because of style issues:
|
docs/running-on-kubernetes.md
Outdated
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.
This could perhaps be more concise or clear. Would appreciate anyone's thoughts on how this could be better explained.
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.
@ash211 I swapped the order here of the tryWithResource and try-finally blocks mainly because we want to clean up the secrets and the shutdown hooks after the pod has been launched but also before the application itself completes.
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.
why do we need to do switch to shutdown hooks? those accumulate this global state and you start ending up having ordering issues (like you had with priorities) that I think is best avoided. Can we keep as try-finally blocks instead?
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.
try-finally doesn't catch the case when the JVM is stopped via a kill signal. I suppose the big question mark is if we care about such scenarios. The rest of the Spark ecosystem relies on shutdown hooks greatly to clear up all kinds of temporary state.
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.
It may be the case that the external URI providers take a little longer to be ready. In testing #70 I noticed that the Ingress can take awhile to set up in the background.
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.
Although I think this highlights that we have an API discrepancy here. We document that the driverServiceManager will build the service that will end up being used, but the code still manipulates the created service after the fact to avoid exposing the NodePort. There's also the extra configuration parameter spark.kubernetes.driver.service.exposeUiPort. There should be a way to reconcile all of these configurations.
docs/running-on-kubernetes.md
Outdated
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.
To use a manually-specified external IP instead of a Kubelet's IP, ...
docs/running-on-kubernetes.md
Outdated
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.
This will create a service with the annotation XYZ that routes to the driver pod
docs/running-on-kubernetes.md
Outdated
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.
provide an example URI, e.g. https://example.com:8080/my-job
docs/running-on-kubernetes.md
Outdated
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 service-loaded class should be the value of that setting? e.g. spark.kubernetes.driver.serviceManagerType =com.mycompany.spark.MyCustomDriverServiceManager ?
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.
It is not - the value here matches what is returned by DriverServiceManager#getType.
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 advantage of this is that the configuration value becomes easier to set for the things we bundle into it - NodePort vs. ExternalAnnotation and eventually ApiServerProxy is more elegant to remember than full class names.
docs/running-on-kubernetes.md
Outdated
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.
we should also provide an implementation of this that uploads through the apiserver proxy
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.
Think this can be left for future work.
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.
put this method at the end so the flow is top to bottom. getServiceManagerType is called first, then customizeDriverService, then getDriverServiceSubmissionServerUris
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 this service cleanup after the job is submitted should be part of the plugin point, rather than the core always opinionatedly deleting the service after the job has submitted.
Alternatively the contract could be that any created k8s resources need to have owner references to the service so that when Spark deletes the service the dependent resources are cleaned up too
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.
It's different here because the service isn't deleted, but rather it is manipulated such that its type becomes ClusterIP and it no longer exposes the submission server over the Node Port. Regardless there is still the question of whether or not the plugin should be the component that makes this decision or if it's universal.
docs/running-on-kubernetes.md
Outdated
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.
provide a list of bundled implementations in a bullet list here -- right now this is just NodePort and ExternalAnnotation but I also think we should do a ServerApi also
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.
Didn't want to try to embed a bullet-list in the table - but added the valid values in prose form.
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.
why do we need to do switch to shutdown hooks? those accumulate this global state and you start ending up having ordering issues (like you had with priorities) that I think is best avoided. Can we keep as try-finally blocks instead?
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.
these comments got disconnected from the LoggingPodStatusWatcher code
|
Haven't done a full review yet of the code. On the docs front, one broad comment: |
|
Also, this PR should be targeted towards k8s-support-alternate-incremental? It is pointing at the ssl branch as of now. |
3e34edb to
ba50538
Compare
|
@foxish any more thoughts on this PR? |
ash211
left a comment
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.
Some minor docs suggestions
docs/running-on-kubernetes.md
Outdated
|
|
||
| There may be cases where the nodes cannot be reached by the submission client. For example, the cluster may | ||
| only be reachable through an external load balancer. The user may provide their own external IP for Spark driver | ||
| services. To use a your own external IP instead of a node's IP, first set |
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.
external IP -> external URI
docs/running-on-kubernetes.md
Outdated
| services. To use a your own external IP instead of a node's IP, first set | ||
| `spark.kubernetes.driver.serviceManagerType` to `ExternalAnnotation`. A service will be created with the annotation | ||
| `spark-job.alpha.apache.org/provideExternalUri`, and this service routes to the driver pod. You will need to run a | ||
| process that watches the API server for services that are created with this annotation in the application's namespace |
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.
separate process
docs/running-on-kubernetes.md
Outdated
| `spark.kubernetes.driver.serviceManagerType` to `ExternalAnnotation`. A service will be created with the annotation | ||
| `spark-job.alpha.apache.org/provideExternalUri`, and this service routes to the driver pod. You will need to run a | ||
| process that watches the API server for services that are created with this annotation in the application's namespace | ||
| (set by `spark.kubernetes.namespace`). The process should determine a URI that routes to this service, and patch the |
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.
... that routes to this service (potentially configuring infrastructure to handle the URI behind the scenes), and patch ...
docs/running-on-kubernetes.md
Outdated
| URI that your process has provided (e.g. `https://example.com:8080/my-job`). | ||
|
|
||
| Note that if the URI provided by the annotation also provides a base path, the base path should be removed when the | ||
| request is forwarded to the back end pod. |
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'm not following this sentence. If the Spark code ignores the base path, then let's throw when the external URI provider gives a URI with a base path? Alternatively probably we should support submitting through a base path since some external URI providers may route based on base-path and require the base path for traffic to reach the underlying spark submit service
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 external URI can include a base path, just that when the request reaches the back end pod, the back end pod should be contacted at an empty base path. In the case that you describe where the external URI provider requires a base path, the URI provider should also rewrite the URI when forwarding to the back end to remove the base path. I'm not sure of the best way to phrase this.
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.
Ah, maybe something like:
Note that the URI provided in the annotation needs to route traffic to the appropriate destination on the pod, which has a fixed path portion of the URI. This means the external URI provider will likely need to rewrite the path from the external URI to the destination on the pod, e.g. https://example.com:8080/spark-app-1/submit will need to route traffic to https://<pod_ip>:<service_port>/path/to/submit. Note that the paths of these two URLs are different.
I'm not sure what the destination /path/to/submit actually is in Spark -- could use some help there.
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.
Done - the path is empty on the back end.
|
|
||
| If the above is confusing, keep in mind that this functionality is only necessary if the submitter cannot reach any of | ||
| the nodes at the driver's node port. It is recommended to use the default configuration with the node port service | ||
| whenever possible. |
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.
mention that there's a way to serviceload implementations of this here
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 don't think we should include the service loading note here - it's a pretty advanced use case and is already covered in the configuration table below.
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.
Mostly because this section is confusing as it is - wouldn't want to add to the confusion here.
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.
Ah right, missed that it's mentioned in the config table.
docs/running-on-kubernetes.md
Outdated
| <td> | ||
| A tag indicating which class to use for creating the Kubernetes service and determining its URI for the submission | ||
| client. Valid values are currently <code>NodePort</code> and <code>ExternalAnnotation</code>. By default, a service | ||
| is created with the NodePort type, and the driver will be contacted at one of the kubelet nodes at the port that the |
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.
since NodePort is a config value in this paragraph, make sure it's always wrapped in code tags
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.
It's not exactly a config value when stating "a service is created with the NodePort type" - NodePort is the type of the service in this case. Granted, NodePort is a term that is overloaded in this case. Marked it with code tags anyways.
|
LGTM |
ash211
left a comment
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.
Looks good to me, though there's a merge conflict now
…te-incremental' into external-uri-provider
|
One of the travis checks failed and it looked like a flake (couldn't find |
|
Passed this time -- merging! |
…a annotations (#147) * Listen for annotations that provide external URIs. * FIx scalstyle * Address comments * Fix doc style * Docs updates * Clearly explain path rewrites
…a annotations (#147) * Listen for annotations that provide external URIs. * FIx scalstyle * Address comments * Fix doc style * Docs updates * Clearly explain path rewrites
…a annotations (apache-spark-on-k8s#147) * Listen for annotations that provide external URIs. * FIx scalstyle * Address comments * Fix doc style * Docs updates * Clearly explain path rewrites (cherry picked from commit f0a40b8)
…a annotations (apache-spark-on-k8s#147) * Listen for annotations that provide external URIs. * FIx scalstyle * Address comments * Fix doc style * Docs updates * Clearly explain path rewrites
Closes #140.