Skip to content

Commit c7e558a

Browse files
author
lamai93
committed
Added disableIPV6 Spec entry.
1 parent 28abb1b commit c7e558a

File tree

6 files changed

+39
-9
lines changed

6 files changed

+39
-9
lines changed

docs/Manual/Deployment/Kubernetes/DeploymentResource.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,12 @@ servers.
325325
When not specified, no monitoring token is used.
326326
The default value is empty.
327327

328-
### `spec.ipv6.forbidden: bool`
328+
### `spec.disableIPV6: bool`
329329

330330
This setting prevents the use of IPv6 addresses by ArangoDB servers.
331-
The default is `false`.
331+
The default is `false`.
332+
333+
This setting cannot be changed after the deployment has been created.
332334

333335
### `spec.<group>.count: number`
334336

pkg/apis/deployment/v1alpha/deployment_spec.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type DeploymentSpec struct {
5151
Image *string `json:"image,omitempty"`
5252
ImagePullPolicy *v1.PullPolicy `json:"imagePullPolicy,omitempty"`
5353
DowntimeAllowed *bool `json:"downtimeAllowed,omitempty"`
54+
DisableIPV6 *bool `json:"disableIPV6,omitempty"`
5455

5556
ExternalAccess ExternalAccessSpec `json:"externalAccess"`
5657
RocksDB RocksDBSpec `json:"rocksdb"`
@@ -98,6 +99,19 @@ func (s DeploymentSpec) IsDowntimeAllowed() bool {
9899
return util.BoolOrDefault(s.DowntimeAllowed)
99100
}
100101

102+
// IsDisableIPV6 returns the value of disableIPV6.
103+
func (s DeploymentSpec) IsDisableIPV6() bool {
104+
return util.BoolOrDefault(s.DisableIPV6)
105+
}
106+
107+
// GetListenAddr returns "[::]" or "0.0.0.0" depending on IsDisableIPV6
108+
func (s DeploymentSpec) GetListenAddr() string {
109+
if s.IsDisableIPV6() {
110+
return "0.0.0.0"
111+
}
112+
return "[::]"
113+
}
114+
101115
// IsAuthenticated returns true when authentication is enabled
102116
func (s DeploymentSpec) IsAuthenticated() bool {
103117
return s.Authentication.IsAuthenticated()
@@ -180,6 +194,9 @@ func (s *DeploymentSpec) SetDefaultsFrom(source DeploymentSpec) {
180194
if s.DowntimeAllowed == nil {
181195
s.DowntimeAllowed = util.NewBoolOrNil(source.DowntimeAllowed)
182196
}
197+
if s.DisableIPV6 == nil {
198+
s.DisableIPV6 = util.NewBoolOrNil(source.DisableIPV6)
199+
}
183200
s.ExternalAccess.SetDefaultsFrom(source.ExternalAccess)
184201
s.RocksDB.SetDefaultsFrom(source.RocksDB)
185202
s.Authentication.SetDefaultsFrom(source.Authentication)
@@ -269,6 +286,10 @@ func (s DeploymentSpec) ResetImmutableFields(target *DeploymentSpec) []string {
269286
target.StorageEngine = NewStorageEngineOrNil(s.StorageEngine)
270287
resetFields = append(resetFields, "storageEngine")
271288
}
289+
if s.IsDisableIPV6() != target.IsDisableIPV6() {
290+
target.DisableIPV6 = util.NewBoolOrNil(s.DisableIPV6)
291+
resetFields = append(resetFields, "disableIPV6")
292+
}
272293
if l := s.ExternalAccess.ResetImmutableFields("externalAccess", &target.ExternalAccess); l != nil {
273294
resetFields = append(resetFields, l...)
274295
}

pkg/apis/deployment/v1alpha/deployment_spec_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ func TestDeploymentSpecResetImmutableFields(t *testing.T) {
9696
true,
9797
[]string{"mode", "agents.count"},
9898
},
99+
{
100+
DeploymentSpec{DisableIPV6: util.NewBool(false)},
101+
DeploymentSpec{DisableIPV6: util.NewBool(true)},
102+
DeploymentSpec{DisableIPV6: util.NewBool(false)},
103+
false,
104+
[]string{"disableIPV6"},
105+
},
99106
}
100107

101108
for _, test := range tests {

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

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/deployment/images.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func (ib *imagesBuilder) fetchArangoDBImageIDAndVersion(ctx context.Context, ima
166166
// Pod cannot be fetched, ensure it is created
167167
args := []string{
168168
"--server.authentication=false",
169-
fmt.Sprintf("--server.endpoint=tcp://[::]:%d", k8sutil.ArangoPort),
169+
fmt.Sprintf("--server.endpoint=tcp://%s:%d", ib.Spec.GetListenAddr(), k8sutil.ArangoPort),
170170
"--database.directory=" + k8sutil.ArangodVolumeMountDir,
171171
"--log.output=+",
172172
}

pkg/deployment/resources/pod_creator.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,13 @@ func createArangodArgs(apiObject metav1.Object, deplSpec api.DeploymentSpec, gro
6666
options := make([]optionPair, 0, 64)
6767
svrSpec := deplSpec.GetServerGroupSpec(group)
6868

69-
// Endpoint
70-
listenAddr := "[::]"
71-
/* if apiObject.Spec.Di.DisableIPv6 {
72-
listenAddr = "0.0.0.0"
73-
}*/
7469
//scheme := NewURLSchemes(bsCfg.SslKeyFile != "").Arangod
7570
scheme := "tcp"
7671
if deplSpec.IsSecure() {
7772
scheme = "ssl"
7873
}
7974
options = append(options,
80-
optionPair{"--server.endpoint", fmt.Sprintf("%s://%s:%d", scheme, listenAddr, k8sutil.ArangoPort)},
75+
optionPair{"--server.endpoint", fmt.Sprintf("%s://%s:%d", scheme, deplSpec.GetListenAddr(), k8sutil.ArangoPort)},
8176
)
8277

8378
// Authentication

0 commit comments

Comments
 (0)