diff --git a/controllers/fluent_controller_finalizer.go b/controllers/fluent_controller_finalizer.go index 5c427f006..e07f8a810 100644 --- a/controllers/fluent_controller_finalizer.go +++ b/controllers/fluent_controller_finalizer.go @@ -143,8 +143,20 @@ func (r *FluentdReconciler) mutate(obj client.Object, fd *fluentdv1alpha1.Fluent expected := operator.MakeStatefulSet(*fd) return func() error { + // Preserve the kubectl.kubernetes.io/restartedAt annotation + restartedAt := o.Spec.Template.Annotations["kubectl.kubernetes.io/restartedAt"] + o.Labels = expected.Labels o.Spec = expected.Spec + + // Restore the kubectl.kubernetes.io/restartedAt annotation if it existed + if restartedAt != "" { + if o.Spec.Template.Annotations == nil { + o.Spec.Template.Annotations = make(map[string]string) + } + o.Spec.Template.Annotations["kubectl.kubernetes.io/restartedAt"] = restartedAt + } + if err := ctrl.SetControllerReference(fd, o, r.Scheme); err != nil { return err } @@ -153,8 +165,20 @@ func (r *FluentdReconciler) mutate(obj client.Object, fd *fluentdv1alpha1.Fluent case *appsv1.DaemonSet: expected := operator.MakeFluentdDaemonSet(*fd) return func() error { + // Preserve the kubectl.kubernetes.io/restartedAt annotation + restartedAt := o.Spec.Template.Annotations["kubectl.kubernetes.io/restartedAt"] + o.Labels = expected.Labels o.Spec = expected.Spec + + // Restore the kubectl.kubernetes.io/restartedAt annotation if it existed + if restartedAt != "" { + if o.Spec.Template.Annotations == nil { + o.Spec.Template.Annotations = make(map[string]string) + } + o.Spec.Template.Annotations["kubectl.kubernetes.io/restartedAt"] = restartedAt + } + if err := ctrl.SetControllerReference(fd, o, r.Scheme); err != nil { return err } diff --git a/controllers/fluentbit_controller.go b/controllers/fluentbit_controller.go index da4d3229b..afa485153 100644 --- a/controllers/fluentbit_controller.go +++ b/controllers/fluentbit_controller.go @@ -152,9 +152,21 @@ func (r *FluentBitReconciler) mutate(obj client.Object, fb *fluentbitv1alpha2.Fl expected := operator.MakeDaemonSet(*fb, logPath) return func() error { + // Preserve the kubectl.kubernetes.io/restartedAt annotation + restartedAt := o.Spec.Template.Annotations["kubectl.kubernetes.io/restartedAt"] + o.Labels = expected.Labels o.Annotations = expected.Annotations o.Spec = expected.Spec + + // Restore the kubectl.kubernetes.io/restartedAt annotation if it existed + if restartedAt != "" { + if o.Spec.Template.Annotations == nil { + o.Spec.Template.Annotations = make(map[string]string) + } + o.Spec.Template.Annotations["kubectl.kubernetes.io/restartedAt"] = restartedAt + } + if err := ctrl.SetControllerReference(fb, o, r.Scheme); err != nil { return err } diff --git a/docs/plugins/fluentbit/output/azure_log_analytics.md b/docs/plugins/fluentbit/output/azure_log_analytics.md index 355ec9fca..a0d031232 100644 --- a/docs/plugins/fluentbit/output/azure_log_analytics.md +++ b/docs/plugins/fluentbit/output/azure_log_analytics.md @@ -8,5 +8,6 @@ Azure Log Analytics is the Azure Log Analytics output plugin, allows you to inge | customerID | Customer ID or Workspace ID | *[plugins.Secret](../secret.md) | | sharedKey | Specify the primary or the secondary client authentication key | *[plugins.Secret](../secret.md) | | logType | Name of the event type. | string | +| logTypeKey | Set a record key that will populate 'logtype'. If the key is found, it will have precedence | string | | timeKey | Specify the name of the key where the timestamp is stored. | string | | timeGenerated | If set, overrides the timeKey value with the `time-generated-field` HTTP header value. | *bool |