1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00

GT-267 Multi-arch support for ID member (#1186)

This commit is contained in:
jwierzbo 2022-11-24 09:57:21 +01:00 committed by GitHub
parent c3dccbb7e8
commit cf80e85514
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 34 additions and 8 deletions

View file

@ -29,6 +29,7 @@
- (Improvement) Add ServerGroup details into ServerGroupSpec
- (Improvement) Add Resource kerror Type
- (Bugfix) Do not block reconciliation in case of Resource failure
- (Improvement) Multi-arch support for ID member
## [1.2.20](https://github.com/arangodb/kube-arangodb/tree/1.2.20) (2022-10-25)
- (Feature) Add action progress

View file

@ -59,6 +59,28 @@ func (a ArangoDeploymentArchitecture) IsArchAllowed(arch ArangoDeploymentArchite
return false
}
func (a ArangoDeploymentArchitecture) AsNodeSelectorRequirement() core.NodeSelectorTerm {
var archs []string
if len(a) == 0 {
archs = append(archs, ArangoDeploymentArchitectureDefault.String())
} else {
for _, arch := range a {
archs = append(archs, arch.String())
}
}
return core.NodeSelectorTerm{
MatchExpressions: []core.NodeSelectorRequirement{
{
Key: shared.NodeArchAffinityLabel,
Operator: "In",
Values: archs,
},
},
}
}
type ArangoDeploymentArchitectureType string
const (
@ -83,6 +105,10 @@ func (a ArangoDeploymentArchitectureType) Validate() error {
}
}
func (a ArangoDeploymentArchitectureType) String() string {
return string(a)
}
func (a *ArangoDeploymentArchitectureType) Default(def ArangoDeploymentArchitectureType) ArangoDeploymentArchitectureType {
if a == nil {
return def
@ -97,7 +123,7 @@ func (a ArangoDeploymentArchitectureType) AsNodeSelectorRequirement() core.NodeS
{
Key: shared.NodeArchAffinityLabel,
Operator: "In",
Values: []string{string(a)},
Values: []string{a.String()},
},
},
}

View file

@ -249,6 +249,7 @@ func (ib *imagesBuilder) fetchArangoDBImageIDAndVersion(ctx context.Context, cac
return true, errors.WithStack(err)
}
// here we need a pod with selector
err = globals.GetGlobalTimeouts().Kubernetes().RunWithTimeout(ctx, func(ctxChild context.Context) error {
_, _, err := resources.CreateArangoPod(ctxChild, ib.Context.ACS().CurrentClusterCache().PodsModInterface().V1(), ib.APIObject, ib.Spec, api.ServerGroupImageDiscovery, pod)
return err
@ -373,9 +374,7 @@ func (i *ImageUpdatePod) GetPodAffinity() *core.PodAffinity {
func (i *ImageUpdatePod) GetNodeAffinity() *core.NodeAffinity {
a := core.NodeAffinity{}
arch := i.spec.Architecture.GetDefault()
pod.AppendArchSelector(&a, arch)
pod.AppendArchSelector(&a, i.spec.Architecture.AsNodeSelectorRequirement())
pod.MergeNodeAffinity(&a, i.spec.ID.Get().NodeAffinity)

View file

@ -52,12 +52,12 @@ func AppendPodAntiAffinityDefault(p interfaces.PodCreator, a *core.PodAntiAffini
}
}
func AppendArchSelector(a *core.NodeAffinity, arch api.ArangoDeploymentArchitectureType) {
func AppendArchSelector(a *core.NodeAffinity, nodeSelectorForArch core.NodeSelectorTerm) {
if a.RequiredDuringSchedulingIgnoredDuringExecution == nil {
a.RequiredDuringSchedulingIgnoredDuringExecution = &core.NodeSelector{}
}
a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms = append(a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms, arch.AsNodeSelectorRequirement())
a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms = append(a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms, nodeSelectorForArch)
}
func GetArchFromAffinity(a *core.Affinity) api.ArangoDeploymentArchitectureType {

View file

@ -362,7 +362,7 @@ func (m *MemberArangoDPod) GetPodAffinity() *core.PodAffinity {
func (m *MemberArangoDPod) GetNodeAffinity() *core.NodeAffinity {
a := core.NodeAffinity{}
pod.AppendArchSelector(&a, m.status.Architecture.Default(m.spec.Architecture.GetDefault()))
pod.AppendArchSelector(&a, m.status.Architecture.Default(m.spec.Architecture.GetDefault()).AsNodeSelectorRequirement())
pod.MergeNodeAffinity(&a, m.groupSpec.NodeAffinity)

View file

@ -231,7 +231,7 @@ func (m *MemberSyncPod) GetPodAffinity() *core.PodAffinity {
func (m *MemberSyncPod) GetNodeAffinity() *core.NodeAffinity {
a := core.NodeAffinity{}
pod.AppendArchSelector(&a, m.memberStatus.Architecture.Default(m.spec.Architecture.GetDefault()))
pod.AppendArchSelector(&a, m.memberStatus.Architecture.Default(m.spec.Architecture.GetDefault()).AsNodeSelectorRequirement())
pod.MergeNodeAffinity(&a, m.groupSpec.NodeAffinity)