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

[Feature] ARM64 Support (#900)

This commit is contained in:
Adam Janikowski 2022-02-02 11:56:57 +01:00 committed by GitHub
parent c8a0920c16
commit 0350466568
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 269 additions and 20 deletions

View file

@ -5,6 +5,7 @@
- Add status.members.<group>. - Add status.members.<group>.
- Define MemberReplacementRequired condition - Define MemberReplacementRequired condition
- Remove pod immediately when annotation is turned on - Remove pod immediately when annotation is turned on
- (ARM64) Add support for ARM64 enablement
## [1.2.7](https://github.com/arangodb/kube-arangodb/tree/1.2.7) (2022-01-17) ## [1.2.7](https://github.com/arangodb/kube-arangodb/tree/1.2.7) (2022-01-17)
- Add Plan BackOff functionality - Add Plan BackOff functionality

View file

@ -13,7 +13,7 @@ LABEL name="kube-arangodb" \
ADD ./LICENSE /licenses/LICENSE ADD ./LICENSE /licenses/LICENSE
ARG RELEASE_MODE=community ARG RELEASE_MODE=community
ARG TARGETARCH=amd64 ARG TARGETARCH
ADD bin/${RELEASE_MODE}/linux/${TARGETARCH}/arangodb_operator /usr/bin/arangodb_operator ADD bin/${RELEASE_MODE}/linux/${TARGETARCH}/arangodb_operator /usr/bin/arangodb_operator
ENTRYPOINT [ "/usr/bin/arangodb_operator" ] ENTRYPOINT [ "/usr/bin/arangodb_operator" ]

View file

@ -31,7 +31,11 @@ REPOPATH := $(ORGPATH)/$(REPONAME)
include $(ROOT)/$(RELEASE_MODE).mk include $(ROOT)/$(RELEASE_MODE).mk
GOPATH := $(GOBUILDDIR) ifndef KEEP_GOPATH
GOPATH := $(GOBUILDDIR)
endif
GOBUILDARGS ?=
GOVERSION := 1.17-alpine3.15 GOVERSION := 1.17-alpine3.15
DISTRIBUTION := alpine:3.15 DISTRIBUTION := alpine:3.15
@ -272,11 +276,11 @@ bin-all: $(BIN) $(VBIN_LINUX_AMD64) $(VBIN_LINUX_ARM64)
$(VBIN_LINUX_AMD64): $(SOURCES) dashboard/assets.go VERSION $(VBIN_LINUX_AMD64): $(SOURCES) dashboard/assets.go VERSION
@mkdir -p $(BINDIR)/$(RELEASE_MODE)/linux/amd64 @mkdir -p $(BINDIR)/$(RELEASE_MODE)/linux/amd64
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build --tags "$(RELEASE_MODE)" $(COMPILE_DEBUG_FLAGS) -installsuffix netgo -ldflags "-X $(REPOPATH)/pkg/version.version=$(VERSION) -X $(REPOPATH)/pkg/version.buildDate=$(BUILDTIME) -X $(REPOPATH)/pkg/version.build=$(COMMIT)" -o $(VBIN_LINUX_AMD64) ./ CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ${GOBUILDARGS} --tags "$(RELEASE_MODE)" $(COMPILE_DEBUG_FLAGS) -installsuffix netgo -ldflags "-X $(REPOPATH)/pkg/version.version=$(VERSION) -X $(REPOPATH)/pkg/version.buildDate=$(BUILDTIME) -X $(REPOPATH)/pkg/version.build=$(COMMIT)" -o $(VBIN_LINUX_AMD64) ./
$(VBIN_LINUX_ARM64): $(SOURCES) dashboard/assets.go VERSION $(VBIN_LINUX_ARM64): $(SOURCES) dashboard/assets.go VERSION
@mkdir -p $(BINDIR)/$(RELEASE_MODE)/linux/arm64 @mkdir -p $(BINDIR)/$(RELEASE_MODE)/linux/arm64
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build --tags "$(RELEASE_MODE)" $(COMPILE_DEBUG_FLAGS) -installsuffix netgo -ldflags "-X $(REPOPATH)/pkg/version.version=$(VERSION) -X $(REPOPATH)/pkg/version.buildDate=$(BUILDTIME) -X $(REPOPATH)/pkg/version.build=$(COMMIT)" -o $(VBIN_LINUX_ARM64) ./ CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build ${GOBUILDARGS} --tags "$(RELEASE_MODE)" $(COMPILE_DEBUG_FLAGS) -installsuffix netgo -ldflags "-X $(REPOPATH)/pkg/version.version=$(VERSION) -X $(REPOPATH)/pkg/version.buildDate=$(BUILDTIME) -X $(REPOPATH)/pkg/version.build=$(COMMIT)" -o $(VBIN_LINUX_ARM64) ./
$(BIN): $(VBIN_LINUX_AMD64) $(BIN): $(VBIN_LINUX_AMD64)
@cp "$(VBIN_LINUX_AMD64)" "$(BIN)" @cp "$(VBIN_LINUX_AMD64)" "$(BIN)"

View file

@ -193,6 +193,12 @@ Define if RBAC should be enabled.
Default: `true` Default: `true`
### `operator.architectures`
List of supported architectures.
Default: `[]string{"amd64"}`
# Limitations # Limitations
N/A N/A

View file

@ -63,7 +63,9 @@ spec:
- key: beta.kubernetes.io/arch - key: beta.kubernetes.io/arch
operator: In operator: In
values: values:
- amd64 {{- range .Values.operator.architectures }}
- {{ . | quote }}
{{- end }}
podAntiAffinity: podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution: preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100 - weight: 100

View file

@ -6,6 +6,9 @@ operator:
imagePullSecrets: [] imagePullSecrets: []
scope: legacy scope: legacy
architectures:
- amd64
debug: false debug: false

View file

@ -0,0 +1,89 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 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
//
package v1
import (
"runtime"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
"github.com/pkg/errors"
core "k8s.io/api/core/v1"
)
type ArangoDeploymentArchitecture []ArangoDeploymentArchitectureType
func (a ArangoDeploymentArchitecture) GetDefault() ArangoDeploymentArchitectureType {
if len(a) == 0 {
return ArangoDeploymentArchitectureDefault
}
return a[0]
}
func (a ArangoDeploymentArchitecture) Validate() error {
if len(a) > 1 {
return errors.Errorf("Only one architecture type is supported currently")
}
for id := range a {
if err := a[id].Validate(); err != nil {
return errors.WithStack(errors.Wrapf(err, "%d", id))
}
}
return nil
}
func (a ArangoDeploymentArchitecture) AsNodeSelectorRequirement() core.NodeSelectorTerm {
return core.NodeSelectorTerm{
MatchExpressions: []core.NodeSelectorRequirement{
{
Key: k8sutil.NodeArchAffinityLabel,
Operator: "In",
Values: []string{string(a.GetDefault())},
},
},
}
}
type ArangoDeploymentArchitectureType string
const (
// ArangoDeploymentArchitectureAMD64 define const for architecture for amd64
ArangoDeploymentArchitectureAMD64 ArangoDeploymentArchitectureType = "amd64"
// ArangoDeploymentArchitectureARM64 define const for architecture for arm64
ArangoDeploymentArchitectureARM64 ArangoDeploymentArchitectureType = "arm64"
// ArangoDeploymentArchitectureDefault define default architecture used by Operator
ArangoDeploymentArchitectureDefault = ArangoDeploymentArchitectureAMD64
// ArangoDeploymentArchitectureCurrent define current Operator architecture
ArangoDeploymentArchitectureCurrent = ArangoDeploymentArchitectureType(runtime.GOARCH)
)
func (a ArangoDeploymentArchitectureType) Validate() error {
switch q := a; q {
case ArangoDeploymentArchitectureAMD64, ArangoDeploymentArchitectureARM64:
return nil
default:
return errors.Errorf("Unknown architecture type %s", q)
}
}

View file

@ -83,7 +83,7 @@ const (
DeploymentCommunicationMethodHeadlessService DeploymentCommunicationMethod = "headless" DeploymentCommunicationMethodHeadlessService DeploymentCommunicationMethod = "headless"
// DeploymentCommunicationMethodDNS define ClusterIP Service DNS based communication. // DeploymentCommunicationMethodDNS define ClusterIP Service DNS based communication.
DeploymentCommunicationMethodDNS DeploymentCommunicationMethod = "dns" DeploymentCommunicationMethodDNS DeploymentCommunicationMethod = "dns"
// DeploymentCommunicationMethodDNS define ClusterIP Service DNS based communication. Use namespaced short DNS (used in migration) // DeploymentCommunicationMethodShortDNS define ClusterIP Service DNS based communication. Use namespaced short DNS (used in migration)
DeploymentCommunicationMethodShortDNS DeploymentCommunicationMethod = "short-dns" DeploymentCommunicationMethodShortDNS DeploymentCommunicationMethod = "short-dns"
// DeploymentCommunicationMethodIP define ClusterIP Servce IP based communication. // DeploymentCommunicationMethodIP define ClusterIP Servce IP based communication.
DeploymentCommunicationMethodIP DeploymentCommunicationMethod = "ip" DeploymentCommunicationMethodIP DeploymentCommunicationMethod = "ip"
@ -168,6 +168,9 @@ type DeploymentSpec struct {
// Rebalancer define the rebalancer specification // Rebalancer define the rebalancer specification
Rebalancer *ArangoDeploymentRebalancerSpec `json:"rebalancer,omitempty"` Rebalancer *ArangoDeploymentRebalancerSpec `json:"rebalancer,omitempty"`
// Architecture definition of supported architectures
Architecture ArangoDeploymentArchitecture `json:"architecture,omitempty"`
} }
// GetAllowMemberRecreation returns member recreation policy based on group and settings // GetAllowMemberRecreation returns member recreation policy based on group and settings
@ -461,6 +464,9 @@ func (s *DeploymentSpec) Validate() error {
if err := s.Bootstrap.Validate(); err != nil { if err := s.Bootstrap.Validate(); err != nil {
return errors.WithStack(err) return errors.WithStack(err)
} }
if err := s.Architecture.Validate(); err != nil {
return errors.WithStack(errors.Wrap(err, "spec.architecture"))
}
return nil return nil
} }

