Skip to content

Commit

Permalink
[Feature] Add new fields to ID Group (#653)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajanikow authored Oct 30, 2020
1 parent 841af83 commit a49d25b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
- Allow to mount EmptyDir
- Allow to specify initContainers in pods
- Add serviceAccount, resources and securityContext fields to ID Group

## [1.1.0](https://github.com/arangodb/kube-arangodb/tree/master) (2020-10-14)
- Change NumberOfCores and MemoryOverride flags to be set to true by default
Expand Down
25 changes: 25 additions & 0 deletions pkg/apis/deployment/v1/server_id_group_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ type ServerIDGroupSpec struct {
Affinity *core.PodAffinity `json:"affinity,omitempty"`
// NodeAffinity specified additional nodeAffinity settings in ArangoDB Pod definitions
NodeAffinity *core.NodeAffinity `json:"nodeAffinity,omitempty"`
// ServiceAccountName specifies the name of the service account used for Pods in this group.
ServiceAccountName *string `json:"serviceAccountName,omitempty"`
// SecurityContext specifies security context for group
SecurityContext *ServerGroupSpecSecurityContext `json:"securityContext,omitempty"`
// Resources holds resource requests & limits
Resources *core.ResourceRequirements `json:"resources,omitempty"`
}

func (s *ServerIDGroupSpec) Get() ServerIDGroupSpec {
Expand All @@ -47,3 +53,22 @@ func (s *ServerIDGroupSpec) Get() ServerIDGroupSpec {

return ServerIDGroupSpec{}
}

func (s *ServerIDGroupSpec) GetServiceAccountName() string {
if s == nil || s.ServiceAccountName == nil {
return ""
}

return *s.ServiceAccountName
}

func (s *ServerIDGroupSpec) GetResources() core.ResourceRequirements {
if s == nil || s.Resources == nil {
return core.ResourceRequirements{
Limits: make(core.ResourceList),
Requests: make(core.ResourceList),
}
}

return *s.Resources
}
20 changes: 20 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.

11 changes: 3 additions & 8 deletions pkg/deployment/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,7 @@ func (a *ArangoDImageUpdateContainer) GetProbes() (*core.Probe, *core.Probe, err
}

func (a *ArangoDImageUpdateContainer) GetResourceRequirements() core.ResourceRequirements {
return core.ResourceRequirements{
Limits: make(core.ResourceList),
Requests: make(core.ResourceList),
}
return a.spec.ID.GetResources()
}

func (a *ArangoDImageUpdateContainer) GetImage() string {
Expand Down Expand Up @@ -351,7 +348,7 @@ func (i *ImageUpdatePod) GetNodeSelector() map[string]string {
}

func (i *ImageUpdatePod) GetServiceAccountName() string {
return ""
return i.spec.ID.GetServiceAccountName()
}

func (a *ArangoDImageUpdateContainer) GetPorts() []core.ContainerPort {
Expand All @@ -365,9 +362,7 @@ func (a *ArangoDImageUpdateContainer) GetPorts() []core.ContainerPort {
}

func (a *ArangoDImageUpdateContainer) GetSecurityContext() *core.SecurityContext {
// Default security context
var v api.ServerGroupSpecSecurityContext
return v.NewSecurityContext()
return a.spec.ID.Get().SecurityContext.NewSecurityContext()
}

func (i *ImageUpdatePod) GetPodAntiAffinity() *core.PodAntiAffinity {
Expand Down

0 comments on commit a49d25b

Please sign in to comment.