Skip to content
Merged
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
4 changes: 3 additions & 1 deletion pkg/apis/deployment/v1/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type ArangoDeployment struct {
Status DeploymentStatus `json:"status"`
}

type ServerGroupFunc func(ServerGroup, ServerGroupSpec, *MemberStatusList) error

// AsOwner creates an OwnerReference for the given deployment
func (d *ArangoDeployment) AsOwner() metav1.OwnerReference {
trueVar := true
Expand All @@ -67,7 +69,7 @@ func (d *ArangoDeployment) AsOwner() metav1.OwnerReference {
// If the callback returns an error, this error is returned and no other server
// groups are processed.
// Groups are processed in this order: agents, single, dbservers, coordinators, syncmasters, syncworkers
func (d *ArangoDeployment) ForeachServerGroup(cb func(group ServerGroup, spec ServerGroupSpec, status *MemberStatusList) error, status *DeploymentStatus) error {
func (d *ArangoDeployment) ForeachServerGroup(cb ServerGroupFunc, status *DeploymentStatus) error {
if status == nil {
status = &d.Status
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/deployment/v1/deployment_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type DeploymentSpec struct {
Sync SyncSpec `json:"sync"`
License LicenseSpec `json:"license"`
Metrics MetricsSpec `json:"metrics"`
Lifecycle LifecycleSpec `json:"lifecycle,omitempty"`

Single ServerGroupSpec `json:"single"`
Agents ServerGroupSpec `json:"agents"`
Expand Down Expand Up @@ -278,6 +279,7 @@ func (s *DeploymentSpec) SetDefaultsFrom(source DeploymentSpec) {
s.SyncMasters.SetDefaultsFrom(source.SyncMasters)
s.SyncWorkers.SetDefaultsFrom(source.SyncWorkers)
s.Metrics.SetDefaultsFrom(source.Metrics)
s.Lifecycle.SetDefaultsFrom(source.Lifecycle)
s.Chaos.SetDefaultsFrom(source.Chaos)
s.Bootstrap.SetDefaultsFrom(source.Bootstrap)
}
Expand Down
37 changes: 37 additions & 0 deletions pkg/apis/deployment/v1/lifecycle_spec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// DISCLAIMER
//
// Copyright 2019 ArangoDB GmbH, Cologne, Germany
//
// Licensed 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.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
// Author Tomasz Mielech <tomasz@arangodb.com>
//

package v1

import (
v1 "k8s.io/api/core/v1"
)

type LifecycleSpec struct {
Resources v1.ResourceRequirements `json:"resources,omitempty"`
}

// SetDefaultsFrom fills unspecified fields with a value from given source spec.
func (s *LifecycleSpec) SetDefaultsFrom(source LifecycleSpec) {
setDefaultsFromResourceList(&s.Resources.Limits, source.Resources.Limits)
setDefaultsFromResourceList(&s.Resources.Requests, source.Resources.Requests)
}
4 changes: 4 additions & 0 deletions pkg/apis/deployment/v1/metrics_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package v1
import (
"github.com/arangodb/kube-arangodb/pkg/util"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
v1 "k8s.io/api/core/v1"
)

// MetricsAuthenticationSpec contains spec for authentication with arangodb
Expand All @@ -37,6 +38,7 @@ type MetricsSpec struct {
Enabled *bool `json:"enabled,omitempty"`
Image *string `json:"image,omitempty"`
Authentication MetricsAuthenticationSpec `json:"authentication,omitempty"`
Resources v1.ResourceRequirements `json:"resources,omitempty"`
}

// IsEnabled returns whether metrics are enabled or not
Expand Down Expand Up @@ -85,6 +87,8 @@ func (s *MetricsSpec) SetDefaultsFrom(source MetricsSpec) {
if s.Authentication.JWTTokenSecretName == nil {
s.Authentication.JWTTokenSecretName = util.NewStringOrNil(source.Authentication.JWTTokenSecretName)
}
setDefaultsFromResourceList(&s.Resources.Limits, source.Resources.Limits)
setDefaultsFromResourceList(&s.Resources.Requests, source.Resources.Requests)
}

// Validate the given spec
Expand Down
19 changes: 19 additions & 0 deletions pkg/apis/deployment/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion pkg/apis/deployment/v1alpha/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type ArangoDeployment struct {
Status DeploymentStatus `json:"status"`
}

type ServerGroupFunc func(ServerGroup, ServerGroupSpec, *MemberStatusList) error

// AsOwner creates an OwnerReference for the given deployment
func (d *ArangoDeployment) AsOwner() metav1.OwnerReference {
trueVar := true
Expand All @@ -67,7 +69,7 @@ func (d *ArangoDeployment) AsOwner() metav1.OwnerReference {
// If the callback returns an error, this error is returned and no other server
// groups are processed.
// Groups are processed in this order: agents, single, dbservers, coordinators, syncmasters, syncworkers
func (d *ArangoDeployment) ForeachServerGroup(cb func(group ServerGroup, spec ServerGroupSpec, status *MemberStatusList) error, status *DeploymentStatus) error {
func (d *ArangoDeployment) ForeachServerGroup(cb ServerGroupFunc, status *DeploymentStatus) error {
if status == nil {
status = &d.Status
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/deployment/v1alpha/deployment_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type DeploymentSpec struct {
Sync SyncSpec `json:"sync"`
License LicenseSpec `json:"license"`
Metrics MetricsSpec `json:"metrics"`
Lifecycle LifecycleSpec `json:"lifecycle,omitempty"`

Single ServerGroupSpec `json:"single"`
Agents ServerGroupSpec `json:"agents"`
Expand Down Expand Up @@ -278,6 +279,7 @@ func (s *DeploymentSpec) SetDefaultsFrom(source DeploymentSpec) {
s.SyncMasters.SetDefaultsFrom(source.SyncMasters)
s.SyncWorkers.SetDefaultsFrom(source.SyncWorkers)
s.Metrics.SetDefaultsFrom(source.Metrics)
s.Lifecycle.SetDefaultsFrom(source.Lifecycle)
s.Chaos.SetDefaultsFrom(source.Chaos)
s.Bootstrap.SetDefaultsFrom(source.Bootstrap)
}
Expand Down
37 changes: 37 additions & 0 deletions pkg/apis/deployment/v1alpha/lifecycle_spec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// DISCLAIMER
//
// Copyright 2019 ArangoDB GmbH, Cologne, Germany
//
// Licensed 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.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
// Author Tomasz Mielech <tomasz@arangodb.com>
//

package v1alpha

import (
v1 "k8s.io/api/core/v1"
)

type LifecycleSpec struct {
Resources v1.ResourceRequirements `json:"resources,omitempty"`
}

// SetDefaultsFrom fills unspecified fields with a value from given source spec.
func (s *LifecycleSpec) SetDefaultsFrom(source LifecycleSpec) {
setDefaultsFromResourceList(&s.Resources.Limits, source.Resources.Limits)
setDefaultsFromResourceList(&s.Resources.Requests, source.Resources.Requests)
}
4 changes: 4 additions & 0 deletions pkg/apis/deployment/v1alpha/metrics_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package v1alpha
import (
"github.com/arangodb/kube-arangodb/pkg/util"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
v1 "k8s.io/api/core/v1"
)

// MetricsAuthenticationSpec contains spec for authentication with arangodb
Expand All @@ -37,6 +38,7 @@ type MetricsSpec struct {
Enabled *bool `json:"enabled,omitempty"`
Image *string `json:"image,omitempty"`
Authentication MetricsAuthenticationSpec `json:"authentication,omitempty"`
Resources v1.ResourceRequirements `json:"resources,omitempty"`
}

// IsEnabled returns whether metrics are enabled or not
Expand Down Expand Up @@ -85,6 +87,8 @@ func (s *MetricsSpec) SetDefaultsFrom(source MetricsSpec) {
if s.Authentication.JWTTokenSecretName == nil {
s.Authentication.JWTTokenSecretName = util.NewStringOrNil(source.Authentication.JWTTokenSecretName)
}
setDefaultsFromResourceList(&s.Resources.Limits, source.Resources.Limits)
setDefaultsFromResourceList(&s.Resources.Requests, source.Resources.Requests)
}

// Validate the given spec
Expand Down
19 changes: 19 additions & 0 deletions pkg/apis/deployment/v1alpha/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading