diff --git a/CHANGELOG.md b/CHANGELOG.md index 24ac74fda..43a8621e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/pkg/apis/deployment/v1/server_id_group_spec.go b/pkg/apis/deployment/v1/server_id_group_spec.go index 1d66dacf1..997498036 100644 --- a/pkg/apis/deployment/v1/server_id_group_spec.go +++ b/pkg/apis/deployment/v1/server_id_group_spec.go @@ -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 { @@ -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 +} diff --git a/pkg/apis/deployment/v1/zz_generated.deepcopy.go b/pkg/apis/deployment/v1/zz_generated.deepcopy.go index cc58a8687..cf33d294e 100644 --- a/pkg/apis/deployment/v1/zz_generated.deepcopy.go +++ b/pkg/apis/deployment/v1/zz_generated.deepcopy.go @@ -1302,6 +1302,11 @@ func (in *ServerGroupSpec) DeepCopyInto(out *ServerGroupSpec) { *out = new(PVCResizeMode) **out = **in } + if in.VolumeAllowShrink != nil { + in, out := &in.VolumeAllowShrink, &out.VolumeAllowShrink + *out = new(bool) + **out = **in + } if in.AntiAffinity != nil { in, out := &in.AntiAffinity, &out.AntiAffinity *out = new(corev1.PodAntiAffinity) @@ -1648,6 +1653,21 @@ func (in *ServerIDGroupSpec) DeepCopyInto(out *ServerIDGroupSpec) { *out = new(corev1.NodeAffinity) (*in).DeepCopyInto(*out) } + if in.ServiceAccountName != nil { + in, out := &in.ServiceAccountName, &out.ServiceAccountName + *out = new(string) + **out = **in + } + if in.SecurityContext != nil { + in, out := &in.SecurityContext, &out.SecurityContext + *out = new(ServerGroupSpecSecurityContext) + (*in).DeepCopyInto(*out) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(corev1.ResourceRequirements) + (*in).DeepCopyInto(*out) + } return } diff --git a/pkg/deployment/images.go b/pkg/deployment/images.go index ac140e30f..a1a4c9a40 100644 --- a/pkg/deployment/images.go +++ b/pkg/deployment/images.go @@ -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 { @@ -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 { @@ -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 {