From a55367b19bd8f915e716c26b70e3def87a873cda Mon Sep 17 00:00:00 2001 From: Aaron Miller <1521726+aaroniscode@users.noreply.github.com> Date: Mon, 2 Sep 2024 19:17:23 -0700 Subject: [PATCH] add: `install spark-operator` (#227) --- README.md | 1 + cmd/install/install.go | 2 ++ cmd/install/uninstall.go | 2 ++ pkg/application/spark/options.go | 29 +++++++++++++++ pkg/application/spark/spark_operator.go | 48 +++++++++++++++++++++++++ 5 files changed, 82 insertions(+) create mode 100644 pkg/application/spark/options.go create mode 100644 pkg/application/spark/spark_operator.go diff --git a/README.md b/README.md index e30abc0..81e33b0 100644 --- a/README.md +++ b/README.md @@ -274,6 +274,7 @@ The application catalog includes: * `secrets` — Secrets Management Solutions for Kubernetes * `store-csi-driver` — Integrates secrets stores with K8s via a CSI volume * `store-csi-driver-provider-aws` — AWS Secrets Manager and Config Provider for Secret Store CSI Driver +* `spark-operator` — Kubeflow Spark Operator * `storage` — Kubernetes Storage Solutions * `ebs-csi` — Amazon EBS CSI driver * `efs-csi` — Amazon EFS CSI driver diff --git a/cmd/install/install.go b/cmd/install/install.go index 806cc61..d1337fe 100644 --- a/cmd/install/install.go +++ b/cmd/install/install.go @@ -23,6 +23,7 @@ import ( "github.com/awslabs/eksdemo/pkg/application/kube_state_metrics" "github.com/awslabs/eksdemo/pkg/application/metrics_server" "github.com/awslabs/eksdemo/pkg/application/prometheus_node_exporter" + sparkoperator "github.com/awslabs/eksdemo/pkg/application/spark" "github.com/awslabs/eksdemo/pkg/application/storage/ebs_csi" "github.com/awslabs/eksdemo/pkg/application/vault" "github.com/awslabs/eksdemo/pkg/application/velero" @@ -95,6 +96,7 @@ func NewInstallCmd() *cobra.Command { cmd.AddCommand(NewInstallSecretsCmd()) cmd.AddCommand(NewInstallAliasCmds(secrets, "secret-")...) cmd.AddCommand(NewInstallAliasCmds(secrets, "secrets-")...) + cmd.AddCommand(sparkoperator.NewApp().NewInstallCmd()) cmd.AddCommand(NewInstallStorageCmd()) cmd.AddCommand(NewInstallAliasCmds(storageApps, "storage-")...) cmd.AddCommand(vault.NewApp().NewInstallCmd()) diff --git a/cmd/install/uninstall.go b/cmd/install/uninstall.go index 2dedd32..58a368b 100644 --- a/cmd/install/uninstall.go +++ b/cmd/install/uninstall.go @@ -23,6 +23,7 @@ import ( "github.com/awslabs/eksdemo/pkg/application/kube_state_metrics" "github.com/awslabs/eksdemo/pkg/application/metrics_server" "github.com/awslabs/eksdemo/pkg/application/prometheus_node_exporter" + sparkoperator "github.com/awslabs/eksdemo/pkg/application/spark" "github.com/awslabs/eksdemo/pkg/application/storage/ebs_csi" "github.com/awslabs/eksdemo/pkg/application/vault" "github.com/awslabs/eksdemo/pkg/application/velero" @@ -95,6 +96,7 @@ func NewUninstallCmd() *cobra.Command { cmd.AddCommand(NewUninstallSecretsCmd()) cmd.AddCommand(NewUninstallAliasCmds(secrets, "secret-")...) cmd.AddCommand(NewUninstallAliasCmds(secrets, "secrets-")...) + cmd.AddCommand(sparkoperator.NewApp().NewUninstallCmd()) cmd.AddCommand(NewUninstallStorageCmd()) cmd.AddCommand(NewUninstallAliasCmds(storageApps, "storage-")...) cmd.AddCommand(vault.NewApp().NewUninstallCmd()) diff --git a/pkg/application/spark/options.go b/pkg/application/spark/options.go new file mode 100644 index 0000000..5765493 --- /dev/null +++ b/pkg/application/spark/options.go @@ -0,0 +1,29 @@ +package spark + +import ( + "github.com/awslabs/eksdemo/pkg/application" + "github.com/awslabs/eksdemo/pkg/cmd" +) + +type Options struct { + application.ApplicationOptions +} + +func newOptions() (options *Options, flags cmd.Flags) { + options = &Options{ + ApplicationOptions: application.ApplicationOptions{ + DefaultVersion: &application.LatestPrevious{ + LatestChart: "2.0.0-rc.0", + Latest: "2.0.0-rc.0", + PreviousChart: "2.0.0-rc.0", + Previous: "2.0.0-rc.0", + }, + Namespace: "spark-operator", + ServiceAccount: "spark-operator-controller", + }, + } + + flags = cmd.Flags{} + + return +} diff --git a/pkg/application/spark/spark_operator.go b/pkg/application/spark/spark_operator.go new file mode 100644 index 0000000..658ce2c --- /dev/null +++ b/pkg/application/spark/spark_operator.go @@ -0,0 +1,48 @@ +package spark + +import ( + "github.com/awslabs/eksdemo/pkg/application" + "github.com/awslabs/eksdemo/pkg/cmd" + "github.com/awslabs/eksdemo/pkg/installer" + "github.com/awslabs/eksdemo/pkg/template" +) + +// Docs: https://www.kubeflow.org/docs/components/spark-operator/ +// GitHub: https://github.com/kubeflow/spark-operator +// Helm: https://github.com/kubeflow/spark-operator/tree/master/charts/spark-operator-chart +// Repo: https://hub.docker.com/r/kubeflow/spark-operator/ +// Version: Latest is v2.0.0-rc.0 (as of 9/2/24) + +func NewApp() *application.Application { + options, flags := newOptions() + + return &application.Application{ + Command: cmd.Command{ + Name: "spark-operator", + Description: "Kubeflow Spark Operator", + Aliases: []string{"spark"}, + }, + + Flags: flags, + + Installer: &installer.HelmInstaller{ + ChartName: "spark-operator", + ReleaseName: "spark-operator", + RepositoryURL: "https://kubeflow.github.io/spark-operator", + ValuesTemplate: &template.TextTemplate{ + Template: valuesTemplate, + }, + }, + + Options: options, + } +} + +// https://github.com/kubeflow/spark-operator/blob/master/charts/spark-operator-chart/values.yaml +const valuesTemplate = `--- +image: + tag: {{ .Version }} +controller: + serviceAccount: + name: {{ .ServiceAccount }} +`