pnune
1
Hello All,
Just trying to log container logs to a particular file by using below sample nginx pod snippet.
Below is the snippet of code but it is failing to create. Can anyone help me out where it is failing?
apiVersion: v1
kind: Pod
metadata:
name: legacy-app
spec:
containers:
- name: count
image: busybox
args: [/bin/sh, -c, ‘tail -n+1 -f /var/log/legacy-app.log’]
volumeMounts:
- name: varlog
mountPath: /var/log
volumes:
- name: varlog
hostPath:
Ensure the file directory is created.
path: /var/log
type: DirectoryOrCreate
apiVersion: v1
kind: Pod
metadata:
name: podname
spec:
containers:
- name: count
image: busybox
args:
- /bin/sh
- -c
-
i=0;
while true;
do
echo “$(date) INFO $i” >> /var/log/legacy-ap.log;
i=$((i+1));
sleep 1;
done
volumeMounts:
- name: logs
mountPath: /var/log
- name: count-log-1
image: busybox
args: [/bin/sh, -c, ‘tail -n+1 -f /var/log/legacy-ap.log’]
volumeMounts:
- name: logs
mountPath: /var/log
volumes:
- name: logs
emptyDir: {}