Skip to content

Commit b219783

Browse files
committed
preserve restartedAt annotation
Signed-off-by: juicer <[email protected]>
1 parent bc8a756 commit b219783

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

controllers/fluent_controller_finalizer.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,20 @@ func (r *FluentdReconciler) mutate(obj client.Object, fd *fluentdv1alpha1.Fluent
143143
expected := operator.MakeStatefulSet(*fd)
144144

145145
return func() error {
146+
// Preserve the kubectl.kubernetes.io/restartedAt annotation
147+
restartedAt := o.Spec.Template.Annotations["kubectl.kubernetes.io/restartedAt"]
148+
146149
o.Labels = expected.Labels
147150
o.Spec = expected.Spec
151+
152+
// Restore the kubectl.kubernetes.io/restartedAt annotation if it existed
153+
if restartedAt != "" {
154+
if o.Spec.Template.Annotations == nil {
155+
o.Spec.Template.Annotations = make(map[string]string)
156+
}
157+
o.Spec.Template.Annotations["kubectl.kubernetes.io/restartedAt"] = restartedAt
158+
}
159+
148160
if err := ctrl.SetControllerReference(fd, o, r.Scheme); err != nil {
149161
return err
150162
}
@@ -153,8 +165,20 @@ func (r *FluentdReconciler) mutate(obj client.Object, fd *fluentdv1alpha1.Fluent
153165
case *appsv1.DaemonSet:
154166
expected := operator.MakeFluentdDaemonSet(*fd)
155167
return func() error {
168+
// Preserve the kubectl.kubernetes.io/restartedAt annotation
169+
restartedAt := o.Spec.Template.Annotations["kubectl.kubernetes.io/restartedAt"]
170+
156171
o.Labels = expected.Labels
157172
o.Spec = expected.Spec
173+
174+
// Restore the kubectl.kubernetes.io/restartedAt annotation if it existed
175+
if restartedAt != "" {
176+
if o.Spec.Template.Annotations == nil {
177+
o.Spec.Template.Annotations = make(map[string]string)
178+
}
179+
o.Spec.Template.Annotations["kubectl.kubernetes.io/restartedAt"] = restartedAt
180+
}
181+
158182
if err := ctrl.SetControllerReference(fd, o, r.Scheme); err != nil {
159183
return err
160184
}

controllers/fluentbit_controller.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,21 @@ func (r *FluentBitReconciler) mutate(obj client.Object, fb *fluentbitv1alpha2.Fl
152152
expected := operator.MakeDaemonSet(*fb, logPath)
153153

154154
return func() error {
155+
// Preserve the kubectl.kubernetes.io/restartedAt annotation
156+
restartedAt := o.Spec.Template.Annotations["kubectl.kubernetes.io/restartedAt"]
157+
155158
o.Labels = expected.Labels
156159
o.Annotations = expected.Annotations
157160
o.Spec = expected.Spec
161+
162+
// Restore the kubectl.kubernetes.io/restartedAt annotation if it existed
163+
if restartedAt != "" {
164+
if o.Spec.Template.Annotations == nil {
165+
o.Spec.Template.Annotations = make(map[string]string)
166+
}
167+
o.Spec.Template.Annotations["kubectl.kubernetes.io/restartedAt"] = restartedAt
168+
}
169+
158170
if err := ctrl.SetControllerReference(fb, o, r.Scheme); err != nil {
159171
return err
160172
}

docs/plugins/fluentbit/output/azure_log_analytics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ Azure Log Analytics is the Azure Log Analytics output plugin, allows you to inge
88
| customerID | Customer ID or Workspace ID | *[plugins.Secret](../secret.md) |
99
| sharedKey | Specify the primary or the secondary client authentication key | *[plugins.Secret](../secret.md) |
1010
| logType | Name of the event type. | string |
11+
| logTypeKey | Set a record key that will populate 'logtype'. If the key is found, it will have precedence | string |
1112
| timeKey | Specify the name of the key where the timestamp is stored. | string |
1213
| timeGenerated | If set, overrides the timeKey value with the `time-generated-field` HTTP header value. | *bool |

0 commit comments

Comments
 (0)