Skip to content

Commit 93e6af5

Browse files
authored
[Feature] [ML] Multi DB Settings (#1536)
1 parent 9ceaba9 commit 93e6af5

7 files changed

+128
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
- (Feature) (ML) Handler for Extension StatefulSet and Service
3535
- (Feature) (ML) Pod & Container Config
3636
- (Improvement) (ML) BatchJob status update
37+
- (Feature) (ML) Multi DB Settings
3738

3839
## [1.2.35](https://github.com/arangodb/kube-arangodb/tree/1.2.35) (2023-11-06)
3940
- (Maintenance) Update go-driver to v1.6.0, update IsNotFound() checks

docs/api/ArangoMLExtension.V1Alpha1.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Image define image details
7676

7777
### .spec.deployment.prediction.port
7878

79-
Type: `integer` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/extension_spec_deployment_component.go#L31)</sup>
79+
Type: `integer` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/extension_spec_deployment_component.go#L30)</sup>
8080

8181
Port defines on which port the container will be listening for connections
8282

@@ -132,7 +132,7 @@ Image define image details
132132

133133
### .spec.deployment.project.port
134134

135-
Type: `integer` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/extension_spec_deployment_component.go#L31)</sup>
135+
Type: `integer` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/extension_spec_deployment_component.go#L30)</sup>
136136

137137
Port defines on which port the container will be listening for connections
138138

@@ -180,7 +180,7 @@ Links:
180180

181181
### .spec.deployment.replicas
182182

183-
Type: `integer` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/extension_spec_deployment.go#L33)</sup>
183+
Type: `integer` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/extension_spec_deployment.go#L56)</sup>
184184

185185
Replicas defines the number of replicas running specified components. No replicas created if no components are defined.
186186

@@ -250,7 +250,7 @@ Image define image details
250250

251251
### .spec.deployment.training.port
252252

253-
Type: `integer` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/extension_spec_deployment_component.go#L31)</sup>
253+
Type: `integer` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/extension_spec_deployment_component.go#L30)</sup>
254254

255255
Port defines on which port the container will be listening for connections
256256

@@ -513,6 +513,30 @@ UID keeps the information about object UID
513513

514514
## Status
515515

516+
### .status.arangoDB.secret.name
517+
518+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/object.go#L46)</sup>
519+
520+
Name of the object
521+
522+
***
523+
524+
### .status.arangoDB.secret.namespace
525+
526+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/object.go#L49)</sup>
527+
528+
Namespace of the object. Should default to the namespace of the parent object
529+
530+
***
531+
532+
### .status.arangoDB.secret.uid
533+
534+
Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/object.go#L52)</sup>
535+
536+
UID keeps the information about object UID
537+
538+
***
539+
516540
### .status.conditions
517541

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

pkg/apis/ml/v1alpha1/extension_spec_deployment.go

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,29 @@ import (
2727
"github.com/arangodb/kube-arangodb/pkg/util/errors"
2828
)
2929

30+
const (
31+
ArangoMLExtensionSpecDeploymentComponentPrediction = "prediction"
32+
ArangoMLExtensionSpecDeploymentComponentTraining = "training"
33+
ArangoMLExtensionSpecDeploymentComponentProject = "project"
34+
35+
ArangoMLExtensionSpecDeploymentComponentPredictionDefaultPort = 16000
36+
ArangoMLExtensionSpecDeploymentComponentTrainingDefaultPort = 16001
37+
ArangoMLExtensionSpecDeploymentComponentProjectDefaultPort = 16002
38+
)
39+
40+
func GetArangoMLExtensionSpecDeploymentComponentDefaultPort(component string) int32 {
41+
switch component {
42+
case ArangoMLExtensionSpecDeploymentComponentPrediction:
43+
return ArangoMLExtensionSpecDeploymentComponentPredictionDefaultPort
44+
case ArangoMLExtensionSpecDeploymentComponentTraining:
45+
return ArangoMLExtensionSpecDeploymentComponentTrainingDefaultPort
46+
case ArangoMLExtensionSpecDeploymentComponentProject:
47+
return ArangoMLExtensionSpecDeploymentComponentProjectDefaultPort
48+
}
49+
50+
return 0
51+
}
52+
3053
type ArangoMLExtensionSpecDeployment struct {
3154
// Replicas defines the number of replicas running specified components. No replicas created if no components are defined.
3255
// +doc/default: 1
@@ -87,9 +110,9 @@ func (s *ArangoMLExtensionSpecDeployment) GetComponents() map[string]*ArangoMLEx
87110
return nil
88111
}
89112
return map[string]*ArangoMLExtensionSpecDeploymentComponent{
90-
"prediction": s.GetPrediction(),
91-
"training": s.GetTraining(),
92-
"project": s.GetProject(),
113+
ArangoMLExtensionSpecDeploymentComponentPrediction: s.GetPrediction(),
114+
ArangoMLExtensionSpecDeploymentComponentTraining: s.GetTraining(),
115+
ArangoMLExtensionSpecDeploymentComponentProject: s.GetProject(),
93116
}
94117
}
95118

