Skip to content

Commit

Permalink
implement shareProcessNamespace in SparkPodSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
ImpSy committed May 20, 2021
1 parent ca473c9 commit d38c1a5
Show file tree
Hide file tree
Showing 10 changed files with 222 additions and 11 deletions.
2 changes: 1 addition & 1 deletion charts/spark-operator-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: spark-operator
description: A Helm chart for Spark on Kubernetes operator
version: 1.1.1
version: 1.1.2
appVersion: v1beta2-1.2.3-3.1.1
keywords:
- spark
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,8 @@ spec:
additionalProperties:
type: string
type: object
shareProcessNamespace:
type: boolean
sidecars:
items:
properties:
Expand Down Expand Up @@ -3007,6 +3009,8 @@ spec:
type: object
serviceAccount:
type: string
shareProcessNamespace:
type: boolean
sidecars:
items:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,8 @@ spec:
additionalProperties:
type: string
type: object
shareProcessNamespace:
type: boolean
sidecars:
items:
properties:
Expand Down Expand Up @@ -2993,6 +2995,8 @@ spec:
type: object
serviceAccount:
type: string
shareProcessNamespace:
type: boolean
sidecars:
items:
properties:
Expand Down
16 changes: 14 additions & 2 deletions docs/api-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2884,6 +2884,18 @@ string
<p>HostAliases settings for the pod, following the Kubernetes specifications.</p>
</td>
</tr>
<tr>
<td>
<code>shareProcessNamespace</code></br>
<em>
bool
</em>
</td>
<td>
<em>(Optional)</em>
<p>ShareProcessNamespace settings for the pod, following the Kubernetes specifications.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="sparkoperator.k8s.io/v1beta2.SparkUIConfiguration">SparkUIConfiguration
Expand Down Expand Up @@ -2918,7 +2930,7 @@ TargetPort should be the same as the one defined in spark.ui.port</p>
</tr>
<tr>
<td>
<code>ServicePortName</code></br>
<code>servicePortName</code></br>
<em>
string
</em>
Expand Down Expand Up @@ -2975,5 +2987,5 @@ map[string]string
<hr/>
<p><em>
Generated with <code>gen-crd-api-reference-docs</code>
on git commit <code>eb07ee0</code>.
on git commit <code>e616816</code>.
</em></p>
31 changes: 28 additions & 3 deletions manifest/crds/sparkoperator.k8s.io_scheduledsparkapplications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: (unknown)
creationTimestamp: null
name: scheduledsparkapplications.sparkoperator.k8s.io
spec:
group: sparkoperator.k8s.io
Expand Down Expand Up @@ -508,6 +507,17 @@ spec:
- name
- quantity
type: object
hostAliases:
items:
properties:
hostnames:
items:
type: string
type: array
ip:
type: string
type: object
type: array
hostNetwork:
type: boolean
image:
Expand Down Expand Up @@ -1295,6 +1305,8 @@ spec:
additionalProperties:
type: string
type: object
shareProcessNamespace:
type: boolean
sidecars:
items:
properties:
Expand Down Expand Up @@ -2307,6 +2319,17 @@ spec:
- name
- quantity
type: object
hostAliases:
items:
properties:
hostnames:
items:
type: string
type: array
ip:
type: string
type: object
type: array
hostNetwork:
type: boolean
image:
Expand Down Expand Up @@ -2986,6 +3009,8 @@ spec:
type: object
serviceAccount:
type: string
shareProcessNamespace:
type: boolean
sidecars:
items:
properties:
Expand Down Expand Up @@ -3614,6 +3639,8 @@ spec:
maximum: 49151
minimum: 1024
type: integer
portName:
type: string
required:
- jmxExporterJar
type: object
Expand Down Expand Up @@ -3686,8 +3713,6 @@ spec:
servicePort:
format: int32
type: integer
serviceType:
type: string
type: object
sparkVersion:
type: string
Expand Down
33 changes: 28 additions & 5 deletions manifest/crds/sparkoperator.k8s.io_sparkapplications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: (unknown)
creationTimestamp: null
name: sparkapplications.sparkoperator.k8s.io
spec:
group: sparkoperator.k8s.io
Expand Down Expand Up @@ -494,6 +493,17 @@ spec:
- name
- quantity
type: object
hostAliases:
items:
properties:
hostnames:
items:
type: string
type: array
ip:
type: string
type: object
type: array
hostNetwork:
type: boolean
image:
Expand Down Expand Up @@ -1281,6 +1291,8 @@ spec:
additionalProperties:
type: string
type: object
shareProcessNamespace:
type: boolean
sidecars:
items:
properties:
Expand Down Expand Up @@ -2293,6 +2305,17 @@ spec:
- name
- quantity
type: object
hostAliases:
items:
properties:
hostnames:
items:
type: string
type: array
ip:
type: string
type: object
type: array
hostNetwork:
type: boolean
image:
Expand Down Expand Up @@ -2972,6 +2995,8 @@ spec:
type: object
serviceAccount:
type: string
shareProcessNamespace:
type: boolean
sidecars:
items:
properties:
Expand Down Expand Up @@ -3600,6 +3625,8 @@ spec:
maximum: 49151
minimum: 1024
type: integer
portName:
type: string
required:
- jmxExporterJar
type: object
Expand Down Expand Up @@ -3672,10 +3699,6 @@ spec:
servicePort:
format: int32
type: integer
servicePortName:
type: string
serviceType:
type: string
type: object
sparkVersion:
type: string
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/sparkoperator.k8s.io/v1beta2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,9 @@ type SparkPodSpec struct {
// HostAliases settings for the pod, following the Kubernetes specifications.
// +optional
HostAliases []apiv1.HostAlias `json:"hostAliases,omitempty"`
// ShareProcessNamespace settings for the pod, following the Kubernetes specifications.
// +optional
ShareProcessNamespace *bool `json:"shareProcessNamespace,omitempty"`
}

// DriverSpec is specification of the driver.
Expand Down
36 changes: 36 additions & 0 deletions pkg/apis/sparkoperator.k8s.io/v1beta2/zz_generated.deepcopy.go

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

20 changes: 20 additions & 0 deletions pkg/webhook/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ func patchSparkPod(pod *corev1.Pod, app *v1beta2.SparkApplication) []patchOperat
patchOps = append(patchOps, *op)
}

op = addShareProcessNamespace(pod, app)
if op != nil {
patchOps = append(patchOps, *op)
}

return patchOps
}

Expand Down Expand Up @@ -834,3 +839,18 @@ func addHostAliases(pod *corev1.Pod, app *v1beta2.SparkApplication) []patchOpera
}
return ops
}

func addShareProcessNamespace(pod *corev1.Pod, app *v1beta2.SparkApplication) *patchOperation {
var shareProcessNamespace *bool
if util.IsDriverPod(pod) {
shareProcessNamespace = app.Spec.Driver.ShareProcessNamespace
}
if util.IsExecutorPod(pod) {
shareProcessNamespace = app.Spec.Executor.ShareProcessNamespace
}

if shareProcessNamespace == nil || *shareProcessNamespace == false {
return nil
}
return &patchOperation{Op: "add", Path: "/spec/shareProcessNamespace", Value: *shareProcessNamespace}
}
Loading

0 comments on commit d38c1a5

Please sign in to comment.