- sidecar container that collects stdout/log files to persistent storage
- Request a separate volume from WMCS to persist logs (so we don't run out of disk space and don't get disk space alerts :D)
- Logrotate config for the k8s hosts
- Document k3s setup
Description
Description
| Status | Subtype | Assigned | Task | ||
|---|---|---|---|---|---|
| Resolved | None | T370076 [Go Live] Move patchdemo.wmcloud.org to Kubernetes in the catalyst WMCS project | |||
| Resolved | SDunlap | T370078 Add logging for catalyst WMCS k8s |
Event Timeline
Comment Actions
Here's an update on my exploration thus far,
- we can change where k3s stores all of it's data including log data
- we can modify our exiting configuration in /etc/rancher/k3s/config.yaml
- this will wipe all data unless we stop the server, move the data, and restart it
- if we want them to be on separate volumes, the guidance seems to be to move the logs manually and symlink [data-dir]/agent/containerd/logs to another path on another volume
- we can modify our exiting configuration in /etc/rancher/k3s/config.yaml
- the kubernetes agent manages log rotation
- we can configure it to have larger log files (default 10mb) and more log files (default 5)
- this allows us to keep using kubectl get logs and we can also get earlier logs from the [data-dir]/agent/containerd/logs location
- we will still need sidecar containers to pull out logs from files
- essentially each sidecar container is responsible for tail-ing one log file to stdout
- this makes these logs get picked up by kubernets and writes them in the log directory on the host
- it also allows you to get these logs through the kubectl command
- e.g. if we had a sidecar container for patchdemo that tailed the apache access.log, patchdemo-access-log
- we could either do kubectl logs patchdemo and the access log would show up in the pod logs
- we can also get just those logs with kubectl logs patchdemo -c patchdemo-access-log to see just that log
- we can also go to [data-dir]/agent/containerd/logs/patchdemo/patchdemo-access-log to see all the logs including rotated logs
- e.g. if we had a sidecar container for patchdemo that tailed the apache access.log, patchdemo-access-log
Comment Actions
- add 40GiB persistent volume, catalyst-k3s-data
- attach catalyst-k3s-data to k3s instance (/dev/sdb)
- add 40GiB persistent volume, catalyst-k3s-logs
- attach catalyst-k3s-logs to k3s instance (/dev/sdc)
- mkdir /mnt/k3s-data and /mnt/k3s-logs
- make the filesystems
- sudo mkfs.ext4 /dev/sdb
- sudo mkfs.ext4 /dev/sdc
- add to fstab
- UUID=913cb98f-a4fe-4320-803d-8d4e4aa4a0ec /mnt/k3s-data ext4 defaults 0 2
- UUID=36f911a5-db56-4d92-9880-17bb8d2988cc /mnt/k3s-logs ext4 defaults 0 2
- stop the k3s server
- sudo systemctl stop k3s
- move the data dir
- sudo mv /var/lib/rancher/k3s /mnt/k3s-data/
- symlink the data dir
- sudo ln -s /mnt/k3s-data/k3s /var/lib/rancher/k3s
- move the logs dir
- sudo mv /var/log/pods /mnt/k3s-logs/pods
- symlink the logs dir
- sudo ln -s /mnt/k3s-logs/pods /var/log/pods
- restart k3s
- sudo systemctl start k3s
Comment Actions
kindrobot opened https://gitlab.wikimedia.org/repos/qte/catalyst/patchdemo/-/merge_requests/16
Adds sidecar containers for log collection
Comment Actions
kindrobot merged https://gitlab.wikimedia.org/repos/qte/catalyst/patchdemo/-/merge_requests/16
Adds sidecar containers for log collection