Skip to content

Commit efbbc79

Browse files
authored
[Feature] Integration TLS (#1710)
1 parent 1095567 commit efbbc79

File tree

25 files changed

+672
-180
lines changed

25 files changed

+672
-180
lines changed

.golangci.yaml

Lines changed: 94 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -23,100 +23,102 @@ linters-settings:
2323
importas:
2424
no-unaliased: true
2525
alias:
26-
- pkg: k8s.io/api/core/v1
27-
alias: core
28-
- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
29-
alias: meta
30-
- pkg: k8s.io/client-go/kubernetes/typed/core/v1
31-
alias: typedCore
32-
- pkg: k8s.io/api/apps/v1
33-
alias: apps
34-
- pkg: k8s.io/api/batch/v1
35-
alias: batch
36-
- pkg: k8s.io/api/storage/v1
37-
alias: storage
38-
- pkg: github.com/arangodb/kube-arangodb/pkg/deployment/reconcile/shared
39-
alias: sharedReconcile
40-
- pkg: k8s.io/api/policy/v1
41-
alias: policy
42-
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/shared/v1
43-
alias: sharedApi
44-
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1
45-
alias: schedulerApi
46-
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1/profiles
47-
alias: schedulerProfiles
48-
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1/container
49-
alias: schedulerContainerApi
50-
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1/container/resources
51-
alias: schedulerContainerResourcesApi
52-
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1/pod
53-
alias: schedulerPodApi
54-
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1/pod/resources
55-
alias: schedulerPodResourcesApi
56-
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1
57-
alias: schedulerApiv1alpha1
58-
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/profiles
59-
alias: schedulerProfilesv1alpha1
60-
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container
61-
alias: schedulerContainerApiv1alpha1
62-
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container/resources
63-
alias: schedulerContainerResourcesApiv1alpha1
64-
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/pod
65-
alias: schedulerPodApiv1alpha1
66-
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/pod/resources
67-
alias: schedulerPodResourcesApiv1alpha1
68-
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/shared
69-
alias: shared
70-
- pkg: github.com/arangodb/kube-arangodb/pkg/handlers/enterprise/analytics/shared
71-
alias: analyticsShared
72-
- pkg: github.com/arangodb/kube-arangodb/pkg/handlers/enterprise/shared
73-
alias: enterpriseShared
74-
- pkg: github.com/arangodb/kube-arangodb/pkg/handlers/enterprise/ml/shared
75-
alias: mlShared
76-
- pkg: github.com/arangodb/kube-arangodb/pkg/handlers/enterprise/ml/shared/test
77-
alias: mlSharedTests
78-
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1
79-
alias: analyticsApi
80-
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/networking/v1alpha1
81-
alias: networkingApi
82-
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/ml/v1beta1
83-
alias: mlApi
84-
- pkg: github.com/arangodb/kube-arangodb/pkg/apis/ml/v1alpha1
85-
alias: mlApiv1alpha1
86-
- pkg: github.com/arangodb/kube-arangodb/integrations/scheduler/v1/definition
87-
alias: pbSchedulerV1
88-
- pkg: github.com/arangodb/kube-arangodb/integrations/scheduler/v1
89-
alias: pbImplSchedulerV1
90-
- pkg: github.com/arangodb/kube-arangodb/integrations/shutdown/v1/definition
91-
alias: pbShutdownV1
92-
- pkg: github.com/arangodb/kube-arangodb/integrations/shutdown/v1
93-
alias: pbImplShutdownV1
94-
- pkg: github.com/arangodb/kube-arangodb/integrations/authentication/v1/definition
95-
alias: pbAuthenticationV1
96-
- pkg: github.com/arangodb/kube-arangodb/integrations/authentication/v1
97-
alias: pbImplAuthenticationV1
98-
- pkg: github.com/arangodb/kube-arangodb/integrations/authorization/v0/definition
99-
alias: pbAuthorizationV0
100-
- pkg: github.com/arangodb/kube-arangodb/integrations/authorization/v0
101-
alias: pbImplAuthorizationV0
102-
- pkg: github.com/arangodb/kube-arangodb/integrations/config/v1/definition
103-
alias: pbConfigV1
104-
- pkg: github.com/arangodb/kube-arangodb/integrations/config/v1
105-
alias: pbImplConfigV1
106-
- pkg: github.com/arangodb/kube-arangodb/integrations/pong/v1/definition
107-
alias: pbPongV1
26+
- alias: pbImplAuthenticationV1
27+
pkg: github.com/arangodb/kube-arangodb/integrations/authentication/v1
28+
- alias: pbAuthenticationV1
29+
pkg: github.com/arangodb/kube-arangodb/integrations/authentication/v1/definition
30+
- alias: pbImplAuthorizationV0
31+
pkg: github.com/arangodb/kube-arangodb/integrations/authorization/v0
32+
- alias: pbAuthorizationV0
33+
pkg: github.com/arangodb/kube-arangodb/integrations/authorization/v0/definition
34+
- alias: pbImplConfigV1
35+
pkg: github.com/arangodb/kube-arangodb/integrations/config/v1
36+
- alias: pbConfigV1
37+
pkg: github.com/arangodb/kube-arangodb/integrations/config/v1/definition
38+
- alias: pbImplEnvoyAuthV3
39+
pkg: github.com/arangodb/kube-arangodb/integrations/envoy/auth/v3
10840
- pkg: github.com/arangodb/kube-arangodb/integrations/pong/v1
10941
alias: pbImplPongV1
110-
- pkg: github.com/arangodb/kube-arangodb/integrations/shared/v1/definition
111-
alias: pbSharedV1
112-
- pkg: github.com/arangodb/kube-arangodb/integrations/shared/v1
113-
alias: pbImplSharedV1
114-
- pkg: github.com/envoyproxy/go-control-plane/envoy/service/auth/v3
115-
alias: pbEnvoyAuthV3
116-
- pkg: github.com/arangodb/kube-arangodb/integrations/envoy/auth/v3
117-
alias: pbImplEnvoyAuthV3
118-
- pkg: github.com/arangodb/kube-arangodb/pkg/util/k8sutil/resources
119-
alias: kresources
42+
- pkg: github.com/arangodb/kube-arangodb/integrations/pong/v1/definition
43+
alias: pbPongV1
44+
- alias: pbImplSchedulerV1
45+
pkg: github.com/arangodb/kube-arangodb/integrations/scheduler/v1
46+
- alias: pbSchedulerV1
47+
pkg: github.com/arangodb/kube-arangodb/integrations/scheduler/v1/definition
48+
- alias: pbImplSharedV1
49+
pkg: github.com/arangodb/kube-arangodb/integrations/shared/v1
50+
- alias: pbSharedV1
51+
pkg: github.com/arangodb/kube-arangodb/integrations/shared/v1/definition
52+
- alias: pbImplShutdownV1
53+
pkg: github.com/arangodb/kube-arangodb/integrations/shutdown/v1
54+
- alias: pbShutdownV1
55+
pkg: github.com/arangodb/kube-arangodb/integrations/shutdown/v1/definition
56+
- alias: analyticsApi
57+
pkg: github.com/arangodb/kube-arangodb/pkg/apis/analytics/v1alpha1
58+
- alias: mlApiv1alpha1
59+
pkg: github.com/arangodb/kube-arangodb/pkg/apis/ml/v1alpha1
60+
- alias: mlApi
61+
pkg: github.com/arangodb/kube-arangodb/pkg/apis/ml/v1beta1
62+
- alias: networkingApi
63+
pkg: github.com/arangodb/kube-arangodb/pkg/apis/networking/v1alpha1
64+
- alias: schedulerApiv1alpha1
65+
pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1
66+
- alias: schedulerContainerApiv1alpha1
67+
pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container
68+
- alias: schedulerContainerResourcesApiv1alpha1
69+
pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/container/resources
70+
- alias: schedulerPodApiv1alpha1
71+
pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/pod
72+
- alias: schedulerPodResourcesApiv1alpha1
73+
pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/pod/resources
74+
- alias: schedulerProfilesv1alpha1
75+
pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1alpha1/profiles
76+
- alias: schedulerApi
77+
pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1
78+
- alias: schedulerContainerApi
79+
pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1/container
80+
- alias: schedulerContainerResourcesApi
81+
pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1/container/resources
82+
- alias: schedulerPodApi
83+
pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1/pod
84+
- alias: schedulerPodResourcesApi
85+
pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1/pod/resources
86+
- alias: schedulerProfiles
87+
pkg: github.com/arangodb/kube-arangodb/pkg/apis/scheduler/v1beta1/profiles
88+
- alias: shared
89+
pkg: github.com/arangodb/kube-arangodb/pkg/apis/shared
90+
- alias: sharedApi
91+
pkg: github.com/arangodb/kube-arangodb/pkg/apis/shared/v1
92+
- alias: sharedReconcile
93+
pkg: github.com/arangodb/kube-arangodb/pkg/deployment/reconcile/shared
94+
- alias: analyticsShared
95+
pkg: github.com/arangodb/kube-arangodb/pkg/handlers/enterprise/analytics/shared
96+
- alias: mlShared
97+
pkg: github.com/arangodb/kube-arangodb/pkg/handlers/enterprise/ml/shared
98+
- alias: mlSharedTests
99+
pkg: github.com/arangodb/kube-arangodb/pkg/handlers/enterprise/ml/shared/test
100+
- alias: enterpriseShared
101+
pkg: github.com/arangodb/kube-arangodb/pkg/handlers/enterprise/shared
102+
- alias: kresources
103+
pkg: github.com/arangodb/kube-arangodb/pkg/util/k8sutil/resources
104+
- alias: ktls
105+
pkg: github.com/arangodb/kube-arangodb/pkg/util/k8sutil/tls
106+
- alias: pbEnvoyAuthV3
107+
pkg: github.com/envoyproxy/go-control-plane/envoy/service/auth/v3
108+
- alias: apps
109+
pkg: k8s.io/api/apps/v1
110+
- alias: batch
111+
pkg: k8s.io/api/batch/v1
112+
- alias: core
113+
pkg: k8s.io/api/core/v1
114+
- alias: policy
115+
pkg: k8s.io/api/policy/v1
116+
- alias: storage
117+
pkg: k8s.io/api/storage/v1
118+
- alias: meta
119+
pkg: k8s.io/apimachinery/pkg/apis/meta/v1
120+
- alias: typedCore
121+
pkg: k8s.io/client-go/kubernetes/typed/core/v1
120122
gci:
121123
sections:
122124
- standard

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- (Feature) Custom Gateway image
2121
- (Bugfix) Fix race condition in ArangoBackup
2222
- (Feature) Improve Gateway Config gen
23+
- (Feature) Integration Service TLS
2324

2425
## [1.2.42](https://github.com/arangodb/kube-arangodb/tree/1.2.42) (2024-07-23)
2526
- (Maintenance) Go 1.22.4 & Kubernetes 1.29.6 libraries

docs/cli/arangodb_operator_integration.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Flags:
2222
--health.auth.token string Token for health service (when auth service is token)
2323
--health.auth.type string Auth type for health service (default "None")
2424
--health.shutdown.enabled Determines if shutdown service should be enabled and exposed (default true)
25+
--health.tls.keyfile string Path to the keyfile
2526
-h, --help help for arangodb_operator_integration
2627
--integration.authentication.v1 Enable AuthenticationV1 Integration Service
2728
--integration.authentication.v1.enabled Defines if Authentication is enabled (default true)
@@ -74,6 +75,8 @@ Flags:
7475
--services.external.auth.token string Token for external service (when auth service is token)
7576
--services.external.auth.type string Auth type for external service (default "None")
7677
--services.external.enabled Defines if external access is enabled
78+
--services.external.tls.keyfile string Path to the keyfile
79+
--services.tls.keyfile string Path to the keyfile
7780
7881
Use "arangodb_operator_integration [command] --help" for more information about a command.
7982
```
@@ -94,6 +97,10 @@ Available Commands:
9497
Flags:
9598
--address string GRPC Service Address (default "127.0.0.1:8080")
9699
-h, --help help for client
100+
--tls.ca string Path to the custom CA
101+
--tls.enabled Defines if GRPC is protected with TLS
102+
--tls.fallback Enables TLS Fallback
103+
--tls.insecure Enables Insecure TLS Connection
97104
--token string GRPC Token
98105
99106
Use "arangodb_operator_integration client [command] --help" for more information about a command.

integrations/pong/v1/impl.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929

3030
pbPongV1 "github.com/arangodb/kube-arangodb/integrations/pong/v1/definition"
3131
pbSharedV1 "github.com/arangodb/kube-arangodb/integrations/shared/v1/definition"
32-
pbShutdownV1 "github.com/arangodb/kube-arangodb/integrations/shutdown/v1/definition"
3332
"github.com/arangodb/kube-arangodb/pkg/util/svc"
3433
)
3534

@@ -45,7 +44,7 @@ type impl struct {
4544
}
4645

4746
func (i *impl) Name() string {
48-
return pbShutdownV1.Name
47+
return pbPongV1.Name
4948
}
5049

5150
func (i *impl) Health() svc.HealthState {

pkg/apis/deployment/v1/tls_spec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const (
4949
)
5050

5151
const (
52-
defaultTLSTTL = Duration("2610h") // About 3 month
52+
DefaultTLSTTL = Duration("2610h") // About 3 month
5353
)
5454

5555
// TLSSpec holds TLS specific configuration settings
@@ -157,7 +157,7 @@ func (s *TLSSpec) SetDefaults(defaultCASecretName string) {
157157
if s.GetTTL() == "" {
158158
// Note that we don't check for nil here, since even a specified, but zero
159159
// should result in the default value.
160-
s.TTL = NewDuration(defaultTLSTTL)
160+
s.TTL = NewDuration(DefaultTLSTTL)
161161
}
162162
}
163163

pkg/apis/deployment/v1/tls_spec_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -60,6 +60,6 @@ func TestTLSSpecSetDefaults(t *testing.T) {
6060
assert.Equal(t, "foo", def(TLSSpec{CASecretName: util.NewType[string]("foo")}).GetCASecretName())
6161
assert.Len(t, def(TLSSpec{}).GetAltNames(), 0)
6262
assert.Len(t, def(TLSSpec{AltNames: []string{"foo.local"}}).GetAltNames(), 1)
63-
assert.Equal(t, defaultTLSTTL, def(TLSSpec{}).GetTTL())
63+
assert.Equal(t, DefaultTLSTTL, def(TLSSpec{}).GetTTL())
6464
assert.Equal(t, time.Hour, def(TLSSpec{TTL: NewDuration("1h")}).GetTTL().AsDuration())
6565
}

pkg/apis/deployment/v2alpha1/tls_spec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const (
4949
)
5050

5151
const (
52-
defaultTLSTTL = Duration("2610h") // About 3 month
52+
DefaultTLSTTL = Duration("2610h") // About 3 month
5353
)
5454

5555
// TLSSpec holds TLS specific configuration settings
@@ -157,7 +157,7 @@ func (s *TLSSpec) SetDefaults(defaultCASecretName string) {
157157
if s.GetTTL() == "" {
158158
// Note that we don't check for nil here, since even a specified, but zero
159159
// should result in the default value.
160-
s.TTL = NewDuration(defaultTLSTTL)
160+
s.TTL = NewDuration(DefaultTLSTTL)
161161
}
162162
}
163163

pkg/apis/deployment/v2alpha1/tls_spec_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -60,6 +60,6 @@ func TestTLSSpecSetDefaults(t *testing.T) {
6060
assert.Equal(t, "foo", def(TLSSpec{CASecretName: util.NewType[string]("foo")}).GetCASecretName())
6161
assert.Len(t, def(TLSSpec{}).GetAltNames(), 0)
6262
assert.Len(t, def(TLSSpec{AltNames: []string{"foo.local"}}).GetAltNames(), 1)
63-
assert.Equal(t, defaultTLSTTL, def(TLSSpec{}).GetTTL())
63+
assert.Equal(t, DefaultTLSTTL, def(TLSSpec{}).GetTTL())
6464
assert.Equal(t, time.Hour, def(TLSSpec{TTL: NewDuration("1h")}).GetTTL().AsDuration())
6565
}

pkg/deployment/reconcile/plan_builder_tls.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import (
4747
operatorHTTP "github.com/arangodb/kube-arangodb/pkg/util/http"
4848
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
4949
inspectorInterface "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
50-
memberTls "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/tls"
50+
ktls "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/tls"
5151
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/tools"
5252
"github.com/arangodb/kube-arangodb/pkg/util/strings"
5353
)
@@ -542,13 +542,13 @@ func (r *Reconciler) keyfileRenewalRequired(ctx context.Context, apiObject k8sut
542542
}
543543

544544
// Verify AltNames
545-
var altNames memberTls.KeyfileInput
545+
var altNames ktls.KeyfileInput
546546

547547
switch group.Type() {
548548
case api.ServerGroupTypeArangoD:
549-
altNames, err = memberTls.GetServerAltNames(apiObject, spec, tlsSpec, service, group, member)
549+
altNames, err = ktls.GetServerAltNames(apiObject, spec, tlsSpec, service, group, member)
550550
case api.ServerGroupTypeArangoSync:
551-
altNames, err = memberTls.GetSyncAltNames(apiObject, spec, tlsSpec, group, member)
551+
altNames, err = ktls.GetSyncAltNames(apiObject, spec, tlsSpec, group, member)
552552
default:
553553
assertion.InvalidGroupKey.Assert(true, "Unable to check TLS Key Renewal for an unknown group: %s", group.AsRole())
554554
return false, false

pkg/deployment/resources/certificates_client_auth.go

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -23,36 +23,23 @@ package resources
2323
import (
2424
"context"
2525
"fmt"
26-
"time"
2726

2827
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
2928

30-
certificates "github.com/arangodb-helper/go-certificates"
31-
3229
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
3330
"github.com/arangodb/kube-arangodb/pkg/util/errors"
3431
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
3532
secretv1 "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/secret/v1"
3633
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/kerrors"
37-
)
38-
39-
const (
40-
clientAuthECDSACurve = "P256" // This curve is the default that ArangoDB accepts and plenty strong
34+
ktls "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/tls"
4135
)
4236

4337
// createClientAuthCACertificate creates a client authentication CA certificate and stores it in a secret with name
4438
// specified in the given spec.
4539
func (r *Resources) createClientAuthCACertificate(ctx context.Context, secrets secretv1.ModInterface, spec api.SyncAuthenticationSpec, deploymentName string, ownerRef *meta.OwnerReference) error {
4640
log := r.log.Str("section", "secrets")
47-
options := certificates.CreateCertificateOptions{
48-
CommonName: fmt.Sprintf("%s Client Authentication Root Certificate", deploymentName),
49-
ValidFrom: time.Now(),
50-
ValidFor: caTTL,
51-
IsCA: true,
52-
IsClientAuth: true,
53-
ECDSACurve: clientAuthECDSACurve,
54-
}
55-
cert, priv, err := certificates.CreateCertificate(options, nil)
41+
42+
cert, priv, err := ktls.CreateTLSCACertificate(fmt.Sprintf("%s Client Authentication Root Certificate", deploymentName))
5643
if err != nil {
5744
log.Err(err).Str("name", spec.GetClientCASecretName()).Debug("Failed to create CA certificate")
5845
return errors.WithStack(err)

0 commit comments

Comments
 (0)