mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Feature] Add ARANGODB_OVERRIDE_DETECTED_NUMBER_OF_CORES env (#629)
This commit is contained in:
parent
17c8ea8e43
commit
cbfa9345ce
6 changed files with 42 additions and 4 deletions
|
@ -3,6 +3,7 @@
|
|||
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
|
||||
- Always use JWT Authorized requests in internal communication
|
||||
- Add Operator Maintenance Management feature
|
||||
- Add support for ARANGODB_OVERRIDE_DETECTED_NUMBER_OF_CORES ArangoDB Environment Variable
|
||||
|
||||
## [1.0.6](https://github.com/arangodb/kube-arangodb/tree/1.0.6) (2020-08-19)
|
||||
- Add Operator Namespaced mode (Alpha)
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
package v1
|
||||
|
||||
type DatabaseSpec struct {
|
||||
// Maintenance manage maintenance mode on Cluster side. Requires maintenance feature to be enabled
|
||||
Maintenance *bool `json:"maintenance,omitempty"`
|
||||
}
|
||||
|
||||
|
|
|
@ -95,6 +95,7 @@ type DeploymentSpec struct {
|
|||
|
||||
ID *ServerIDGroupSpec `json:"id,omitempty"`
|
||||
|
||||
// Database holds information about database state, like maintenance mode
|
||||
Database *DatabaseSpec `json:"database,omitempty"`
|
||||
|
||||
Single ServerGroupSpec `json:"single"`
|
||||
|
|
|
@ -54,6 +54,8 @@ type ServerGroupSpec struct {
|
|||
Resources core.ResourceRequirements `json:"resources,omitempty"`
|
||||
// OverrideDetectedTotalMemory determines if memory should be overrided based on values in resources.
|
||||
OverrideDetectedTotalMemory *bool `json:"overrideDetectedTotalMemory,omitempty"`
|
||||
// OverrideDetectedNumberOfCores determines if number of cores should be overrided based on values in resources.
|
||||
OverrideDetectedNumberOfCores *bool `json:"overrideDetectedNumberOfCores,omitempty"`
|
||||
// Tolerations specifies the tolerations added to Pods in this group.
|
||||
Tolerations []core.Toleration `json:"tolerations,omitempty"`
|
||||
// Annotations specified the annotations added to Pods in this group.
|
||||
|
@ -368,6 +370,24 @@ func (s ServerGroupSpec) GetProbesSpec() ServerGroupProbesSpec {
|
|||
return ServerGroupProbesSpec{}
|
||||
}
|
||||
|
||||
// GetOverrideDetectedTotalMemory returns OverrideDetectedTotalMemory with default value (false)
|
||||
func (s ServerGroupSpec) GetOverrideDetectedTotalMemory() bool {
|
||||
if s.OverrideDetectedTotalMemory == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return *s.OverrideDetectedTotalMemory
|
||||
}
|
||||
|
||||
// OverrideDetectedNumberOfCores returns OverrideDetectedNumberOfCores with default value (false)
|
||||
func (s ServerGroupSpec) GetOverrideDetectedNumberOfCores() bool {
|
||||
if s.OverrideDetectedNumberOfCores == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return *s.OverrideDetectedNumberOfCores
|
||||
}
|
||||
|
||||
// Validate the given group spec
|
||||
func (s ServerGroupSpec) Validate(group ServerGroup, used bool, mode DeploymentMode, env Environment) error {
|
||||
if used {
|
||||
|
|
5
pkg/apis/deployment/v1/zz_generated.deepcopy.go
generated
5
pkg/apis/deployment/v1/zz_generated.deepcopy.go
generated
|
@ -1191,6 +1191,11 @@ func (in *ServerGroupSpec) DeepCopyInto(out *ServerGroupSpec) {
|
|||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
if in.OverrideDetectedNumberOfCores != nil {
|
||||
in, out := &in.OverrideDetectedNumberOfCores, &out.OverrideDetectedNumberOfCores
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
if in.Tolerations != nil {
|
||||
in, out := &in.Tolerations, &out.Tolerations
|
||||
*out = make([]corev1.Toleration, len(*in))
|
||||
|
|
|
@ -42,8 +42,9 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
ArangoDExecutor string = "/usr/sbin/arangod"
|
||||
ArangoDBOverrideDetectedTotalMemoryEnv = "ARANGODB_OVERRIDE_DETECTED_TOTAL_MEMORY"
|
||||
ArangoDExecutor string = "/usr/sbin/arangod"
|
||||
ArangoDBOverrideDetectedTotalMemoryEnv = "ARANGODB_OVERRIDE_DETECTED_TOTAL_MEMORY"
|
||||
ArangoDBOverrideDetectedNumberOfCoresEnv = "ARANGODB_OVERRIDE_DETECTED_NUMBER_OF_CORES"
|
||||
)
|
||||
|
||||
var _ interfaces.PodCreator = &MemberArangoDPod{}
|
||||
|
@ -154,8 +155,8 @@ func (a *ArangoDContainer) GetEnvs() []core.EnvVar {
|
|||
envs.Add(true, k8sutil.GetLifecycleEnv()...)
|
||||
}
|
||||
|
||||
if util.BoolOrDefault(a.groupSpec.OverrideDetectedTotalMemory, false) {
|
||||
if a.groupSpec.Resources.Limits != nil {
|
||||
if a.groupSpec.Resources.Limits != nil {
|
||||
if a.groupSpec.GetOverrideDetectedTotalMemory() {
|
||||
if limits, ok := a.groupSpec.Resources.Limits[core.ResourceMemory]; ok {
|
||||
envs.Add(true, core.EnvVar{
|
||||
Name: ArangoDBOverrideDetectedTotalMemoryEnv,
|
||||
|
@ -163,6 +164,15 @@ func (a *ArangoDContainer) GetEnvs() []core.EnvVar {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
if a.groupSpec.GetOverrideDetectedNumberOfCores() {
|
||||
if limits, ok := a.groupSpec.Resources.Limits[core.ResourceCPU]; ok {
|
||||
envs.Add(true, core.EnvVar{
|
||||
Name: ArangoDBOverrideDetectedNumberOfCoresEnv,
|
||||
Value: fmt.Sprintf("%d", limits.Value()),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(a.groupSpec.Envs) > 0 {
|
||||
|
|
Loading…
Reference in a new issue