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

Commit 9d026b7

Browse files
author
odacremolbap
committed
use unique stream per broker instance
1 parent f6ea13d commit 9d026b7

File tree

4 files changed

+193
-6
lines changed

4 files changed

+193
-6
lines changed

config/300-redisbroker.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,61 @@ spec:
4646
spec:
4747
description: RedisBrokerSpec defines the desired state of RedisBroker
4848
type: object
49+
properties:
50+
redis:
51+
description: Redis options.
52+
type: object
53+
properties:
54+
connection:
55+
description: Redis connection.
56+
type: object
57+
properties:
58+
url:
59+
description: URL of the Redis instance.
60+
type: string
61+
format: url
62+
pattern: ^https?:\/\/.+$
63+
username:
64+
description: Redis username.
65+
type: object
66+
properties:
67+
secretKeyRef:
68+
description: A reference to a Kubernetes Secret object.
69+
type: object
70+
properties:
71+
name:
72+
type: string
73+
key:
74+
type: string
75+
password:
76+
description: Redis password.
77+
type: object
78+
properties:
79+
secretKeyRef:
80+
description: A reference to a Kubernetes Secret object.
81+
type: object
82+
properties:
83+
name:
84+
type: string
85+
key:
86+
type: string
87+
required:
88+
- url
89+
90+
stream:
91+
description: Redis stream to be used by the broker.
92+
type: string
93+
streamMaxLen:
94+
description: Maximum number of items (approximate) the Redis stream can host.
95+
type: integer
96+
97+
broker:
98+
description: Broker options.
99+
type: object
100+
properties:
101+
port:
102+
description: Broker HTTP port.
103+
type: integer
49104
status:
50105
description: Status represents the current state of the Broker. This data may be out of date.
51106
type: object

pkg/apis/eventing/v1alpha1/deepcopy_generated.go

Lines changed: 98 additions & 3 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: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
package v1alpha1
55

66
import (
7+
corev1 "k8s.io/api/core/v1"
78
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
89
"k8s.io/apimachinery/pkg/runtime"
9-
10+
"knative.dev/pkg/apis"
1011
duckv1 "knative.dev/pkg/apis/duck/v1"
1112
"knative.dev/pkg/kmeta"
1213
)
@@ -43,7 +44,40 @@ var (
4344
_ duckv1.KRShaped = (*RedisBroker)(nil)
4445
)
4546

47+
type RedisConnection struct {
48+
// Redis URL.
49+
URL apis.URL `json:"url"`
50+
// Redis username.
51+
Username SecretValueFromSource `json:"username,omitempty"`
52+
// Redis password.
53+
Password SecretValueFromSource `json:"password,omitempty"`
54+
}
55+
56+
type Redis struct {
57+
// Redis connection data.
58+
Connection RedisConnection `json:"connection,omitempty"`
59+
60+
// Stream name used by the broker.
61+
Stream *string `json:"stream,omitempty"`
62+
63+
// Maximum number of items the stream can host.
64+
StreamMaxLen *int `json:"streamMaxLen,omitempty"`
65+
}
66+
67+
// SecretValueFromSource represents the source of a secret value
68+
type SecretValueFromSource struct {
69+
// The Secret key to select from.
70+
SecretKeyRef *corev1.SecretKeySelector `json:"secretKeyRef,omitempty"`
71+
}
72+
73+
type Broker struct {
74+
Port *int `json:"port,omitempty"`
75+
}
76+
4677
type RedisBrokerSpec struct {
78+
Redis *Redis `json:"redis,omitempty"`
79+
80+
Broker Broker `json:"broker,omitempty"`
4781
}
4882

4983
// RedisBrokerStatus represents the current state of a Redis broker.

pkg/reconciler/redisbroker/reconcile_broker.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
)
2727

2828
const (
29-
configSecretFile = "config"
29+
configSecretFile = "broker.config"
3030
configSecretPath = "/opt/broker"
3131

3232
brokerResourceSuffix = "redisbroker-broker"
@@ -84,7 +84,10 @@ func buildBrokerDeployment(rb *eventingv1alpha1.RedisBroker, redis *corev1.Servi
8484
resources.PodSpecAddVolume(v),
8585
resources.PodSpecAddContainer(
8686
resources.NewContainer("broker", image,
87-
resources.ContainerAddArgs("start --redis.address "+redisService+" --broker-config-path "+configMountedPath),
87+
resources.ContainerAddArgs("start"+
88+
" --redis.address "+redisService+
89+
" --broker-config-path "+configMountedPath+
90+
" --redis.stream "+rb.Namespace+"."+rb.Name),
8891
resources.ContainerAddVolumeMount(vm),
8992
),
9093
),

0 commit comments

Comments
 (0)