-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
csi: add log rotation for csi pod containers
1) Make the csi container logs persisted in a file 2) Add log rotation to rotate the log file 3) Provide api specs to configure the log rotate 4) Add a sidecar log collector container closes: #12809 Signed-off-by: parth-gr <partharora1010@gmail.com>
- Loading branch information
Showing
8 changed files
with
175 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
args: | ||
- | | ||
echo "Starting the csi-logrotate-sidecar" | ||
mkdir -p /var/lib/cephcsi/logrotate-config/{{ .CSILogFolder }}; | ||
echo '/var/lib/cephcsi/log/{{ .CSILogFolder }}/*.log { | ||
{{ .CSILogRotationPeriod }} | ||
missingok | ||
rotate 7 | ||
compress | ||
copytruncate | ||
notifempty | ||
}' > /var/lib/cephcsi/logrotate-config/{{ .CSILogFolder }}/csi; | ||
echo "File creation container completed"; | ||
LOG_ROTATE_CEPH_CSI_FILE=/var/lib/cephcsi/logrotate-config/{{ .CSILogFolder }}/csi | ||
LOG_MAX_SIZE={{ .CSILogRotationMaxSize }} | ||
if [ "$LOG_MAX_SIZE" != "0" ]; then | ||
sed --in-place "4i \ \ \ \ maxsize $LOG_MAX_SIZE" "$LOG_ROTATE_CEPH_CSI_FILE" | ||
fi | ||
while true; do | ||
logrotate --verbose "$LOG_ROTATE_CEPH_CSI_FILE" | ||
sleep 15m | ||
done | ||
command: | ||
- /bin/sh | ||
- -c | ||
image: { { .CSIPluginImage } } | ||
imagePullPolicy: IfNotPresent | ||
name: log-collector | ||
volumeMounts: | ||
- mountPath: /var/lib/cephcsi/logrotate-config/{{ .CSILogFolder }} | ||
name: csi-logs-logrotate | ||
- mountPath: /var/lib/cephcsi/log/{{ .CSILogFolder }} | ||
name: csi-log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.