How do I pass flags when starting a systemd service?
From here this can be done like so:
-
Create an arguments file say
/etc/.argconf
ARG1=-o ARG2=--verbose
-
And your .service file:
EnvironmentFile=/etc/.argconf ExecStart=/usr/bin/prog $ARG1 $ARG2
Another method from that same post is as seen below:
[Unit]
Description=Test passing multiple arguments
[Service]
Environment="SCRIPT_ARGS=%I"
ExecStart=/tmp/test.py $SCRIPT_ARGS
And the name of the file has to be [email protected]
take note of the @
as this is required when passing arguments in this fashion to a service. You then run that service like so:
sudo systemctl start myservice@"arg1 arg2 arg3".service
Just like how every implementation/flavor/distribution of Linux is a little different.
I learned that every implementation of Kuberntes is a little different.
And that there's different ways to implement systemd.
With all that variability I believe the best way to do this seems to be:
To use the find command to find where *.service is located
WorkerNodeBash# find / -name "*.service" | grep -i "kube"
WorkerNodeBash# nano /etc/systemd/system/kubelet.service
[Unit]
Description=Kubernetes Kubelet
Documentation=https://github.com/kubernetes/kubernetes
After=containerd.service
Requires=containerd.service
[Service]
ExecStart=/usr/local/bin/kubelet \
--config=/var/lib/kubelet/kubelet-config.yaml \
--container-runtime=remote \
--container-runtime-endpoint=unix:///var/run/containerd/containerd.sock \
--image-pull-progress-deadline=2m \
--kubeconfig=/var/lib/kubelet/kubeconfig \
--network-plugin=cni \
--register-node=true \
--pod-manifest-path=/etc/kubernetes/manifests \
--v=2
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
(The above comes from Kubernetes the hard way implementation, I've also done kubeadm and looked in this same file and saw no args, but thanks to learning how to use the find command I was able to search:
WorkerNodeBash# find / -type f -name "*.yaml" | grep "kube"
And I found a config file that mentioned
KUBELET_EXTRA_ARGS=, and pass them in there.