Skip to content

Commit

Permalink
Merge pull request #101 from GluuFederation/docs-logs-delete
Browse files Browse the repository at this point in the history
docs: automatic logs deletion in CN
  • Loading branch information
moabu authored Feb 4, 2025
2 parents 79cd501 + e126887 commit 23f9ddc
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs-gluu-server-prod/docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ copyright: Copyright © 2022, Gluu, Inc.

# Repository
docs_dir: source
repo_name: GluuFederation/docs-gluu-server-prod
repo_url: https://github.com/GluuFederation/docs-gluu-server-prod/
repo_name: GitHub
repo_url: https://github.com/GluuFederation/gluu4/tree/4.5/docs-gluu-server-prod/
edit_uri: edit/4.5/docs/source

# Configuration
Expand Down
41 changes: 41 additions & 0 deletions docs-gluu-server-prod/docs/source/operation/logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,47 @@ Remember the initial `GET` request will hit the Apache server first, and then be
## Clearing Logs
### VM setup
The "clear-logs" feature can be used to clear all log files with the extension `.log`, including system logs. Clear-logs can be helpful during troubleshooting, as well as research and development. We discourage its use in production systems if the logs are not backed-up. More features are planned. Please consider this as work in progress.
`service gluu-server clear-logs`
### CN setup
This `CronJob` deletes log files older than 15 days.
This showcases deleting old log files in `oxauth`.
You can adjust it as needed.
```yaml
apiVersion: batch/v1
kind: CronJob
metadata:
name: log-cleanup-cronjob
namespace: gluu # We assume the namespace is "gluu". Adjust as needed in the whole cronJob as needed.
spec:
schedule: "0 0 * * *" # Run this at midnight daily (adjust as needed)
jobTemplate:
spec:
template:
spec:
containers:
- name: log-cleanup
image: bitnami/kubectl:latest # Using the kubectl image
command:
- /bin/sh
- -c
- |
# Get the latest oxauth pod name dynamically using kubectl
POD_NAME=$(kubectl get pod -l app=oxauth -n gluu -o jsonpath='{.items[0].metadata.name}')
# Run cleanup on the latest oxauth pod
kubectl exec -it $POD_NAME -n gluu -- find /opt/gluu/jetty/oxauth/logs/ -type f -name "*.log" -mtime +15 -delete
env:
- name: KUBERNETES_SERVICE_HOST
value: "kubernetes.default.svc"
- name: KUBERNETES_SERVICE_PORT
value: "443"
restartPolicy: OnFailure
```

0 comments on commit 23f9ddc

Please sign in to comment.