Skip to content

Commit 0c1eeb6

Browse files
authored
[Feature] Improved TLS rotation (#577)
1 parent 450d61c commit 0c1eeb6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1754
-614
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
44
- Add Encryption Key rotation feature for ArangoDB EE 3.7+
5+
- Improve TLS CA and Keyfile rotation for CE and EE
6+
- Add runtime TLS rotation for ArangoDB EE 3.7+
57

68
## [1.0.3](https://github.com/arangodb/kube-arangodb/tree/1.0.3) (2020-05-25)
79
- Prevent deletion of not known PVC's

pkg/apis/deployment/v1/deployment_mode.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ func (m *DeploymentMode) Get() DeploymentMode {
5858
return *m
5959
}
6060

61+
// String return string from mode
62+
func (m *DeploymentMode) String() string {
63+
return string(m.Get())
64+
}
65+
66+
// Nww return pointer to mode
67+
func (m DeploymentMode) New() *DeploymentMode {
68+
return &m
69+
}
70+
6171
// HasSingleServers returns true when the given mode is "Single" or "ActiveFailover".
6272
func (m DeploymentMode) HasSingleServers() bool {
6373
return m == DeploymentModeSingle || m == DeploymentModeActiveFailover

pkg/apis/deployment/v1/deployment_status.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ type DeploymentStatus struct {
7070
// detect changes in secret values.
7171
SecretHashes *SecretHashes `json:"secret-hashes,omitempty"`
7272

73-
// CurrentEncryptionKeys keep list of currently applied encryption keys as SHA256 hash
74-
CurrentEncryptionKeyHashes DeploymentStatusEncryptionKeyHashes `json:"currentEncryptionKeyHashes,omitempty"`
73+
// Hashes keep status of hashes in deployment
74+
Hashes DeploymentStatusHashes `json:"hashes,omitempty"`
7575

7676
// ForceStatusReload if set to true forces a reload of the status from the custom resource.
7777
ForceStatusReload *bool `json:"force-status-reload,omitempty"`

pkg/apis/deployment/v1/hashes.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2020 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+
// Author Adam Janikowski
21+
//
22+
23+
package v1
24+
25+
type DeploymentStatusHashes struct {
26+
Encryption DeploymentStatusHashList `json:"encryption,omitempty"`
27+
TLS DeploymentStatusHashesTLS `json:"tls,omitempty"`
28+
}
29+
30+
type DeploymentStatusHashesTLS struct {
31+
CA *string `json:"ca,omitempty"`
32+
Truststore DeploymentStatusHashList `json:"truststore,omitempty"`
33+
}

pkg/apis/deployment/v1/encryption_key_hashes.go renamed to pkg/apis/deployment/v1/key_hashes.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ package v1
2424

2525
import "fmt"
2626

27-
type DeploymentStatusEncryptionKeyHashes []string
27+
type DeploymentStatusHashList []string
2828

29-
func (d DeploymentStatusEncryptionKeyHashes) Contains(hash string) bool {
29+
func (d DeploymentStatusHashList) Contains(hash string) bool {
3030
if len(d) == 0 {
3131
return false
3232
}
@@ -40,6 +40,6 @@ func (d DeploymentStatusEncryptionKeyHashes) Contains(hash string) bool {
4040
return false
4141
}
4242

43-
func (d DeploymentStatusEncryptionKeyHashes) ContainsSHA256(hash string) bool {
43+
func (d DeploymentStatusHashList) ContainsSHA256(hash string) bool {
4444
return d.Contains(fmt.Sprintf("sha256:%s", hash))
4545
}

pkg/apis/deployment/v1/plan.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ import (
3232
// ActionType is a strongly typed name for a plan action item
3333
type ActionType string
3434

35+
func (a ActionType) String() string {
36+
return string(a)
37+
}
38+
3539
const (
3640
// ActionTypeIdle causes a plan to be recalculated.
3741
ActionTypeIdle ActionType = "Idle"
@@ -61,6 +65,16 @@ const (
6165
ActionTypeRenewTLSCertificate ActionType = "RenewTLSCertificate"
6266
// ActionTypeRenewTLSCACertificate causes the TLS CA certificate of the entire deployment to be renewed.
6367
ActionTypeRenewTLSCACertificate ActionType = "RenewTLSCACertificate"
68+
// ActionTypeAppendTLSCACertificate add TLS CA certificate to local truststore.
69+
ActionTypeAppendTLSCACertificate ActionType = "AppendTLSCACertificate"
70+
// ActionTypeCleanTLSCACertificate clean TLS CA certificate from local truststore.
71+
ActionTypeCleanTLSCACertificate ActionType = "CleanTLSCACertificate"
72+
// ActionTypeCleanTLSKeyfileCertificate clean server keyfile
73+
ActionTypeCleanTLSKeyfileCertificate ActionType = "CleanTLSKeyfileCertificate"
74+
// ActionTypeRefreshTLSKeyfileCertificate refresh server keyfile using API
75+
ActionTypeRefreshTLSKeyfileCertificate ActionType = "RefreshTLSKeyfileCertificate"
76+
// ActionTypeTLSKeyStatusUpdate update status with current data from deployment
77+
ActionTypeTLSKeyStatusUpdate ActionType = "TLSKeyStatusUpdate"
6478
// ActionTypeUpdateTLSSNI update SNI inplace.
6579
ActionTypeUpdateTLSSNI ActionType = "UpdateTLSSNI"
6680
// ActionTypeSetCurrentImage causes status.CurrentImage to be updated to the image given in the action.

pkg/apis/deployment/v1/tls_sni_spec.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,9 @@ import (
2727
"github.com/pkg/errors"
2828
)
2929

30-
type TLSSNIRotateMode string
31-
32-
func (t *TLSSNIRotateMode) Get() TLSSNIRotateMode {
33-
if t == nil {
34-
return TLSSNIRotateModeInPlace
35-
}
36-
37-
return *t
38-
}
39-
40-
const (
41-
TLSSNIRotateModeInPlace TLSSNIRotateMode = "inplace"
42-
TLSSNIRotateModeRecreate TLSSNIRotateMode = "recreate"
43-
)
44-
4530
// TLSSNISpec holds TLS SNI additional certificates
4631
type TLSSNISpec struct {
4732
Mapping map[string][]string `json:"mapping,omitempty"`
48-
Mode *TLSSNIRotateMode `json:"mode,omitempty"`
4933
}
5034

5135
func (s TLSSNISpec) Validate() error {

pkg/apis/deployment/v1/tls_spec.go

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,36 @@ import (
3131
"github.com/arangodb/kube-arangodb/pkg/util/validation"
3232
)
3333

34+
type TLSRotateMode string
35+
36+
func (t *TLSRotateMode) Get() TLSRotateMode {
37+
if t == nil {
38+
return TLSRotateModeInPlace
39+
}
40+
41+
return *t
42+
}
43+
44+
func (t TLSRotateMode) New() *TLSRotateMode {
45+
return &t
46+
}
47+
48+
const (
49+
TLSRotateModeInPlace TLSRotateMode = "inplace"
50+
TLSRotateModeRecreate TLSRotateMode = "recreate"
51+
)
52+
3453
const (
3554
defaultTLSTTL = Duration("2610h") // About 3 month
3655
)
3756

3857
// TLSSpec holds TLS specific configuration settings
3958
type TLSSpec struct {
40-
CASecretName *string `json:"caSecretName,omitempty"`
41-
AltNames []string `json:"altNames,omitempty"`
42-
TTL *Duration `json:"ttl,omitempty"`
43-
SNI *TLSSNISpec `json:"sni,omitempty"`
59+
CASecretName *string `json:"caSecretName,omitempty"`
60+
AltNames []string `json:"altNames,omitempty"`
61+
TTL *Duration `json:"ttl,omitempty"`
62+
SNI *TLSSNISpec `json:"sni,omitempty"`
63+
Mode *TLSRotateMode `json:"mode,omitempty"`
4464
}
4565

4666
const (

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

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

pkg/deployment/deployment_inspector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func (d *Deployment) inspectDeploymentWithError(ctx context.Context, lastInterva
150150
}
151151
}
152152

153-
if err := d.resources.EnsureSecrets(cachedStatus); err != nil {
153+
if err := d.resources.EnsureSecrets(d.deps.Log, cachedStatus); err != nil {
154154
return minInspectionInterval, errors.Wrapf(err, "Secret creation failed")
155155
}
156156

0 commit comments

Comments
 (0)