Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/.licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ header:
- gradlew
- 'build/**'
- '**/*.json'
- '**/.helmignore'

comment: on-failure
3 changes: 3 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ jobs:
- name: Build with Gradle
run: |
./gradlew build
- name: Validate helm chart linting
run: |
helm lint --strict build-tools/helm/spark-kubernetes-operator
build-image:
name: "Build Operator Image CI"
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
.vscode
/lib/
target/
build-tools/helm/spark-kubernetes-operator/crds

# Gradle Files #
################
Expand Down
12 changes: 12 additions & 0 deletions build-tools/helm/spark-kubernetes-operator/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.DS_Store
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
21 changes: 21 additions & 0 deletions build-tools/helm/spark-kubernetes-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: v2
name: spark-kubernetes-operator
description: A Helm chart for the Apache Spark Kubernetes Operator
type: application
version: 0.1.0-SNAPSHOT
appVersion: 0.1.0
icon: https://spark.apache.org/favicon.ico
146 changes: 146 additions & 0 deletions build-tools/helm/spark-kubernetes-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

{{/*
Expand the name of the chart.
*/}}
{{- define "spark-operator.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "spark-operator.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "spark-operator.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end }}

{{/*
Common labels
*/}}
{{- define "spark-operator.commonLabels" -}}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "spark-operator.chart" . }}
{{- end }}

{{/*
Dynamic config (hot properties) labels
*/}}
{{- define "spark-operator.dynamicConfigLabels" -}}
app.kubernetes.io/name: {{ include "spark-operator.name" . }}
app.kubernetes.io/component: "operator-dynamic-config-overrides"
{{- include "spark-operator.commonLabels" . }}
{{- end }}

{{/*
Bootstrap config labels
*/}}
{{- define "spark-operator.configLabels" -}}
app.kubernetes.io/name: {{ include "spark-operator.name" . }}
app.kubernetes.io/component: "operator-config"
{{- include "spark-operator.commonLabels" . }}
{{- end }}

{{/*
Deployment selector labels
*/}}
{{- define "spark-operator.deploymentSelectorLabels" -}}
app.kubernetes.io/name: {{ include "spark-operator.name" . }}
app.kubernetes.io/component: "operator-deployment"
{{- end }}