View file

@ -183,6 +183,26 @@ func (in *ArangoDeployment) DeepCopyObject() runtime.Object {
return nil return nil
} }
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in ArangoDeploymentArchitecture) DeepCopyInto(out *ArangoDeploymentArchitecture) {
{
in := &in
*out = make(ArangoDeploymentArchitecture, len(*in))
copy(*out, *in)
return
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoDeploymentArchitecture.
func (in ArangoDeploymentArchitecture) DeepCopy() ArangoDeploymentArchitecture {
if in == nil {
return nil
}
out := new(ArangoDeploymentArchitecture)
in.DeepCopyInto(out)
return *out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ArangoDeploymentList) DeepCopyInto(out *ArangoDeploymentList) { func (in *ArangoDeploymentList) DeepCopyInto(out *ArangoDeploymentList) {
*out = *in *out = *in
@ -844,6 +864,11 @@ func (in *DeploymentSpec) DeepCopyInto(out *DeploymentSpec) {
*out = new(ArangoDeploymentRebalancerSpec) *out = new(ArangoDeploymentRebalancerSpec)
(*in).DeepCopyInto(*out) (*in).DeepCopyInto(*out)
} }
if in.Architecture != nil {
in, out := &in.Architecture, &out.Architecture
*out = make(ArangoDeploymentArchitecture, len(*in))
copy(*out, *in)
}
return return
} }

View file

@ -0,0 +1,89 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 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
//
package v2alpha1
import (
"runtime"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
"github.com/pkg/errors"
core "k8s.io/api/core/v1"
)
type ArangoDeploymentArchitecture []ArangoDeploymentArchitectureType
func (a ArangoDeploymentArchitecture) GetDefault() ArangoDeploymentArchitectureType {
if len(a) == 0 {
return ArangoDeploymentArchitectureDefault
}
return a[0]
}
func (a ArangoDeploymentArchitecture) Validate() error {
if len(a) > 1 {
return errors.Errorf("Only one architecture type is supported currently")
}
for id := range a {
if err := a[id].Validate(); err != nil {
return errors.WithStack(errors.Wrapf(err, "%d", id))
}
}
return nil
}
func (a ArangoDeploymentArchitecture) AsNodeSelectorRequirement() core.NodeSelectorTerm {
return core.NodeSelectorTerm{
MatchExpressions: []core.NodeSelectorRequirement{
{
Key: k8sutil.NodeArchAffinityLabel,
Operator: "In",
Values: []string{string(a.GetDefault())},
},
},
}
}
type ArangoDeploymentArchitectureType string
const (
// ArangoDeploymentArchitectureAMD64 define const for architecture for amd64
ArangoDeploymentArchitectureAMD64 ArangoDeploymentArchitectureType = "amd64"
// ArangoDeploymentArchitectureARM64 define const for architecture for arm64
ArangoDeploymentArchitectureARM64 ArangoDeploymentArchitectureType = "arm64"
// ArangoDeploymentArchitectureDefault define default architecture used by Operator
ArangoDeploymentArchitectureDefault = ArangoDeploymentArchitectureAMD64
// ArangoDeploymentArchitectureCurrent define current Operator architecture
ArangoDeploymentArchitectureCurrent = ArangoDeploymentArchitectureType(runtime.GOARCH)
)
func (a ArangoDeploymentArchitectureType) Validate() error {
switch q := a; q {
case ArangoDeploymentArchitectureAMD64, ArangoDeploymentArchitectureARM64:
return nil
default:
return errors.Errorf("Unknown architecture type %s", q)
}
}

View file

@ -83,7 +83,7 @@ const (
DeploymentCommunicationMethodHeadlessService DeploymentCommunicationMethod = "headless" DeploymentCommunicationMethodHeadlessService DeploymentCommunicationMethod = "headless"
// DeploymentCommunicationMethodDNS define ClusterIP Service DNS based communication. // DeploymentCommunicationMethodDNS define ClusterIP Service DNS based communication.
DeploymentCommunicationMethodDNS DeploymentCommunicationMethod = "dns" DeploymentCommunicationMethodDNS DeploymentCommunicationMethod = "dns"
// DeploymentCommunicationMethodDNS define ClusterIP Service DNS based communication. Use namespaced short DNS (used in migration) // DeploymentCommunicationMethodShortDNS define ClusterIP Service DNS based communication. Use namespaced short DNS (used in migration)
DeploymentCommunicationMethodShortDNS DeploymentCommunicationMethod = "short-dns" DeploymentCommunicationMethodShortDNS DeploymentCommunicationMethod = "short-dns"
// DeploymentCommunicationMethodIP define ClusterIP Servce IP based communication. // DeploymentCommunicationMethodIP define ClusterIP Servce IP based communication.
DeploymentCommunicationMethodIP DeploymentCommunicationMethod = "ip" DeploymentCommunicationMethodIP DeploymentCommunicationMethod = "ip"
@ -168,6 +168,9 @@ type DeploymentSpec struct {
// Rebalancer define the rebalancer specification // Rebalancer define the rebalancer specification
Rebalancer *ArangoDeploymentRebalancerSpec `json:"rebalancer,omitempty"` Rebalancer *ArangoDeploymentRebalancerSpec `json:"rebalancer,omitempty"`
// Architecture definition of supported architectures
Architecture ArangoDeploymentArchitecture `json:"architecture,omitempty"`
} }
// GetAllowMemberRecreation returns member recreation policy based on group and settings // GetAllowMemberRecreation returns member recreation policy based on group and settings
@ -461,6 +464,9 @@ func (s *DeploymentSpec) Validate() error {
if err := s.Bootstrap.Validate(); err != nil { if err := s.Bootstrap.Validate(); err != nil {
return errors.WithStack(err) return errors.WithStack(err)
} }
if err := s.Architecture.Validate(); err != nil {
return errors.WithStack(errors.Wrap(err, "spec.architecture"))
}
return nil return nil
} }

