Skip to content

Commit

Permalink
[Feature] [Analytics] GAE Integration (#1660)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajanikow authored May 8, 2024
1 parent 7e371cc commit 67f6199
Show file tree
Hide file tree
Showing 56 changed files with 1,959 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ linters-settings:
alias: mlShared
- pkg: github.com/arangodb/kube-arangodb/pkg/handlers/enterprise/ml/shared/test
alias: mlSharedTests
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1
alias: analyticsApi
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/ml/v1beta1
alias: mlApi
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/ml/v1alpha1
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- (Feature) (ML) Enable TLS
- (Feature) (ML) Release V1Beta1 API
- (Maintenance) Update Go to 1.22.3
- (Feature) (Analytics) GAE Integration

## [1.2.40](https://github.com/arangodb/kube-arangodb/tree/1.2.40) (2024-04-10)
- (Feature) Add Core fields to the Scheduler Container Spec
Expand Down
17 changes: 13 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -431,15 +431,23 @@ update-generated:
"client lister informer deepcopy" \
"github.com/arangodb/kube-arangodb/pkg/generated" \
"github.com/arangodb/kube-arangodb/pkg/apis" \
"deployment:v1 replication:v1 storage:v1alpha backup:v1 deployment:v2alpha1 replication:v2alpha1 apps:v1 ml:v1alpha1 ml:v1beta1 scheduler:v1alpha1 scheduler:v1beta1" \
"deployment:v1 deployment:v2alpha1 \
replication:v1 replication:v2alpha1 \
storage:v1alpha \
backup:v1 \
apps:v1 \
ml:v1alpha1 ml:v1beta1 \
scheduler:v1alpha1 scheduler:v1beta1 \
analytics:v1alpha1" \
--go-header-file "./tools/codegen/boilerplate.go.txt" \
$(VERIFYARGS)
GOPATH=$(GOBUILDDIR) $(VENDORDIR)/k8s.io/code-generator/generate-groups.sh \
"deepcopy" \
"github.com/arangodb/kube-arangodb/pkg/generated" \
"github.com/arangodb/kube-arangodb/pkg/apis" \
"shared:v1 scheduler:v1alpha1/container scheduler:v1alpha1/container/resources scheduler:v1alpha1/pod scheduler:v1alpha1/pod/resources\
shared:v1 scheduler:v1beta1/container scheduler:v1beta1/container/resources scheduler:v1beta1/pod scheduler:v1beta1/pod/resources" \
"shared:v1 \
scheduler:v1alpha1/container scheduler:v1alpha1/container/resources scheduler:v1alpha1/pod scheduler:v1alpha1/pod/resources \
scheduler:v1beta1/container scheduler:v1beta1/container/resources scheduler:v1beta1/pod scheduler:v1beta1/pod/resources" \
--go-header-file "./tools/codegen/boilerplate.go.txt" \
$(VERIFYARGS)

Expand Down Expand Up @@ -858,7 +866,8 @@ CRDS:=apps-job \
database-clustersynchronization database-deployment database-member database-task \
replication-deploymentreplication \
ml-storage ml-extension ml-job-batch ml-job-cron \
scheduler-profile
scheduler-profile \
analytics-graphanalyticsengine

.PHONY: sync-crds
sync-crds:
Expand Down
22 changes: 22 additions & 0 deletions chart/kube-arangodb/crds/analytics-graphanalyticsengine.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: graphanalyticsengines.analytics.arangodb.com
spec:
group: analytics.arangodb.com
names:
kind: GraphAnalyticsEngine
listKind: GraphAnalyticsEngineList
plural: graphanalyticsengines
singular: graphanalyticsengine
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
type: object
x-kubernetes-preserve-unknown-fields: true
served: true
storage: true
subresources:
status: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{ if .Values.rbac.enabled -}}
{{ if not (eq .Values.operator.scope "namespaced") -}}
{{ if .Values.operator.features.analytics -}}

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ template "kube-arangodb.rbac-cluster" . }}-analytics
labels:
app.kubernetes.io/name: {{ template "kube-arangodb.name" . }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
release: {{ .Release.Name }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "kube-arangodb.rbac-cluster" . }}-analytics
subjects:
- kind: ServiceAccount
name: {{ template "kube-arangodb.operatorName" . }}
namespace: {{ .Release.Namespace }}

{{- end }}
{{- end }}
{{- end }}
22 changes: 22 additions & 0 deletions chart/kube-arangodb/templates/analytics-operator/cluster-role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{ if .Values.rbac.enabled -}}
{{ if not (eq .Values.operator.scope "namespaced") -}}
{{ if .Values.operator.features.analytics -}}

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ template "kube-arangodb.rbac-cluster" . }}-analytics
labels:
app.kubernetes.io/name: {{ template "kube-arangodb.name" . }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
release: {{ .Release.Name }}
rules:
- apiGroups: ["apiextensions.k8s.io"]
resources: ["customresourcedefinitions"]
verbs: ["get", "list", "watch"]

{{- end }}
{{- end }}
{{- end }}
25 changes: 25 additions & 0 deletions chart/kube-arangodb/templates/analytics-operator/role-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{ if .Values.rbac.enabled -}}
{{ if .Values.operator.features.analytics -}}

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ template "kube-arangodb.rbac" . }}-analytics
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ template "kube-arangodb.name" . }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
release: {{ .Release.Name }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ template "kube-arangodb.rbac" . }}-analytics
subjects:
- kind: ServiceAccount
name: {{ template "kube-arangodb.operatorName" . }}
namespace: {{ .Release.Namespace }}

