Reputation: 101
use 'EOF',it can keep indenting, but it can't explain variables
[root@master ~]# registry=10.105.100.4/library
[root@master ~]# cat > /etc/sysconfig/kubelet << 'EOF'
> KUBELET_EXTRA_ARGS=--pod-infra-container-image=${registry}/pause:3.1 \
> --runtime-cgroups=/systemd/system.slice --kubelet-cgroups=/systemd/system.slice \
> --feature-gates=LocalStorageCapacityIsolation=true \
> --kube-reserved-cgroup=/kubepods.slice --kube-reserved=cpu=500m,memory=500Mi,ephemeral-storage=1Gi \
> --system-reserved-cgroup=/system.slice --system-reserved=cpu=500m,memory=500Mi,ephemeral-storage=1Gi \
> --eviction-hard=memory.available<500Mi,nodefs.available<10% \
> --max-pods=250
> EOF
[root@master ~]# cat /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS=--pod-infra-container-image=${registry}/pause:3.1 \
--runtime-cgroups=/systemd/system.slice --kubelet-cgroups=/systemd/system.slice \
--feature-gates=LocalStorageCapacityIsolation=true \
--kube-reserved-cgroup=/kubepods.slice --kube-reserved=cpu=500m,memory=500Mi,ephemeral-storage=1Gi \
--system-reserved-cgroup=/system.slice --system-reserved=cpu=500m,memory=500Mi,ephemeral-storage=1Gi \
--eviction-hard=memory.available<500Mi,nodefs.available<10% \
--max-pods=250
just use EOF,It can interpret variables, but it can't keep indenting,
[root@master ~]# registry=10.105.100.4/library
[root@master ~]# cat > /etc/sysconfig/kubelet << EOF
> KUBELET_EXTRA_ARGS=--pod-infra-container-image=${registry}/pause:3.1 \
> --runtime-cgroups=/systemd/system.slice --kubelet-cgroups=/systemd/system.slice \
> --feature-gates=LocalStorageCapacityIsolation=true \
> --kube-reserved-cgroup=/kubepods.slice --kube-reserved=cpu=500m,memory=500Mi,ephemeral-storage=1Gi \
> --system-reserved-cgroup=/system.slice --system-reserved=cpu=500m,memory=500Mi,ephemeral-storage=1Gi \
> --eviction-hard=memory.available<500Mi,nodefs.available<10% \
> --max-pods=250
> EOF
[root@master ~]# cat /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS=--pod-infra-container-image=10.105.100.4/library/pause:3.1 --runtime-cgroups=/systemd/system.slice --kubelet-cgroups=/systemd/system.slice --feature-gates=LocalStorageCapacityIsolation=true --kube-reserved-cgroup=/kubepods.slice --kube-reserved=cpu=500m,memory=500Mi,ephemeral-storage=1Gi --system-reserved-cgroup=/system.slice --system-reserved=cpu=500m,memory=500Mi,ephemeral-storage=1Gi --eviction-hard=memory.available<500Mi,nodefs.available<10% --max-pods=250
[root@master ~]#
Is there any way for both to take effect at the same time?
Upvotes: 0
Views: 136
Reputation: 52539
You have to escape the backslashes at the end of the lines (Tested with bash and zsh; I assume other shells are similar):
$ cat > foo.txt <<EOF
line 1 \\
line 2
EOF
$ cat foo.txt
line 1 \
line 2
Upvotes: 1