@@ -130,12 +153,22 @@ func (s *ArangoMLExtensionSpecDeployment) Validate() error {
130153
var usedPorts util.List[int32]
131154
for prefix, component := range s.GetComponents() {
132155
err := component.Validate()
133-
errs = append(errs, shared.PrefixResourceErrors(prefix, err))
156+
if err != nil {
157+
errs = append(errs, shared.PrefixResourceErrors(prefix, err))
158+
continue
159+
}
134160
if err == nil {
135-
if usedPorts.IndexOf(component.GetPort()) >= 0 {
136-
errs = append(errs, shared.PrefixResourceErrors(prefix, errors.Newf("port %d already specified for other component", component.GetPort())))
161+
port := component.GetPort(GetArangoMLExtensionSpecDeploymentComponentDefaultPort(prefix))
162+
163+
if port == 0 {
164+
errs = append(errs, shared.PrefixResourceErrors(prefix, errors.Newf("port not defined")))
165+
continue
166+
}
167+
168+
if usedPorts.IndexOf(port) >= 0 {
169+
errs = append(errs, shared.PrefixResourceErrors(prefix, errors.Newf("port %d already specified for other component", port)))
137170
} else {
138-
usedPorts.Append(component.GetPort())
171+
usedPorts.Append(port)
139172
}
140173
}
141174
}

pkg/apis/ml/v1alpha1/extension_spec_deployment_component.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ package v1alpha1
2323
import (
2424
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
2525
sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1"
26-
"github.com/arangodb/kube-arangodb/pkg/util/errors"
2726
)
2827

2928
type ArangoMLExtensionSpecDeploymentComponent struct {
@@ -34,9 +33,9 @@ type ArangoMLExtensionSpecDeploymentComponent struct {
3433
*sharedApi.ContainerTemplate `json:",inline"`
3534
}
3635

37-
func (s *ArangoMLExtensionSpecDeploymentComponent) GetPort() int32 {
36+
func (s *ArangoMLExtensionSpecDeploymentComponent) GetPort(def int32) int32 {
3837
if s == nil || s.Port == nil {
39-
return 0
38+
return def
4039
}
4140
return *s.Port
4241
}
@@ -56,10 +55,6 @@ func (s *ArangoMLExtensionSpecDeploymentComponent) Validate() error {
5655

5756
var err []error
5857

59-
if s.GetPort() < 1 {
60-
err = append(err, shared.PrefixResourceErrors("port", errors.Newf("must be positive")))
61-
}
62-
6358
err = append(err,
6459
s.GetContainerTemplate().Validate(),
6560
)

pkg/apis/ml/v1alpha1/extension_status.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,7 @@ type ArangoMLExtensionStatus struct {
3535

3636
// ServiceAccount keeps the information about ServiceAccount
3737
ServiceAccount *shared.ServiceAccount `json:"serviceAccount,omitempty"`
38+
39+
// ArangoDB keeps the information about local arangodb reference
40+
ArangoDB *ArangoMLExtensionStatusArangoDBRef `json:"arangoDB,omitempty"`
3841
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package v1alpha1
22+
23+
import shared "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1"
24+
25+
type ArangoMLExtensionStatusArangoDBRef struct {
26+
// Secret keeps the information about Secret for ArangoDB Authentication
27+
Secret *shared.Object `json:"secret,omitempty"`
28+
}

pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)