Skip to content

Commit

Permalink
[Addon kubevela#603] Add Apache Spark as a experimental addon
Browse files Browse the repository at this point in the history
Signed-off-by: yanghua <yanghua1127@gmail.com>
  • Loading branch information
yanghua committed Feb 7, 2023
1 parent 645b8ab commit e85f8a9
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 0 deletions.
3 changes: 3 additions & 0 deletions addons/spark-kubernetes-operator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# spark-kubernetes-operator

This is an addon template. Check how to build your own addon: https://kubevela.net/docs/platform-engineers/addon/intro
15 changes: 15 additions & 0 deletions addons/spark-kubernetes-operator/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
description: A kubernetes operator for Apache Spark
icon: "https://spark.apache.org/images/spark-logo.png"
invisible: false
name: spark-kubernetes-operator
tags:
- GoogleCloudPlatform/spark-on-k8s-operator
version: v1beta2-1.3.8-3.1.1
url: https://github.com/GoogleCloudPlatform/spark-on-k8s-operator

dependencies:
- name: fluxcd

system:
vela: ">=1.5.0-beta.3"
# kubernetes: ">=1.16"
22 changes: 22 additions & 0 deletions addons/spark-kubernetes-operator/parameter.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// parameter.cue is used to store addon parameters.
//
// You can use these parameters in template.cue or in resources/ by 'parameter.myparam'
//
// For example, you can use parameters to allow the user to customize
// container images, ports, and etc.
parameter: {
// +usage=Custom parameter description
myparam: *"myns" | string
//+usage=Deploy to specified clusters. Leave empty to deploy to all clusters.
clusters?: [...string]
//+usage=Namespace to deploy to, defaults to cert-manager
namespace: *"spark-operator" | string
// +usage=Specify if create the webhook or not
"createWebhook": *true | bool
// +usage=Specify the image repository
"imageRepository": *"ghcr.io/googlecloudplatform/spark-operator" | string
// +usage=Specify the image tag
"imageTag": *"v1beta2-1.3.8-3.1.1" | string
// +usage=Specify if create the sa for job or not
"createSparkServiceAccount": *false|bool
}
8 changes: 8 additions & 0 deletions addons/spark-kubernetes-operator/schemas/myschema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# We put UI Schemas that correspond to Definitions in schemas directory.
# References:
# - https://kubevela.net/docs/platform-engineers/addon/intro#schemas-directoryoptional
# - https://kubevela.net/docs/reference/ui-schema
- jsonKey: myparam
label: MyParam
validate:
required: true
63 changes: 63 additions & 0 deletions addons/spark-kubernetes-operator/template.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package main
output: {
apiVersion: "core.oam.dev/v1beta1"
kind: "Application"
spec: {
components: [
{
type: "k8s-objects"
name: "spark-operator-ns"
properties: objects: [{
apiVersion: "v1"
kind: "Namespace"
metadata: name: parameter.namespace
}]
},
{
name: "spark-operator-helm"
type: "helm"
dependsOn: ["spark-operator-ns"]
type: "helm"
properties: {
repoType: "helm"
url: "https://googlecloudplatform.github.io/spark-on-k8s-operator/"
chart: "spark-operator"
targetNamespace: parameter["namespace"]
version: "1.1.26"
values: {
image: {
repository: parameter["imageRepository"]
tag: parameter["imageTag"]
}

serviceAccounts: {
spark: {
create: parameter["createSparkServiceAccount"]
}
}

serviceAccounts: {
sparkoperator: {
name: "spark-kubernetes-operator"
}
}

webhook: {
enable: parameter["createWebhook"]
}

}
}
},
]
policies: [
{
name: "gc-dependency",
type: "garbage-collect",
properties: {
order: "dependency"
}
}
]
}
}
31 changes: 31 additions & 0 deletions addons/spark-kubernetes-operator/views/my-view.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// We put VelaQL views in views directory.
//
// VelaQL(Vela Query Language) is a resource query language for KubeVela,
// used to query status of any extended resources in application-level.
// Reference: https://kubevela.net/docs/platform-engineers/system-operation/velaql
//
// This VelaQL View querys the status of this addon.
// Use this view to query by:
// vela ql --query 'my-view{addonName:spark-kubernetes-operator}.status'
// You should see 'running'.

import (
"vela/ql"
)

app: ql.#Read & {
value: {
kind: "Application"
apiVersion: "core.oam.dev/v1beta1"
metadata: {
name: "addon-" + parameter.addonName
namespace: "vela-system"
}
}
}

parameter: {
addonName: *"spark-kubernetes-operator" | string
}

status: app.value.status.status

0 comments on commit e85f8a9

Please sign in to comment.