Long title but a relatively quick TIL. In a helm chart, when specifying a storageClass in your templates, it is important that if the user does not set a storageClass that you do not output storageClass in your template for a persistent volume. That is say that this:
Is not equivalent to this:
When installed the first time, both will result in Kubernetes selecting your default storage class. When this happens, your resource is actually updated to reflect the selected storageClass in the API. When you apply the same file again during an upgrade, an empty storageClassName will be seen as a change from the default storage to “”, which is not what you want. Instead, you should not send storageClassName at all if the user did not specify one.
TIL that you can tell systemd to run any ExecStartPre and ExecStopPost scripts as root instead of the user the service is supposed to run under.
At the same time we can touch on how to create an override for a service. In my case, I wanted to override how Redis is started on a system to ensure hugepage was set correctly, per their documentation. Creating an override for a service is super simple:
systemctl edit <service>
In my case this means:
systemctl edit redis
Since I know that the name of the service I want to edit is redis. From here, I am presented with my favorite editor where I can input the following:
Here I am defining two things. First, I want the permissions to only apply to the ExecStart command, not the others. Next, I am specifying an ExecStartPre that calls a script. This script is simply outputting:
/bin/echo never > /sys/kernel/mm/transparent_hugepage/enabled
Once complete, save out the file and restart your service. Your changes will now take affect.
If you are running a newer release of systemd (231+) then you can use the following format as well: