K3s: Extra args with "<" are problematic for shell (kubelet eviction rules)

Created on 30 May 2019  Â·  4Comments  Â·  Source: k3s-io/k3s

Describe the bug
When trying to start k3s server with extra arguments that contains the "<" char, the shell interprets it as an stdin redirection which breaks the k3s startup.

To Reproduce
Run the following command:

curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION='v0.5.0' sh -s - --docker --no-deploy traefik --kubelet-arg='eviction-soft=memory.available<500Mi' --kubelet-arg='eviction-soft-grace-period=memory.available=1m' --kubelet-arg='eviction-hard=memory.available<100Mi' --kubelet-arg='eviction-soft=nodefs.available<15%' --kubelet-arg='eviction-soft-grace-period=nodefs.available=60m' --kubelet-arg='eviction-hard=nodefs.available<10%' --kubelet-arg='eviction-soft=nodefs.inodesFree<10%' --kubelet-arg='eviction-soft-grace-period=nodefs.inodesFree=120m' --kubelet-arg='eviction-hard=nodefs.inodesFree<5%'

Which will result in the following systemd file:

[Unit]
Description=Lightweight Kubernetes
Documentation=https://k3s.io
After=network-online.target

[Service]
Type=notify
EnvironmentFile=/etc/systemd/system/k3s.service.env
ExecStartPre=-/sbin/modprobe br_netfilter
ExecStartPre=-/sbin/modprobe overlay
ExecStart=/usr/local/bin/k3s server --docker --no-deploy traefik --kubelet-arg=eviction-soft=memory.available<500Mi --kubelet-arg=eviction-soft-grace-period=memory.available=1m --kubelet-arg=eviction-hard=memory.available<100Mi --kubelet-arg=eviction-soft=nodefs.available<15% --kubelet-arg=eviction-soft-grace-period=nodefs.available=60m --kubelet-arg=eviction-hard=nodefs.available<10% --kubelet-arg=eviction-soft=nodefs.inodesFree<10% --kubelet-arg=eviction-soft-grace-period=nodefs.inodesFree=120m --kubelet-arg=eviction-hard=nodefs.inodesFree<5%
KillMode=process
Delegate=yes
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
TimeoutStartSec=0
Restart=always

[Install]
WantedBy=multi-user.target

Running this command in shell will provide the following error:

# /usr/local/bin/k3s server --docker --no-deploy traefik --kubelet-arg=eviction-soft=memory.available<500Mi --kubelet-arg=eviction-soft-grace-period=memory.available=1m --kubelet-arg=eviction-hard=memory.available<100Mi --kubelet-arg=eviction-soft=nodefs.available<15% --kubelet-arg=eviction-soft-grace-period=nodefs.available=60m --kubelet-arg=eviction-hard=nodefs.available<10% --kubelet-arg=eviction-soft=nodefs.inodesFree<10% --kubelet-arg=eviction-soft-grace-period=nodefs.inodesFree=120m --kubelet-arg=eviction-hard=nodefs.inodesFree<5%
-su: 500Mi: No such file or directory

Expected behavior
The args should be encapsulated with quotes so the shell will not break if args uses special shell characters or operators.

kinbug statublocker

Most helpful comment

@digger18 a fix has been merged for this, please feel free to re-open if it does not solve the issue.

All 4 comments

@digger18 a fix has been merged for this, please feel free to re-open if it does not solve the issue.

The problem is also still.
image

We fixed it in the install script. If you're running k3s server from the command-line you are responsible for appropriately quoting the arguments yourself. Just put the flags with < or > in quotes.

@brandond thanks~.-kubelet-arg=eviction-hard=imagefs.available<1%,nodefs.available<1% --kubelet-arg=eviction-minimum-reclaim=imagefs.available=1%,nodefs.available=1% can be used in the install script.

Was this page helpful?
0 / 5 - 0 ratings