Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit 68a209e

Browse files
author
Pablo Mercado
authored
Merge pull request #113 from triggermesh/task/add-redis-tls-auth-support
Redis: Add Redis tls auth support
2 parents 619756f + 24c9fa0 commit 68a209e

File tree

8 files changed

+96
-10
lines changed

8 files changed

+96
-10
lines changed

config/300-redisbroker.yaml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ spec:
8787
type: string
8888
key:
8989
type: string
90-
caCertificate:
91-
description: Contains a CA Certificate used to connect to Redis.
90+
tlsCACertificate:
91+
description: Contains a CA certificate used to connect to Redis.
9292
type: object
9393
properties:
9494
secretKeyRef:
@@ -99,6 +99,31 @@ spec:
9999
type: string
100100
key:
101101
type: string
102+
tlsCertificate:
103+
description: Contains a certificate used to connect to authenticate to Redis.
104+
type: object
105+
properties:
106+
secretKeyRef:
107+
description: A reference to a Kubernetes Secret object.
108+
type: object
109+
properties:
110+
name:
111+
type: string
112+
key:
113+
type: string
114+
tlsKey:
115+
description: Contains a key certificate used to connect to authenticate to Redis.
116+
type: object
117+
properties:
118+
secretKeyRef:
119+
description: A reference to a Kubernetes Secret object.
120+
type: object
121+
properties:
122+
name:
123+
type: string
124+
key:
125+
type: string
126+
102127
tlsEnabled:
103128
description: Use TLS enctrypted Redis connection.
104129
type: boolean

docs/redis-broker.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,15 @@ spec:
2525
secretKeyRef:
2626
name: <Kubernetes secret name>
2727
key: <Kubernetes secret key>
28-
caCertificate: <CA certificate used to connect to redis. Optional>
28+
tlsCACertificate: <CA certificate used to connect to redis. Optional>
29+
secretKeyRef:
30+
name: <Kubernetes secret name>
31+
key: <Kubernetes secret key>
32+
tlsCertificate: <Certificate used to authenticate to redis. Optional>
33+
secretKeyRef:
34+
name: <Kubernetes secret name>
35+
key: <Kubernetes secret key>
36+
tlsKey: <Certificate key used to authenticate to redis. Optional>
2937
secretKeyRef:
3038
name: <Kubernetes secret name>
3139
key: <Kubernetes secret key>

pkg/apis/eventing/v1alpha1/deepcopy_generated.go

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

pkg/apis/eventing/v1alpha1/redisbroker_types.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ type RedisConnection struct {
5656
Password *SecretValueFromSource `json:"password,omitempty"`
5757

5858
// CA Certificate used to connect to Redis.
59-
CACertificate *SecretValueFromSource `json:"caCertificate,omitempty"`
59+
TLSCACertificate *SecretValueFromSource `json:"tlsCACertificate,omitempty"`
60+
61+
// Certificate used to connect to authenticate to Redis.
62+
TLSCertificate *SecretValueFromSource `json:"tlsCertificate,omitempty"`
63+
64+
// Certificate Key used to connect to authenticate to Redis.
65+
TLSKey *SecretValueFromSource `json:"tlsKey,omitempty"`
6066

6167
// Use TLS enctrypted connection.
6268
TLSEnabled *bool `json:"tlsEnabled,omitempty"`

pkg/client/generated/injection/reconciler/eventing/v1alpha1/memorybroker/controller.go

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

pkg/client/generated/injection/reconciler/eventing/v1alpha1/redisbroker/controller.go

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

pkg/client/generated/injection/reconciler/eventing/v1alpha1/trigger/controller.go

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

pkg/reconciler/redisbroker/reconciler.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,22 @@ func redisDeploymentOption(rb *eventingv1alpha1.RedisBroker, redisSvc *corev1.Se
8484
rb.Spec.Redis.Connection.Password.SecretKeyRef.Key)(c)
8585
}
8686

87-
if rb.Spec.Redis.Connection.CACertificate != nil {
87+
if rb.Spec.Redis.Connection.TLSCACertificate != nil {
8888
resources.ContainerAddEnvVarFromSecret("REDIS_TLS_CA_CERTIFICATE",
89-
rb.Spec.Redis.Connection.CACertificate.SecretKeyRef.Name,
90-
rb.Spec.Redis.Connection.CACertificate.SecretKeyRef.Key)(c)
89+
rb.Spec.Redis.Connection.TLSCACertificate.SecretKeyRef.Name,
90+
rb.Spec.Redis.Connection.TLSCACertificate.SecretKeyRef.Key)(c)
91+
}
92+
93+
if rb.Spec.Redis.Connection.TLSCertificate != nil {
94+
resources.ContainerAddEnvVarFromSecret("REDIS_TLS_CERTIFICATE",
95+
rb.Spec.Redis.Connection.TLSCertificate.SecretKeyRef.Name,
96+
rb.Spec.Redis.Connection.TLSCertificate.SecretKeyRef.Key)(c)
97+
}
98+
99+
if rb.Spec.Redis.Connection.TLSKey != nil {
100+
resources.ContainerAddEnvVarFromSecret("REDIS_TLS_KEY",
101+
rb.Spec.Redis.Connection.TLSKey.SecretKeyRef.Name,
102+
rb.Spec.Redis.Connection.TLSKey.SecretKeyRef.Key)(c)
91103
}
92104

93105
if rb.Spec.Redis.Connection.TLSEnabled != nil && *rb.Spec.Redis.Connection.TLSEnabled {
@@ -96,7 +108,8 @@ func redisDeploymentOption(rb *eventingv1alpha1.RedisBroker, redisSvc *corev1.Se
96108

97109
if rb.Spec.Redis.Connection.TLSSkipVerify != nil && *rb.Spec.Redis.Connection.TLSSkipVerify {
98110
tlsSkipVerifyDefault := "true"
99-
if rb.Spec.Redis.Connection.CACertificate != nil {
111+
// TODO this should be moved to webhook
112+
if rb.Spec.Redis.Connection.TLSCACertificate != nil {
100113
tlsSkipVerifyDefault = "false"
101114
}
102115
resources.ContainerAddEnvFromValue("REDIS_TLS_SKIP_VERIFY", tlsSkipVerifyDefault)(c)

0 commit comments

Comments
 (0)