We are trying to add docker logging options to our kubernetes deployments for log rolling e.g --log-opt max-size=10m
For example if we ran something like this directly using docker
docker run -it --log-opt max-size=10m --log-opt max-file=2 image-name
We can use docker inspect to see those options added to the LogConfig e.g
"LogConfig": {
"Type": "json-file",
"Config": {
"max-file": "2",
"max-size": "10m"
}
},
Here is what we have defined in our deployment:
containers:
- image: ourlocalrepo/deployments/our_pod:latest
command:
- java
- -Djava.security.egd=file:/dev/./urandom
- -Dlog4j.configurationFile=/etc/logs-config/log4j2.xml
- -Xms128m
- -Xmx256m
- -jar
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
imagePullPolicy: Always
name: "our_pod"
ports:
- containerPort: 80
protocol: TCP
args:
- "--log-opt max-size=10m"
- "--log-opt max-file=2"
But when this deployment is run and the pod comes up on a node i can use docker inspect and see that these args are added to Cmd:
"Cmd": [
"--log-opt max-size=10m",
"--log-opt max-file=2"
],
Instead of the LogConfig section as they should be - it still looks like this :
"LogConfig": {
"Type": "json-file",
"Config": {}
},
Can anyone point me the right direction to get the kubernetes deployment to add these log options?
thanks!!
I don't know, though, how to change those options for the docker
daemon. Probably the kubelet might be involved, but never changed
those myself in kubernetes.