Welcome to the Linux Foundation Forum!

Exercise 5.5: Enabling API Server Auditing: mount audit.log file as FileOrCreate

Hi,

In "Exercise 5.5: Enabling API Server Auditing" I can see that it's suggested to mount audit.log file as FileOrCreate.

  1. - --audit-log-maxbackup=2
  2. - --audit-log-maxsize=50
  3. - --audit-log-path=/var/log/audit.log
  4. ...
  5. - hostPath:
  6. path: /var/log/audit.log
  7. type: FileOrCreate
  8. name: audit-log

Does it make any sense? Once log file reached the size limit it remains unchanged. And in kube-apiserver log appear messages like

  1. E0120 09:05:09.242149 1 metrics.go:110] Error in audit plugin 'log' affecting 1 audit events: can't rename log file: rename /var/log/audit.log /var/log/audit-2025-01-20T09-05-09.242.log: device or resource busy

Perhaps it makes more sense to mount host directory rather than file to let kube-apiserver roll the log

  1. volumeMounts:
  2. - mountPath: /var/log
  3. name: audit-log
  4. readOnly: false
  5. ...
  6. volumes:
  7. - hostPath:
  8. path: /var/log
  9. type: Directory
  10. name: audit-log

Regards,
Dmytro

Best Answer

  • Posts: 2,434
    Answer ✓

    Hi @dmsheiko,

    Agreed, that once a log limit is set, the logging mechanism stops recording new logs - so it does not make any sense.
    However, in the training guide there is a statement acting as a clear warning about the audit log size. In addition, on the same page you may find described flags defining the audit file size, files count, files age, collectively defining the log file rotation mechanism. Thus the integrated audit file rotation mechanism can be closely managed by declaring these specific options.

    Regards,
    -Chris

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training