-
Notifications
You must be signed in to change notification settings - Fork 885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: add log rotation and log shipping sidecar examples #142
Comments
Are there any examples of how to setup these sidecars? I'm running into a lot of trouble trying to get this working correctly with the number of security bits enabled that make most off the shelf sidecar containers just break because they all assume they can run as root. |
Have you found any workaround for this ..?
|
I ended up writing a custom container with logrotate & a go based cron scheduler. Due to the security settings on Vault most OSS log rotate containers just didn't work and I wish I had just started with something custom. |
I know reviving an old issue is kind of annoying. But this is the best fitting place right now as its the first search hit for the exact issue.
I took this as inspiration to update this old issue with a solution for the problem at hand: The values for the most recent helm charts (v0.20.1) look something like this: vault:
server:
# HUP signal for logrotate
shareProcessNamespace: true
# Add the lograte config from a config map
volumes:
- name: logrotate-config
configMap:
name: logrotate-config
# And finally the container
extraContainers:
- name: auditlog-rotator
image: vault-logrotate:latest
imagePullPolicy: Always
env:
- name: CRONTAB
value: "*/5 * * * *"
volumeMounts:
- mountPath: /etc/logrotate.conf
name: logrotate-config
subPath: logrotate.conf
readOnly: true
- mountPath: /vault/audit
name: audit The logrotate.conf ConfigMap can look something like this: apiVersion: v1
kind: ConfigMap
metadata:
name: logrotate-config
data:
logrotate.conf: |
/vault/audit/vault.log {
copytruncate
size 100M
missingok
nocompress
postrotate
pkill -HUP vault
endscript
}
|
Adding another example for a scenario that is using kubernetes, raft with integrated storage and persistent volumes that are ReadWriteOnce. DockerfileThere is an issue with Alpine's index for edge/community where the supercronic package is not included. In addition, it would be necessary to modify the /etc/apk/repositories file in order to pull the package so I choose to copy it in. You made need to change the arch type to match your environment.
run.sh
docker-entrypoint.shI pulled the latest version and then added one line for starting supercronic using run.sh.
logrotate.conf
|
If anyone decides to use it - keep in mind that dockerfile is incorrectly built, rename the go binary, pkill/pgrep will point at self and kill itself causing interrupts. This script also does not respect graceful shutdowns. Subscribe to system calls for |
Thank you so much for the discussions! I made a step-by-step tutorial based on the comment #142 (comment). |
Add an example to the documentation that sets up Vault Helm to include a sidecar container that rotates Vault audit logs to satisfy this issue: #109.
This would use
server.extraContainers
to add in any other containers we may need.References:
The text was updated successfully, but these errors were encountered: