Skip to content

Commit 0350466

Browse files
authored
[Feature] ARM64 Support (#900)
1 parent c8a0920 commit 0350466

File tree

16 files changed

+269
-20
lines changed

16 files changed

+269
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Add status.members.<group>.
66
- Define MemberReplacementRequired condition
77
- Remove pod immediately when annotation is turned on
8+
- (ARM64) Add support for ARM64 enablement
89

910
## [1.2.7](https://github.com/arangodb/kube-arangodb/tree/1.2.7) (2022-01-17)
1011
- Add Plan BackOff functionality

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ LABEL name="kube-arangodb" \
1313
ADD ./LICENSE /licenses/LICENSE
1414

1515
ARG RELEASE_MODE=community
16-
ARG TARGETARCH=amd64
16+
ARG TARGETARCH
1717
ADD bin/${RELEASE_MODE}/linux/${TARGETARCH}/arangodb_operator /usr/bin/arangodb_operator
1818

1919
ENTRYPOINT [ "/usr/bin/arangodb_operator" ]

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ REPOPATH := $(ORGPATH)/$(REPONAME)
3131

3232
include $(ROOT)/$(RELEASE_MODE).mk
3333

34-
GOPATH := $(GOBUILDDIR)
34+
ifndef KEEP_GOPATH
35+
GOPATH := $(GOBUILDDIR)
36+
endif
37+
38+
GOBUILDARGS ?=
3539
GOVERSION := 1.17-alpine3.15
3640
DISTRIBUTION := alpine:3.15
3741

@@ -272,11 +276,11 @@ bin-all: $(BIN) $(VBIN_LINUX_AMD64) $(VBIN_LINUX_ARM64)
272276

273277
$(VBIN_LINUX_AMD64): $(SOURCES) dashboard/assets.go VERSION
274278
@mkdir -p $(BINDIR)/$(RELEASE_MODE)/linux/amd64
275-
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) ./
279+
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) ./
276280

277281
$(VBIN_LINUX_ARM64): $(SOURCES) dashboard/assets.go VERSION
278282
@mkdir -p $(BINDIR)/$(RELEASE_MODE)/linux/arm64
279-
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) ./
283+
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) ./
280284

281285
$(BIN): $(VBIN_LINUX_AMD64)
282286
@cp "$(VBIN_LINUX_AMD64)" "$(BIN)"

chart/kube-arangodb/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ Define if RBAC should be enabled.
193193

194194
Default: `true`
195195

196+
### `operator.architectures`
197+
198+
List of supported architectures.
199+
200+
Default: `[]string{"amd64"}`
201+
196202
# Limitations
197203

198204
N/A

chart/kube-arangodb/templates/deployment.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ spec:
6363
- key: beta.kubernetes.io/arch
6464
operator: In
6565
values:
66-
- amd64
66+
{{- range .Values.operator.architectures }}
67+
- {{ . | quote }}
68+
{{- end }}
6769
podAntiAffinity:
6870
preferredDuringSchedulingIgnoredDuringExecution:
6971
- weight: 100

chart/kube-arangodb/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ operator:
66
imagePullSecrets: []
77

88
scope: legacy
9+
10+
architectures:
11+
- amd64
912

1013
debug: false
1114

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package v1
22+
23+
import (
24+
"runtime"
25+
26+
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
27+
"github.com/pkg/errors"
28+
core "k8s.io/api/core/v1"
29+
)
30+
31+
type ArangoDeploymentArchitecture []ArangoDeploymentArchitectureType
32+
33+
func (a ArangoDeploymentArchitecture) GetDefault() ArangoDeploymentArchitectureType {
34+
if len(a) == 0 {
35+
return ArangoDeploymentArchitectureDefault
36+
}
37+
38+
return a[0]
39+
}
40+
41+
func (a ArangoDeploymentArchitecture) Validate() error {
42+
if len(a) > 1 {
43+
return errors.Errorf("Only one architecture type is supported currently")
44+
}
45+
46+
for id := range a {
47+
if err := a[id].Validate(); err != nil {
48+
return errors.WithStack(errors.Wrapf(err, "%d", id))
49+
}
50+
}
51+
52+
return nil
53+
}
54+
55+
func (a ArangoDeploymentArchitecture) AsNodeSelectorRequirement() core.NodeSelectorTerm {
56+
return core.NodeSelectorTerm{
57+
MatchExpressions: []core.NodeSelectorRequirement{
58+
{
59+
Key: k8sutil.NodeArchAffinityLabel,
60+
Operator: "In",
61+
Values: []string{string(a.GetDefault())},
62+
},
63+
},
64+
}
65+
}
66+
67+
type ArangoDeploymentArchitectureType string
68+
69+
const (
70+
// ArangoDeploymentArchitectureAMD64 define const for architecture for amd64
71+
ArangoDeploymentArchitectureAMD64 ArangoDeploymentArchitectureType = "amd64"
72+
// ArangoDeploymentArchitectureARM64 define const for architecture for arm64
73+
ArangoDeploymentArchitectureARM64 ArangoDeploymentArchitectureType = "arm64"
74+
75+
// ArangoDeploymentArchitectureDefault define default architecture used by Operator
76+
ArangoDeploymentArchitectureDefault = ArangoDeploymentArchitectureAMD64
77+
78+
// ArangoDeploymentArchitectureCurrent define current Operator architecture
79+
ArangoDeploymentArchitectureCurrent = ArangoDeploymentArchitectureType(runtime.GOARCH)
80+
)
81+
82+
func (a ArangoDeploymentArchitectureType) Validate() error {
83+
switch q := a; q {
84+
case ArangoDeploymentArchitectureAMD64, ArangoDeploymentArchitectureARM64:
85+
return nil
86+
default:
87+
return errors.Errorf("Unknown architecture type %s", q)
88+
}
89+
}

