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

Commit e8adf60

Browse files
committed
Adding CA Certificate support to redis broker
1 parent cc170ff commit e8adf60

File tree

5 files changed

+36
-2
lines changed

5 files changed

+36
-2
lines changed

config/300-redisbroker.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,23 @@ spec:
8787
type: string
8888
key:
8989
type: string
90+
caCertificate:
91+
description: Contains a CA Certificate used to connect to Redis.
92+
type: object
93+
properties:
94+
secretKeyRef:
95+
description: A reference to a Kubernetes Secret object.
96+
type: object
97+
properties:
98+
name:
99+
type: string
100+
key:
101+
type: string
90102
tlsEnabled:
91103
description: Use TLS enctrypted Redis connection.
92104
type: boolean
93105
tlsSkipVerify:
94-
description: Skip TLS certificate verification.
106+
description: Skip TLS certificate verification. If caCertificate is set, tlsSkipVerify will default to false.
95107
type: boolean
96108
oneOf:
97109
- required: [url]

docs/redis-broker.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ spec:
2525
secretKeyRef:
2626
name: <Kubernetes secret name>
2727
key: <Kubernetes secret key>
28+
caCertificate: <CA certificate used to connect to redis. Optional>
29+
secretKeyRef:
30+
name: <Kubernetes secret name>
31+
key: <Kubernetes secret key>
2832
tlsEnabled: <boolean that indicates if the Redis server is TLS protected. Optional, defaults to false>
2933
tlsSkipVerify: <boolean that skips verifying TLS certificates. Optional, defaults to false>
3034
stream: <Redis stream name. Optional, defaults to a combination of namespace and broker name>

pkg/apis/eventing/v1alpha1/deepcopy_generated.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/apis/eventing/v1alpha1/redisbroker_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ type RedisConnection struct {
5555
// Redis password.
5656
Password *SecretValueFromSource `json:"password,omitempty"`
5757

58+
// CA Certificate used to connect to Redis.
59+
CACertificate *SecretValueFromSource `json:"caCertificate,omitempty"`
60+
5861
// Use TLS enctrypted connection.
5962
TLSEnabled *bool `json:"tlsEnabled,omitempty"`
6063

pkg/reconciler/redisbroker/reconciler.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,12 +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 {
88+
resources.ContainerAddEnvVarFromSecret("REDIS_CA_CERTIFICATE",
89+
rb.Spec.Redis.Connection.CACertificate.SecretKeyRef.Name,
90+
rb.Spec.Redis.Connection.CACertificate.SecretKeyRef.Key)(c)
91+
}
92+
8793
if rb.Spec.Redis.Connection.TLSEnabled != nil && *rb.Spec.Redis.Connection.TLSEnabled {
8894
resources.ContainerAddEnvFromValue("REDIS_TLS_ENABLED", "true")(c)
8995
}
9096

9197
if rb.Spec.Redis.Connection.TLSSkipVerify != nil && *rb.Spec.Redis.Connection.TLSSkipVerify {
92-
resources.ContainerAddEnvFromValue("REDIS_TLS_SKIP_VERIFY", "true")(c)
98+
tlsSkipVerifyDefault := "true"
99+
if rb.Spec.Redis.Connection.CACertificate != nil {
100+
tlsSkipVerifyDefault = "false"
101+
}
102+
resources.ContainerAddEnvFromValue("REDIS_TLS_SKIP_VERIFY", tlsSkipVerifyDefault)(c)
93103
}
94104

95105
} else {

0 commit comments

Comments
 (0)