Search code examples
linuxkubernetesopenshiftrhel

configure file system in each node using kubernetes daemonset


I was trying to increase core dump retention and node disk capacity using kubernetes deamonset. I can increase the retention period like this using a bash script but how do I do it using daemonset.

echo "/var/lib/systemd/coredump 0755 root root 10d" > /etc/tmpfiles.d/<filename>.conf.

In the same daemonset I want to increase the MaxUse field of file /etc/systemd/coredump.conf to 20%. Is it possible to do it in the same daemonset? I know this can be done using a cronjob but I don't want to use a cronjob. Hopefully the given information helps. Thanks for the help.


Solution

  • This is what I did to address this issue :

    1. Create a config map which contains values for both retention period and MaxUse like this :
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: core-cm
    data:
      core.retention-period: Xd
      core.max-volume-use: XG
    
    1. Pass these values in cm as an ENV variable inside the container of the daemonset and mount volume for the directories which needs to be changed
    env:
      - name: RETENTION_PERIOD
        valueFrom:
          configMapKeyRef:
            name: core-cm
            key: core.retention-period
      - name: MAX_VOLUME_USE
        valueFrom:
          configMapKeyRef:
            name: core-cm
            key: core.max-volume-use
    
    1. Write a script that will run inside the above mentioned container.

    This configured all the nodes with the changes that I needed.