Call kubectl from a systemd service

Hi, i’d like to write a script that gets called every time we shutdown a VM running kubernetes.

I’ve saved it and made it executable in the /lib/systemd/system-shutdown/
It worked sometime, then stopped being called.
Instead I decided to try a systemd service that gets called on shutdown.
Any idea what might be wrong? I get this error:

E0625 17:04:23.797832 600376 memcache.go:265] couldn’t get current server API group list: Get “http://localhost:8080/api?timeout=32s”: dial tcp 127.0.0.1:8080: connect: connection refused

This is the service:

[Unit]
Description=Pre-Shutdown Processes
DefaultDependencies=no
Before=shutdown.target

[Service]
Type=oneshot
Environment=“KUBECONFIG=/home/myuser/.kube/config”
ExecStart=/home/rgadmin/drain.sh

[Install]
WantedBy=halt.target reboot.target shutdown.target

Cluster information:

1.29.4

Kubernetes version:
Cloud being used: (put bare-metal if not on a public cloud)
Installation method:
Host OS:
CNI and version:
CRI and version:

You can format your yaml by highlighting it and pressing Ctrl-Shift-C, it will make your output easier to read.

I got that error just starting it manually, not necessarily waiting for a shutdown. The script works when started from my home directory