Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion utilities/collectl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ imagestream.image.openshift.io/collectl created

Then add the entrypoint as a `configMap`:
```bash
$ oc create configmap collectl-entrypoint --from-file entrypoint.sh
$ oc create -f configmap-entrypoint.yaml
configmap/collectl-entrypoint created
```

Expand Down
63 changes: 63 additions & 0 deletions utilities/collectl/configmap-entrypoint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: collectl-entrypoint
namespace: openshift4-debug
data:
entrypoint.sh: |-
#!/bin/bash

trap signal EXIT
trap signal SIGINT

function signal()
{
echo "Exited due to signal recieved."
exit
}

function main()
{
echo "Found hostname:"
echo $(/usr/bin/hostname)

echo "Checking collectl version:"
/usr/bin/collectl -v

echo "Current configuration:"
CONFIG=$(egrep -v "\#|^$" /etc/collectl.conf)
echo "$CONFIG"

echo "Ensuring /var/log/collectl exists..."
if [ ! -d /var/log/collectl ]
then
mkdir /var/log/collectl
fi

echo "Checking if collectl is already running on this node..."
PID=$(pgrep -f '/usr/bin/perl -w /usr/bin/collectl')
if [ ! -z "$PID" ]
then
echo "Host process $PID is already running collectl, exiting."
exit
fi

echo "Starting collectl process..."
/usr/bin/collectl -D /etc/collectl.conf
PID=$(pgrep -f '/usr/bin/perl -w /usr/bin/collectl')

echo "Monitoring PID $PID for exit..."
while true
do
PID=$(pgrep -f '/usr/bin/perl -w /usr/bin/collectl')
if [ $? -ne 0 ]
then
echo "Could no longer find PID $PID, exiting..."
exit
fi

sleep 10
done
}

main
24 changes: 24 additions & 0 deletions utilities/logrotate/buildconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
name: logrotate
namespace: openshift4-debug
labels:
app: openshift4-debug
spec:
output:
to:
kind: ImageStreamTag
name: logrotate:latest
source:
dockerfile: |
FROM registry.access.redhat.com/ubi8
RUN dnf install logrotate -y && \
dnf clean all
CMD logrotate /etc/logrotate.conf
type: Dockerfile
strategy:
dockerStrategy: {}
type: Docker
triggers:
- type: ConfigChange
13 changes: 13 additions & 0 deletions utilities/logrotate/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: logrotate-config
namespace: openshift4-debug
data:
logrotate.conf: |-
/var/log/collectl/*raw.gz {
daily
missingok
rotate 14
maxage 14
}
36 changes: 36 additions & 0 deletions utilities/logrotate/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: app-logrotate
spec:
schedule: "* * */2 * *"
concurrencyPolicy: Replace
jobTemplate:
spec:
template:
spec:
containers:
- name: logrotate
image: image-registry.openshift-image-registry.svc:5000/openshift4-debug/logrotate
volumeMounts:
- name: logrotate-conf
subPath: logrotate.conf
mountPath: /etc/logrotate.conf
- name: logs
mountPath: /var/log/
securityContext:
runAsUser: 0
privileged: true
nodeSelector:
collectl: "true"
restartPolicy: Never
volumes:
- name: logrotate-conf
configMap:
name: logrotate-config
- name: logs
hostPath:
path: /var/log
type: Directory
serviceAccount: openshift4-debug
serviceAccountName: openshift4-debug
7 changes: 7 additions & 0 deletions utilities/logrotate/imagestream.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
name: logrotate
namespace: openshift4-debug
labels:
app: openshift4-debug