@@ -22,11 +22,13 @@ import (
22
22
type transformerReconciler struct {
23
23
* reconcilers.Instance
24
24
deployment * appsv1.Deployment
25
+ cacheDeployment * appsv1.Deployment
25
26
promService * corev1.Service
26
27
hpa * ascv2.HorizontalPodAutoscaler
27
28
serviceAccount * corev1.ServiceAccount
28
29
staticConfigMap * corev1.ConfigMap
29
30
dynamicConfigMap * corev1.ConfigMap
31
+ cacheConfigMap * corev1.ConfigMap
30
32
roleBinding * rbacv1.ClusterRoleBinding
31
33
serviceMonitor * monitoringv1.ServiceMonitor
32
34
prometheusRule * monitoringv1.PrometheusRule
@@ -37,11 +39,13 @@ func newTransformerReconciler(cmn *reconcilers.Instance) *transformerReconciler
37
39
rec := transformerReconciler {
38
40
Instance : cmn ,
39
41
deployment : cmn .Managed .NewDeployment (name ),
42
+ cacheDeployment : cmn .Managed .NewDeployment (flpCacheName ),
40
43
promService : cmn .Managed .NewService (promServiceName (ConfKafkaTransformer )),
41
44
hpa : cmn .Managed .NewHPA (name ),
42
45
serviceAccount : cmn .Managed .NewServiceAccount (name ),
43
46
staticConfigMap : cmn .Managed .NewConfigMap (staticConfigMapName (ConfKafkaTransformer )),
44
47
dynamicConfigMap : cmn .Managed .NewConfigMap (dynamicConfigMapName (ConfKafkaTransformer )),
48
+ cacheConfigMap : cmn .Managed .NewConfigMap (flpCacheConfigMap ),
45
49
roleBinding : cmn .Managed .NewCRB (RoleBindingName (ConfKafkaTransformer )),
46
50
}
47
51
if cmn .AvailableAPIs .HasSvcMonitor () {
@@ -86,13 +90,13 @@ func (r *transformerReconciler) reconcile(ctx context.Context, desired *flowslat
86
90
if err != nil {
87
91
return err
88
92
}
93
+
94
+ // Main, static config map
89
95
newSCM , configDigest , err := builder .staticConfigMap ()
90
96
if err != nil {
91
97
return err
92
98
}
93
- annotations := map [string ]string {
94
- constants .PodConfigurationDigest : configDigest ,
95
- }
99
+ annotations := map [string ]string {constants .PodConfigurationDigest : configDigest }
96
100
if ! r .Managed .Exists (r .staticConfigMap ) {
97
101
if err := r .CreateOwned (ctx , newSCM ); err != nil {
98
102
return err
@@ -103,6 +107,23 @@ func (r *transformerReconciler) reconcile(ctx context.Context, desired *flowslat
103
107
}
104
108
}
105
109
110
+ // Cache config map
111
+ // TODO: factorize with main static CM code
112
+ newCCM , configDigest , err := builder .generic .cacheConfigMap ()
113
+ if err != nil {
114
+ return err
115
+ }
116
+ cacheAnnotations := map [string ]string {constants .PodConfigurationDigest : configDigest }
117
+ if ! r .Managed .Exists (r .cacheConfigMap ) {
118
+ if err := r .CreateOwned (ctx , newCCM ); err != nil {
119
+ return err
120
+ }
121
+ } else if ! equality .Semantic .DeepDerivative (newCCM .Data , r .cacheConfigMap .Data ) {
122
+ if err := r .UpdateIfOwned (ctx , r .cacheConfigMap , newCCM ); err != nil {
123
+ return err
124
+ }
125
+ }
126
+
106
127
if err := r .reconcileDynamicConfigMap (ctx , & builder ); err != nil {
107
128
return err
108
129
}
@@ -125,6 +146,7 @@ func (r *transformerReconciler) reconcile(ctx context.Context, desired *flowslat
125
146
}
126
147
127
148
// Watch for Kafka certificate if necessary; need to restart pods in case of cert rotation
149
+ // TODO: cacheAnnotations
128
150
if err = annotateKafkaCerts (ctx , r .Common , & desired .Spec .Kafka , "kafka" , annotations ); err != nil {
129
151
return err
130
152
}
@@ -137,7 +159,7 @@ func (r *transformerReconciler) reconcile(ctx context.Context, desired *flowslat
137
159
return err
138
160
}
139
161
140
- if err = r .reconcileDeployment (ctx , & desired .Spec .Processor , & builder , annotations ); err != nil {
162
+ if err = r .reconcileDeployment (ctx , & desired .Spec .Processor , & builder , annotations , cacheAnnotations ); err != nil {
141
163
return err
142
164
}
143
165
@@ -161,11 +183,11 @@ func (r *transformerReconciler) reconcileDynamicConfigMap(ctx context.Context, b
161
183
return nil
162
184
}
163
185
164
- func (r * transformerReconciler ) reconcileDeployment (ctx context.Context , desiredFLP * flowslatest.FlowCollectorFLP , builder * transfoBuilder , annotations map [string ]string ) error {
186
+ func (r * transformerReconciler ) reconcileDeployment (ctx context.Context , desiredFLP * flowslatest.FlowCollectorFLP , builder * transfoBuilder , annotations , cacheAnnots map [string ]string ) error {
165
187
report := helper .NewChangeReport ("FLP Deployment" )
166
188
defer report .LogIfNeeded (ctx )
167
189
168
- return reconcilers .ReconcileDeployment (
190
+ if err := reconcilers .ReconcileDeployment (
169
191
ctx ,
170
192
r .Instance ,
171
193
r .deployment ,
@@ -174,7 +196,10 @@ func (r *transformerReconciler) reconcileDeployment(ctx context.Context, desired
174
196
helper .PtrInt32 (desiredFLP .KafkaConsumerReplicas ),
175
197
& desiredFLP .KafkaConsumerAutoscaler ,
176
198
& report ,
177
- )
199
+ ); err != nil {
200
+ return err
201
+ }
202
+ return reconcilers .ReconcileDeployment (ctx , r .Instance , r .cacheDeployment , builder .cacheDeployment (cacheAnnots ), flpCacheName , 1 , nil , & report )
178
203
}
179
204
180
205
func (r * transformerReconciler ) reconcileHPA (ctx context.Context , desiredFLP * flowslatest.FlowCollectorFLP , builder * transfoBuilder ) error {
0 commit comments