pkg/apis/deployment/v1/deployment_spec.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ const (
8383
DeploymentCommunicationMethodHeadlessService DeploymentCommunicationMethod = "headless"
8484
// DeploymentCommunicationMethodDNS define ClusterIP Service DNS based communication.
8585
DeploymentCommunicationMethodDNS DeploymentCommunicationMethod = "dns"
86-
// DeploymentCommunicationMethodDNS define ClusterIP Service DNS based communication. Use namespaced short DNS (used in migration)
86+
// DeploymentCommunicationMethodShortDNS define ClusterIP Service DNS based communication. Use namespaced short DNS (used in migration)
8787
DeploymentCommunicationMethodShortDNS DeploymentCommunicationMethod = "short-dns"
8888
// DeploymentCommunicationMethodIP define ClusterIP Servce IP based communication.
8989
DeploymentCommunicationMethodIP DeploymentCommunicationMethod = "ip"
@@ -168,6 +168,9 @@ type DeploymentSpec struct {
168168

169169
// Rebalancer define the rebalancer specification
170170
Rebalancer *ArangoDeploymentRebalancerSpec `json:"rebalancer,omitempty"`
171+
172+
// Architecture definition of supported architectures
173+
Architecture ArangoDeploymentArchitecture `json:"architecture,omitempty"`
171174
}
172175

173176
// GetAllowMemberRecreation returns member recreation policy based on group and settings
@@ -461,6 +464,9 @@ func (s *DeploymentSpec) Validate() error {
461464
if err := s.Bootstrap.Validate(); err != nil {
462465
return errors.WithStack(err)
463466
}
467+
if err := s.Architecture.Validate(); err != nil {
468+
return errors.WithStack(errors.Wrap(err, "spec.architecture"))
469+
}
464470
return nil
465471
}
466472

pkg/apis/deployment/v1/zz_generated.deepcopy.go

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package v2alpha1
22+
23+
import (
24+
"runtime"
25+
26+
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
27+
"github.com/pkg/errors"
28+
core "k8s.io/api/core/v1"
29+
)
30+
31+
type ArangoDeploymentArchitecture []ArangoDeploymentArchitectureType
32+
33+
func (a ArangoDeploymentArchitecture) GetDefault() ArangoDeploymentArchitectureType {
34+
if len(a) == 0 {
35+
return ArangoDeploymentArchitectureDefault
36+
}
37+
38+
return a[0]
39+
}
40+
41+
func (a ArangoDeploymentArchitecture) Validate() error {
42+
if len(a) > 1 {
43+
return errors.Errorf("Only one architecture type is supported currently")
44+
}
45+
46+
for id := range a {
47+
if err := a[id].Validate(); err != nil {
48+
return errors.WithStack(errors.Wrapf(err, "%d", id))
49+
}
50+
}
51+
52+
return nil
53+
}
54+
55+
func (a ArangoDeploymentArchitecture) AsNodeSelectorRequirement() core.NodeSelectorTerm {
56+
return core.NodeSelectorTerm{
57+
MatchExpressions: []core.NodeSelectorRequirement{
58+
{
59+
Key: k8sutil.NodeArchAffinityLabel,
60+
Operator: "In",
61+
Values: []string{string(a.GetDefault())},
62+
},
63+
},
64+
}
65+
}
66+
67+
type ArangoDeploymentArchitectureType string
68+
69+
const (
70+
// ArangoDeploymentArchitectureAMD64 define const for architecture for amd64
71+
ArangoDeploymentArchitectureAMD64 ArangoDeploymentArchitectureType = "amd64"
72+
// ArangoDeploymentArchitectureARM64 define const for architecture for arm64
73+
ArangoDeploymentArchitectureARM64 ArangoDeploymentArchitectureType = "arm64"
74+
75+
// ArangoDeploymentArchitectureDefault define default architecture used by Operator
76+
ArangoDeploymentArchitectureDefault = ArangoDeploymentArchitectureAMD64
77+
78+
// ArangoDeploymentArchitectureCurrent define current Operator architecture
79+
ArangoDeploymentArchitectureCurrent = ArangoDeploymentArchitectureType(runtime.GOARCH)
80+
)
81+
82+
func (a ArangoDeploymentArchitectureType) Validate() error {
83+
switch q := a; q {
84+
case ArangoDeploymentArchitectureAMD64, ArangoDeploymentArchitectureARM64:
85+
return nil
86+
default:
87+
return errors.Errorf("Unknown architecture type %s", q)
88+
}
89+
}

0 commit comments

Comments
 (0)