{{/*
Create the path of the operator image to use
*/}}
{{- define "spark-operator.imagePath" -}}
{{- if .Values.image.digest }}
{{- .Values.image.repository }}@{{ .Values.image.digest }}
{{- else }}
{{- .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}
{{- end }}
{{- end }}

{{/*
List of Spark app namespaces. If not provied in values, use the same namespace as operator
*/}}
{{- define "spark-operator.appNamespacesStr" -}}
{{- if index (.Values.appResources.namespaces) "data" }}
{{- $ns_list := join "," .Values.appResources.namespaces.data }}
{{- printf "%s" $ns_list }}
{{- else }}
{{- printf "%s" .Release.Namespace }}
{{- end }}
{{- end }}

{{/*
Default property overrides
*/}}
{{- define "spark-operator.defaultPropertyOverrides" -}}
# Runtime resolved properties
spark.kubernetes.operator.namespace={{ .Release.Namespace }}
spark.kubernetes.operator.name={{- include "spark-operator.name" . }}
spark.kubernetes.operator.dynamicConfig.enabled={{ .Values.operatorConfiguration.dynamicConfig.enable }}
{{- if .Values.appResources.namespaces.overrideWatchedNamespaces }}
spark.kubernetes.operator.watchedNamespaces={{ include "spark-operator.appNamespacesStr" . | trim }}
{{- end }}
{{- end }}

{{/*
Readiness Probe properties overrides
*/}}
{{- define "spark-operator.readinessProbe.failureThreshold" -}}
{{- default 30 .Values.operatorDeployment.operatorPod.operatorContainer.probes.startupProbe.failureThreshold }}
{{- end }}
{{- define "spark-operator.readinessProbe.periodSeconds" -}}
{{- default 10 .Values.operatorDeployment.operatorPod.operatorContainer.probes.startupProbe.periodSeconds }}
{{- end }}

{{/*
Liveness Probe properties override
*/}}
{{- define "spark-operator.livenessProbe.initialDelaySeconds" -}}
{{- default 30 .Values.operatorDeployment.operatorPod.operatorContainer.probes.livenessProbe.initialDelaySeconds }}
{{- end }}
{{- define "spark-operator.livenessProbe.periodSeconds" -}}
{{- default 10 .Values.operatorDeployment.operatorPod.operatorContainer.probes.livenessProbe.periodSeconds }}
{{- end }}

{{/*
Readiness Probe property overrides
*/}}
{{- define "spark-operator.probePort" -}}
{{- default 19091 .Values.operatorDeployment.operatorPod.operatorContainer.probes.port }}
{{- end }}
176 changes: 176 additions & 0 deletions build-tools/helm/spark-kubernetes-operator/templates/app-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

{{/*
RBAC rules used to create the app (cluster)role based on the scope
*/}}
{{- define "spark-operator.appRbacRules" }}
rules:
- apiGroups:
- ""
resources:
- pods
- services
- configmaps
- persistentvolumeclaims
verbs:
- '*'
{{- end }}

{{/*
RoleRef for app service account rolebindings
*/}}
{{- define "spark-operator.appRoleRef" }}
roleRef:
apiGroup: rbac.authorization.k8s.io
{{- if .Values.appResources.clusterRole.create }}
kind: ClusterRole
name: {{ .Values.appResources.clusterRole.name }}
{{- else }}
kind: Role
name: {{ .Values.appResources.role.name }}
{{- end }}
{{- end }}

{{/*
Labels and annotations to be applied
*/}}
{{- define "spark-operator.appLabels" -}}
{{- with .Values.appResources.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- include "spark-operator.commonLabels" . | nindent 4 }}
{{- end }}

{{- define "spark-operator.appAnnotations" -}}
{{- with .Values.appResources.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

{{- define "spark-operator.appLabelsAnnotations" }}
labels:
{{ template "spark-operator.appLabels" $ }}
annotations:
{{ template "spark-operator.appAnnotations" $ }}
{{- end }}
---
{{- $appResources := .Values.appResources -}}
{{- $systemNs := .Release.Namespace -}}
{{- $operatorRbac := .Values.operatorRbac -}}
{{- if index (.Values.appResources.namespaces) "data" }}
{{- range $appNs := .Values.appResources.namespaces.data }}
{{- if $appResources.namespaces.create }}
apiVersion: v1
kind: Namespace
metadata:
name: {{ $appNs }}
{{- template "spark-operator.appLabelsAnnotations" $ }}
---
{{- end }}
{{- if $appResources.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ $appResources.serviceAccount.name }}
namespace: {{ $appNs }}
{{- template "spark-operator.appLabelsAnnotations" $ }}
---
{{- end }}
{{- if $appResources.role.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ $appResources.role.name }}
namespace: {{ $appNs }}
{{- template "spark-operator.appLabelsAnnotations" $ }}
{{- template "spark-operator.appRbacRules" $ }}
---
{{- end }}
{{- if $appResources.roleBinding.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ $appResources.roleBinding.name }}
namespace: {{ $appNs }}
{{- template "spark-operator.appLabelsAnnotations" $ }}
{{- template "spark-operator.appRoleRef" $ }}
subjects:
- kind: ServiceAccount
name: {{ $appResources.serviceAccount.name }}
namespace: {{ $appNs }}
---
{{- end }}
{{- end }}
{{- else }}
{{- if $appResources.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ $appResources.serviceAccount.name }}
namespace: {{ $systemNs }}
{{- template "spark-operator.appLabelsAnnotations" $ }}
---
{{- end }}
{{- if $appResources.role.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ $appResources.role.name }}
namespace: {{ $systemNs }}
{{- template "spark-operator.appLabelsAnnotations" $ }}
{{- template "spark-operator.appRbacRules" $ }}
---
{{- end }}
{{- if $appResources.roleBinding.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ $appResources.serviceAccount.name }}
namespace: {{ $systemNs }}
{{- template "spark-operator.appLabelsAnnotations" $ }}
{{- template "spark-operator.appRoleRef" $ }}
subjects:
- kind: ServiceAccount
name: {{ $appResources.serviceAccount.name }}
namespace: {{ $systemNs }}
---
{{- end }}
{{- end }}

{{- if $appResources.clusterRole.create }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ $appResources.clusterRole.name }}
{{- template "spark-operator.appLabelsAnnotations" $ }}
{{- template "spark-operator.appRbacRules" $ }}
---
{{- end }}
{{- if $appResources.sparkApplicationSentinel.create }}
{{- range $sentinelNs := .Values.appResources.sparkApplicationSentinel.sentinelNamespaces.data }}
apiVersion: org.apache.spark/v1alpha1
kind: SparkApplication
metadata:
name: {{ $appResources.sparkApplicationSentinel.name }}
namespace: {{ $sentinelNs }}
labels:
"spark.operator/sentinel": "true"
{{- template "spark-operator.appLabels" $ }}
annotations:
{{- template "spark-operator.appAnnotations" $ }}
{{- end }}
---
{{- end }}
Loading