{{- end }}
{{- end }}
36 changes: 36 additions & 0 deletions chart/kube-arangodb/templates/analytics-operator/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{ if .Values.rbac.enabled -}}
{{ if .Values.operator.features.analytics -}}

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ template "kube-arangodb.rbac" . }}-analytics
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ template "kube-arangodb.name" . }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
release: {{ .Release.Name }}
rules:
- apiGroups:
- "analytics.arangodb.com"
resources:
- "graphanalyticsengines"
- "graphanalyticsengines/status"
verbs:
- "*"
- apiGroups:
- "database.arangodb.com"
resources:
- "arangodeployments"
verbs:
- "get"
- "list"
- "watch"
- apiGroups: [ "" ]
resources:
- "secrets"
verbs: [ "*" ]
{{- end }}
{{- end }}
3 changes: 3 additions & 0 deletions chart/kube-arangodb/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ spec:
{{ if .Values.operator.features.ml }}
- --operator.ml
{{- end }}
{{ if .Values.operator.features.analytics }}
- --operator.analytics
{{- end }}
{{ if .Values.operator.features.k8sToK8sClusterSync }}
- --operator.k2k-cluster-sync
{{- end }}
Expand Down
1 change: 1 addition & 0 deletions chart/kube-arangodb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ operator:
apps: false
k8sToK8sClusterSync: false
ml: false
analytics: false
tolerations: []
rbac:
enabled: true
Expand Down
19 changes: 14 additions & 5 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ var (
enableBackup bool // Run backup operator
enableApps bool // Run apps operator
enableML bool // Run ml operator
enableAnalytics bool // Run analytics operator
versionOnly bool // Run only version endpoint, explicitly disabled with other
enableK2KClusterSync bool // Run k2kClusterSync operator

Expand Down Expand Up @@ -181,6 +182,7 @@ var (
backupProbe probe.ReadyProbe
appsProbe probe.ReadyProbe
mlProbe probe.ReadyProbe
analyticsProbe probe.ReadyProbe
k2KClusterSyncProbe probe.ReadyProbe
)

Expand All @@ -206,6 +208,7 @@ func init() {
f.BoolVar(&operatorOptions.enableBackup, "operator.backup", false, "Enable to run the ArangoBackup operator")
f.BoolVar(&operatorOptions.enableApps, "operator.apps", false, "Enable to run the ArangoApps operator")
f.BoolVar(&operatorOptions.enableML, "operator.ml", false, "Enable to run the ArangoML operator")
f.BoolVar(&operatorOptions.enableAnalytics, "operator.analytics", false, "Enable to run the Analytics operator")
f.BoolVar(&operatorOptions.enableK2KClusterSync, "operator.k2k-cluster-sync", false, "Enable to run the ListSimple operator")
f.MarkDeprecated("operator.k2k-cluster-sync", "Enabled within deployment operator")
f.BoolVar(&operatorOptions.versionOnly, "operator.version", false, "Enable only version endpoint in Operator")
Expand Down Expand Up @@ -333,19 +336,19 @@ func executeMain(cmd *cobra.Command, args []string) {

// Check operating mode
if !operatorOptions.enableDeployment && !operatorOptions.enableDeploymentReplication && !operatorOptions.enableStorage &&
!operatorOptions.enableBackup && !operatorOptions.enableApps && !operatorOptions.enableK2KClusterSync && !operatorOptions.enableML {
!operatorOptions.enableBackup && !operatorOptions.enableApps && !operatorOptions.enableK2KClusterSync && !operatorOptions.enableML && !operatorOptions.enableAnalytics {
if !operatorOptions.versionOnly {
if version.GetVersionV1().IsEnterprise() {
logger.Fatal("Turn on --operator.deployment, --operator.deployment-replication, --operator.storage, --operator.backup, --operator.apps, --operator.k2k-cluster-sync, --operator.ml or any combination of these")
logger.Fatal("Turn on --operator.deployment, --operator.deployment-replication, --operator.storage, --operator.backup, --operator.apps, --operator.k2k-cluster-sync, --operator.ml, --operator.analytics or any combination of these")
} else {
logger.Fatal("Turn on --operator.deployment, --operator.deployment-replication, --operator.storage, --operator.backup, --operator.apps, --operator.k2k-cluster-sync or any combination of these")
}
}
} else if operatorOptions.versionOnly {
logger.Fatal("Options --operator.deployment, --operator.deployment-replication, --operator.storage, --operator.backup, --operator.apps, --operator.k2k-cluster-sync, --operator.ml cannot be enabled together with --operator.version")
logger.Fatal("Options --operator.deployment, --operator.deployment-replication, --operator.storage, --operator.backup, --operator.apps, --operator.k2k-cluster-sync, --operator.ml, --operator.analytics cannot be enabled together with --operator.version")
} else if !version.GetVersionV1().IsEnterprise() {
if operatorOptions.enableML {
logger.Fatal("Options --operator.ml can be enabled only on the Enterprise Operator")
if operatorOptions.enableML || operatorOptions.enableAnalytics {
logger.Fatal("Options --operator.ml, --operator.analytics can be enabled only on the Enterprise Operator")
}
}

Expand Down Expand Up @@ -476,6 +479,10 @@ func executeMain(cmd *cobra.Command, args []string) {
Enabled: cfg.EnableML,
Probe: &mlProbe,
},
Analytics: server.OperatorDependency{
Enabled: cfg.EnableAnalytics,
Probe: &analyticsProbe,
},
ClusterSync: server.OperatorDependency{
Enabled: cfg.EnableK2KClusterSync,
Probe: &k2KClusterSyncProbe,
Expand Down Expand Up @@ -559,6 +566,7 @@ func newOperatorConfigAndDeps(id, namespace, name string) (operator.Config, oper
EnableBackup: operatorOptions.enableBackup,
EnableApps: operatorOptions.enableApps,
EnableML: operatorOptions.enableML,
EnableAnalytics: operatorOptions.enableAnalytics,
EnableK2KClusterSync: operatorOptions.enableK2KClusterSync,
AllowChaos: chaosOptions.allowed,
ScalingIntegrationEnabled: operatorOptions.scalingIntegrationEnabled,
Expand All @@ -578,6 +586,7 @@ func newOperatorConfigAndDeps(id, namespace, name string) (operator.Config, oper
BackupProbe: &backupProbe,
AppsProbe: &appsProbe,
MlProbe: &mlProbe,
AnalyticsProbe: &analyticsProbe,
K2KClusterSyncProbe: &k2KClusterSyncProbe,
}

Expand Down
56 changes: 56 additions & 0 deletions docs/api/GraphAnalyticsEngine.V1Alpha1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
layout: page
parent: CRD reference
title: GraphAnalyticsEngine V1Alpha1
---

# API Reference for GraphAnalyticsEngine V1Alpha1

## Spec

### .spec.deploymentName

Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/analytics/v1alpha1/gae_spec.go#L30)</sup>

DeploymentName define deployment name used in the object. Immutable

## Status

### .status.conditions

Type: `api.Conditions` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/analytics/v1alpha1/gae_status.go#L31)</sup>

Conditions specific to the entire extension

***

### .status.deployment.checksum

Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L61)</sup>

UID keeps the information about object Checksum

***

### .status.deployment.name

Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L52)</sup>

Name of the object

***

### .status.deployment.namespace

Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L55)</sup>

Namespace of the object. Should default to the namespace of the parent object

***

### .status.deployment.uid

Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.40/pkg/apis/shared/v1/object.go#L58)</sup>

UID keeps the information about object UID

8 changes: 8 additions & 0 deletions internal/cr_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"sigs.k8s.io/yaml"

analyticsApi "github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1"
appsv1 "github.com/arangodb/kube-arangodb/pkg/apis/apps/v1"
backupv1 "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1"
deploymentv1 "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
Expand Down Expand Up @@ -226,6 +227,13 @@ func Test_GenerateCRValidationSchemas(t *testing.T) {
},
},
},
"analytics-graphanalyticsengine": {
fmt.Sprintf("%s/pkg/apis/analytics/v1alpha1", root): {
"v1alpha1": {
analyticsApi.GraphAnalyticsEngine{}.Spec,
},
},
},
}

for filePrefix, packagesToVersion := range input {
Expand Down
14 changes: 14 additions & 0 deletions internal/docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/coreos/go-semver/semver"
"github.com/stretchr/testify/require"

analyticsApi "github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1"
appsApi "github.com/arangodb/kube-arangodb/pkg/apis/apps/v1"
backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1"
deploymentApi "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
Expand Down Expand Up @@ -248,6 +249,19 @@ func Test_GenerateAPIDocs(t *testing.T) {
},
},
},
"analytics": map[string]inputPackage{
"v1alpha1": {
Types: inputPackageTypes{
"GraphAnalyticsEngine.V1Alpha1": {
"Spec": analyticsApi.GraphAnalyticsEngine{}.Spec,
"Status": analyticsApi.GraphAnalyticsEngine{}.Status,
},
},
Shared: []string{
"shared/v1",
},
},
},
"replication": map[string]inputPackage{
"v1": {
Types: inputPackageTypes{
Expand Down
Loading

0 comments on commit 67f6199

Please sign in to comment.