Skip to content
4 changes: 4 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ linters:
- linters:
- staticcheck
text: "SA1019: .*\\.Requeue is deprecated: Use `RequeueAfter` instead."
# exclude staticcheck SA1019 for client deploy mode until it is removed, see #3253.
- linters:
- staticcheck
text: "SA1019: v1beta2.DeployModeClient is deprecated"

issues:
# Maximum issues count per one linter.
Expand Down
2 changes: 1 addition & 1 deletion api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -14484,7 +14484,7 @@
"type": "string"
},
"mode": {
"description": "Mode is the deployment mode of the Spark application.",
"description": "Mode is the deployment mode of the Spark application. The client mode is deprecated and will be removed in the next API version.",
"type": "string"
},
"monitoring": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class SparkV1beta2SparkApplicationSpec(BaseModel):
main_class: Optional[StrictStr] = Field(default=None, description="MainClass is the fully-qualified main class of the Spark application. This only applies to Java/Scala Spark applications.", alias="mainClass")
managed_by: Optional[StrictStr] = Field(default=None, description="ManagedBy indicates the controller managing this SparkApplication. Set to \"sparkoperator.k8s.io/spark-operator\" for the built-in operator (default behavior when field is omitted) or \"kueue.x-k8s.io/multikueue\" to delegate reconciliation to MultiKueue. The field is immutable once set.", alias="managedBy")
memory_overhead_factor: Optional[StrictStr] = Field(default=None, description="This sets the Memory Overhead Factor that will allocate memory to non-JVM memory. For JVM-based jobs this value will default to 0.10, for non-JVM jobs 0.40. Value of this field will be overridden by `Spec.Driver.MemoryOverhead` and `Spec.Executor.MemoryOverhead` if they are set.", alias="memoryOverheadFactor")
mode: Optional[StrictStr] = Field(default=None, description="Mode is the deployment mode of the Spark application.")
mode: Optional[StrictStr] = Field(default=None, description="Mode is the deployment mode of the Spark application. The client mode is deprecated and will be removed in the next API version.")
monitoring: Optional[SparkV1beta2MonitoringSpec] = Field(default=None, description="Monitoring configures how monitoring is handled.")
node_selector: Optional[Dict[str, StrictStr]] = Field(default=None, description="NodeSelector is the Kubernetes node selector to be added to the driver and executor pods. This field is mutually exclusive with nodeSelector at podSpec level (driver or executor). This field will be deprecated in future versions (at SparkApplicationSpec level).", alias="nodeSelector")
proxy_user: Optional[StrictStr] = Field(default=None, description="ProxyUser specifies the user to impersonate when submitting the application. It maps to the command-line flag \"--proxy-user\" in spark-submit.", alias="proxyUser")
Expand Down
7 changes: 5 additions & 2 deletions api/v1beta2/sparkapplication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type SparkApplicationSpec struct {
// SparkVersion is the version of Spark the application uses.
SparkVersion string `json:"sparkVersion"`
// Mode is the deployment mode of the Spark application.
// The client mode is deprecated and will be removed in the next API version.
// +kubebuilder:validation:Enum={cluster,client}
Mode DeployMode `json:"mode,omitempty"`
// ProxyUser specifies the user to impersonate when submitting the application.
Expand Down Expand Up @@ -242,8 +243,10 @@ type DeployMode string

// Different types of deployments.
const (
DeployModeCluster DeployMode = "cluster"
DeployModeClient DeployMode = "client"
DeployModeCluster DeployMode = "cluster"
// Deprecated: client mode will be removed in the next API version, see https://github.com/kubeflow/spark-operator/issues/3253.
DeployModeClient DeployMode = "client"
// Deprecated: in-cluster-client mode will be removed in the next API version, see https://github.com/kubeflow/spark-operator/issues/3253.
DeployModeInClusterClient DeployMode = "in-cluster-client"
)

Expand Down
2 changes: 1 addition & 1 deletion api/v1beta2/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10871,7 +10871,9 @@ spec:
be overridden by `Spec.Driver.MemoryOverhead` and `Spec.Executor.MemoryOverhead` if they are set.
type: string
mode:
description: Mode is the deployment mode of the Spark application.
description: |-
Mode is the deployment mode of the Spark application.
The client mode is deprecated and will be removed in the next API version.
enum:
- cluster
- client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10792,7 +10792,9 @@ spec:
be overridden by `Spec.Driver.MemoryOverhead` and `Spec.Executor.MemoryOverhead` if they are set.
type: string
mode:
description: Mode is the deployment mode of the Spark application.
description: |-
Mode is the deployment mode of the Spark application.
The client mode is deprecated and will be removed in the next API version.
enum:
- cluster
- client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10871,7 +10871,9 @@ spec:
be overridden by `Spec.Driver.MemoryOverhead` and `Spec.Executor.MemoryOverhead` if they are set.
type: string
mode:
description: Mode is the deployment mode of the Spark application.
description: |-
Mode is the deployment mode of the Spark application.
The client mode is deprecated and will be removed in the next API version.
enum:
- cluster
- client
Expand Down
4 changes: 3 additions & 1 deletion config/crd/bases/sparkoperator.k8s.io_sparkapplications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10792,7 +10792,9 @@ spec:
be overridden by `Spec.Driver.MemoryOverhead` and `Spec.Executor.MemoryOverhead` if they are set.
type: string
mode:
description: Mode is the deployment mode of the Spark application.
description: |-
Mode is the deployment mode of the Spark application.
The client mode is deprecated and will be removed in the next API version.
enum:
- cluster
- client
Expand Down
12 changes: 8 additions & 4 deletions docs/api-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,8 @@ DeployMode
</em>
</td>
<td>
<p>Mode is the deployment mode of the Spark application.</p>
<p>Mode is the deployment mode of the Spark application.
The client mode is deprecated and will be removed in the next API version.</p>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -1994,11 +1995,13 @@ given with the &ldquo;packages&rdquo; option.</p>
</tr>
</thead>
<tbody><tr><td><p>&#34;client&#34;</p></td>
<td></td>
<td><p>Deprecated: client mode will be removed in the next API version, see <a href="https://github.com/kubeflow/spark-operator/issues/3253">https://github.com/kubeflow/spark-operator/issues/3253</a>.</p>
</td>
</tr><tr><td><p>&#34;cluster&#34;</p></td>
<td></td>
</tr><tr><td><p>&#34;in-cluster-client&#34;</p></td>
<td></td>
<td><p>Deprecated: in-cluster-client mode will be removed in the next API version, see <a href="https://github.com/kubeflow/spark-operator/issues/3253">https://github.com/kubeflow/spark-operator/issues/3253</a>.</p>
</td>
</tr></tbody>
</table>
<h3 id="sparkoperator.k8s.io/v1beta2.DriverInfo">DriverInfo
Expand Down Expand Up @@ -3443,7 +3446,8 @@ DeployMode
</em>
</td>
<td>
<p>Mode is the deployment mode of the Spark application.</p>
<p>Mode is the deployment mode of the Spark application.
The client mode is deprecated and will be removed in the next API version.</p>
</td>
</tr>
<tr>
Expand Down
8 changes: 6 additions & 2 deletions docs/website/user-guide/writing-sparkapplication.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

As with all other Kubernetes API objects, a `SparkApplication` needs the `apiVersion`, `kind`, and `metadata` fields. For general information about working with manifests, see [object management using kubectl](https://kubernetes.io/docs/concepts/overview/object-management-kubectl/overview/).

A `SparkApplication` also needs a [`.spec` section](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status). This section contains fields for specifying various aspects of an application including its type (`Scala`, `Java`, `Python`, or `R`), deployment mode (`cluster` or `client`), main application resource URI (e.g., the URI of the application jar), main class, arguments, etc. Node selectors are also supported via the optional field `.spec.nodeSelector`.
A `SparkApplication` also needs a [`.spec` section](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status). This section contains fields for specifying various aspects of an application including its type (`Scala`, `Java`, `Python`, or `R`), deployment mode (`cluster`; `client` is deprecated), main application resource URI (e.g., the URI of the application jar), main class, arguments, etc. Node selectors are also supported via the optional field `.spec.nodeSelector`.

It also has fields for specifying the unified container image (to use for both the driver and executors) and the image pull policy, namely, `.spec.image` and `.spec.imagePullPolicy` respectively. If a custom init-container (in both the driver and executor pods) image needs to be used, the optional field `.spec.initContainerImage` can be used to specify it. If set, `.spec.initContainerImage` overrides `.spec.image` for the init-container image. Otherwise, the image specified by `.spec.image` will be used for the init-container. It is invalid if both `.spec.image` and `.spec.initContainerImage` are not set.

Expand All @@ -24,7 +24,11 @@ spec:

## Specifying Deployment Mode

A `SparkApplication` should set `.spec.mode` to `cluster`, as `client` is not currently implemented. The driver pod will then run `spark-submit` in `client` mode internally to run the driver program. Additional details of how `SparkApplication`s are run can be found in the [design documentation](../overview/index.md#architecture).
A `SparkApplication` should set `.spec.mode` to `cluster`. The driver pod will then run `spark-submit` in `client` mode internally to run the driver program. Additional details of how `SparkApplication`s are run can be found in the [design documentation](../overview/index.md#architecture).

:::{warning}
`.spec.mode: client` is deprecated and will be removed in the next API version. Client mode runs the driver inside the operator, which is a security risk. For interactive workloads, use [SparkConnect](spark-connect.md) instead. See [#3253](https://github.com/kubeflow/spark-operator/issues/3253).
:::

## Specifying Application Dependencies

Expand Down
3 changes: 3 additions & 0 deletions internal/controller/sparkapplication/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,9 @@ func (r *Reconciler) getSparkApplication(ctx context.Context, key types.Namespac
func (r *Reconciler) submitSparkApplication(ctx context.Context, app *v1beta2.SparkApplication) {
logger := log.FromContext(ctx)
logger.Info("Submitting SparkApplication", "state", app.Status.AppState.State)
if app.Spec.Mode == v1beta2.DeployModeClient {
logger.Info("Client mode is deprecated and will be removed in the next API version; use cluster mode or SparkConnect instead")
}

// SubmissionID must be set before creating any resources to ensure all the resources are labeled.
app.Status.SubmissionID = uuid.New().String()
Expand Down
4 changes: 2 additions & 2 deletions internal/webhook/scheduledsparkapplication_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (v *ScheduledSparkApplicationValidator) ValidateCreate(ctx context.Context,
if err := v.validate(app); err != nil {
return nil, err
}
return nil, nil
return deprecationWarnings(&app.Spec.Template, field.NewPath("spec", "template")), nil
}

// ValidateUpdate implements admission.Validator.
Expand All @@ -82,7 +82,7 @@ func (v *ScheduledSparkApplicationValidator) ValidateUpdate(ctx context.Context,
if err := v.validate(newApp); err != nil {
return nil, err
}
return nil, nil
return deprecationWarnings(&newApp.Spec.Template, field.NewPath("spec", "template")), nil
Comment thread
vikas-saxena02 marked this conversation as resolved.
Resolved
}

// ValidateDelete implements admission.Validator.
Expand Down
31 changes: 31 additions & 0 deletions internal/webhook/scheduledsparkapplication_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,34 @@ func TestScheduledSparkApplicationValidatorValidateCreate_ConfigMapNames(t *test
t.Fatalf("expected an invalid ConfigMap name error, got %v", err)
}
}

func TestScheduledSparkApplicationValidatorValidateCreate_ClientModeWarning(t *testing.T) {
validator := NewScheduledSparkApplicationValidator()

app := newScheduledSparkApplication()
app.Spec.Template.Mode = v1beta2.DeployModeClient

warnings, err := validator.ValidateCreate(context.Background(), app)
if err != nil {
t.Fatalf("expected success, got %v", err)
}
if len(warnings) != 1 || !strings.Contains(warnings[0], "spec.template.mode: client mode is deprecated") {
t.Fatalf("expected client mode deprecation warning, got %v", warnings)
Comment thread
vikas-saxena02 marked this conversation as resolved.
Resolved
}
}

func TestScheduledSparkApplicationValidatorValidateUpdate_ClientModeWarning(t *testing.T) {
validator := NewScheduledSparkApplicationValidator()

oldApp := newScheduledSparkApplication()
newApp := newScheduledSparkApplication()
newApp.Spec.Template.Mode = v1beta2.DeployModeClient

warnings, err := validator.ValidateUpdate(context.Background(), oldApp, newApp)
if err != nil {
t.Fatalf("expected success, got %v", err)
}
if len(warnings) != 1 || !strings.Contains(warnings[0], "spec.template.mode: client mode is deprecated") {
t.Fatalf("expected client mode deprecation warning, got %v", warnings)
}
}
14 changes: 12 additions & 2 deletions internal/webhook/sparkapplication_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (v *SparkApplicationValidator) ValidateCreate(ctx context.Context, app *v1b
}
}

return nil, nil
return deprecationWarnings(&app.Spec, field.NewPath("spec")), nil
}

// ValidateUpdate implements admission.Validator.
Expand Down Expand Up @@ -110,7 +110,7 @@ func (v *SparkApplicationValidator) ValidateUpdate(ctx context.Context, oldApp *
}
}

return nil, nil
return deprecationWarnings(&newApp.Spec, field.NewPath("spec")), nil
Comment thread
vikas-saxena02 marked this conversation as resolved.
Resolved
}

// ValidateDelete implements admission.Validator.
Expand Down Expand Up @@ -164,6 +164,16 @@ func (v *SparkApplicationValidator) validateSpec(ctx context.Context, app *v1bet
return nil
}

// deprecationWarnings returns admission warnings so users see client mode is deprecated at apply time, see https://github.com/kubeflow/spark-operator/issues/3253.
func deprecationWarnings(spec *v1beta2.SparkApplicationSpec, path *field.Path) admission.Warnings {
if spec.Mode != v1beta2.DeployModeClient {
return nil
}
return admission.Warnings{
fmt.Sprintf("%s: client mode is deprecated and will be removed in the next API version; use cluster mode or SparkConnect instead", path.Child("mode")),
}
}

// validateName ensures the SparkApplication metadata.name is a valid DNS-1035 label
// This prevents failures later when creating related resources like Services which
// require DNS-1035 compliant names.
Expand Down
43 changes: 43 additions & 0 deletions internal/webhook/sparkapplication_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,3 +655,46 @@ func configMapRefs(names ...string) []v1beta2.NamePath {
}
return refs
}

func TestSparkApplicationValidatorValidateCreate_ClientModeWarning(t *testing.T) {
validator := newTestValidator(t, false)

app := newSparkApplication()
app.Spec.Mode = v1beta2.DeployModeClient

warnings, err := validator.ValidateCreate(context.Background(), app)
if err != nil {
t.Fatalf("expected success, got %v", err)
}
if len(warnings) != 1 || !strings.Contains(warnings[0], "spec.mode: client mode is deprecated") {
t.Fatalf("expected client mode deprecation warning, got %v", warnings)
}
}

func TestSparkApplicationValidatorValidateCreate_ClusterModeNoWarning(t *testing.T) {
validator := newTestValidator(t, false)

warnings, err := validator.ValidateCreate(context.Background(), newSparkApplication())
if err != nil {
t.Fatalf("expected success, got %v", err)
}
if len(warnings) != 0 {
t.Fatalf("expected no warnings, got %v", warnings)
}
}

func TestSparkApplicationValidatorValidateUpdate_ClientModeWarning(t *testing.T) {
validator := newTestValidator(t, false)

oldApp := newSparkApplication()
newApp := newSparkApplication()
newApp.Spec.Mode = v1beta2.DeployModeClient

warnings, err := validator.ValidateUpdate(context.Background(), oldApp, newApp)
if err != nil {
t.Fatalf("expected success, got %v", err)
}
if len(warnings) != 1 || !strings.Contains(warnings[0], "spec.mode: client mode is deprecated") {
t.Fatalf("expected client mode deprecation warning, got %v", warnings)
}
}
Loading