View file

@ -183,6 +183,26 @@ func (in *ArangoDeployment) DeepCopyObject() runtime.Object {
return nil return nil
} }
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in ArangoDeploymentArchitecture) DeepCopyInto(out *ArangoDeploymentArchitecture) {
{
in := &in
*out = make(ArangoDeploymentArchitecture, len(*in))
copy(*out, *in)
return
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ArangoDeploymentArchitecture.
func (in ArangoDeploymentArchitecture) DeepCopy() ArangoDeploymentArchitecture {
if in == nil {
return nil
}
out := new(ArangoDeploymentArchitecture)
in.DeepCopyInto(out)
return *out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ArangoDeploymentList) DeepCopyInto(out *ArangoDeploymentList) { func (in *ArangoDeploymentList) DeepCopyInto(out *ArangoDeploymentList) {
*out = *in *out = *in
@ -844,6 +864,11 @@ func (in *DeploymentSpec) DeepCopyInto(out *DeploymentSpec) {
*out = new(ArangoDeploymentRebalancerSpec) *out = new(ArangoDeploymentRebalancerSpec)
(*in).DeepCopyInto(*out) (*in).DeepCopyInto(*out)
} }
if in.Architecture != nil {
in, out := &in.Architecture, &out.Architecture
*out = make(ArangoDeploymentArchitecture, len(*in))
copy(*out, *in)
}
return return
} }

View file

@ -355,7 +355,7 @@ func (i *ImageUpdatePod) GetPodAffinity() *core.PodAffinity {
func (i *ImageUpdatePod) GetNodeAffinity() *core.NodeAffinity { func (i *ImageUpdatePod) GetNodeAffinity() *core.NodeAffinity {
a := core.NodeAffinity{} a := core.NodeAffinity{}
pod.AppendNodeSelector(&a) pod.AppendArchSelector(&a, i.spec.Architecture)
pod.MergeNodeAffinity(&a, i.spec.ID.Get().NodeAffinity) pod.MergeNodeAffinity(&a, i.spec.ID.Get().NodeAffinity)

View file

@ -21,6 +21,7 @@
package pod package pod
import ( import (
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/interfaces" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/interfaces"
core "k8s.io/api/core/v1" core "k8s.io/api/core/v1"
@ -49,20 +50,12 @@ func AppendPodAntiAffinityDefault(p interfaces.PodCreator, a *core.PodAntiAffini
} }
} }
func AppendNodeSelector(a *core.NodeAffinity) { func AppendArchSelector(a *core.NodeAffinity, arch api.ArangoDeploymentArchitecture) {
if a.RequiredDuringSchedulingIgnoredDuringExecution == nil { if a.RequiredDuringSchedulingIgnoredDuringExecution == nil {
a.RequiredDuringSchedulingIgnoredDuringExecution = &core.NodeSelector{} a.RequiredDuringSchedulingIgnoredDuringExecution = &core.NodeSelector{}
} }
a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms = append(a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms, core.NodeSelectorTerm{ a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms = append(a.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms, arch.AsNodeSelectorRequirement())
MatchExpressions: []core.NodeSelectorRequirement{
{
Key: k8sutil.NodeArchAffinityLabel,
Operator: "In",
Values: []string{"amd64"},
},
},
})
} }
func AppendAffinityWithRole(p interfaces.PodCreator, a *core.PodAffinity, role string) { func AppendAffinityWithRole(p interfaces.PodCreator, a *core.PodAffinity, role string) {

View file

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

View file

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