1.如果不关闭swap,就会在kubeadm初始化Kubernetes的时候报错,如下图:
[ERROR Swap]: running with swap on is not supported. Please disable swap
用ansible批量执行任务:
$ ansible -i inventory/inventory.cfg all -a "swapoff -a"
$ ansible -i inventory/inventory.cfg all -a "sudo sed -i '/ swap / s/^(.*)$/#1/g' /etc/fstab"
$ ansible -i inventory/inventory.cfg all -a "free -m"
cat a.txt
abc haha
注释掉第一行
sed -i '/haha/ s$^(.*)$#1$g' a.txt