SSHを介してリモートコンピュータに接続し、一連のコマンドを実行するbashスクリプトがあります。
外部スクリプトのheredocが正しくソートされていないようで、エラーが発生し続けます。
-bash: line 49: warning: here-document at line 6 delimited by end-of-file (wanted `MOD')
スクリプトは次のとおりです。
ssh -i "$master_private_key" "$master_username@$master_public_ip" << EOF
# disable swap
sudo swapoff -a
sudo sed -i '/swap/ s/^/#/' /etc/fstab
# setup the bridge for IPV4
cat <<- MOD | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
MOD
sudo modprobe overlay
sudo modprobe br_netfilter
# sysctl params required by setup, params persist across reboots
cat <<- MOD | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.ipv4.ip_forward = 1
MOD
# Apply sysclt parameters without reboot
sudo sysctl --system
sudo apt-get update && apt install docker.io -y
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
sudo mkdir /etc/apt/keyrings
sudo curl -fsSLo /etc/apt/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl
# initialize kubeadm on master
kubeadm init --pod-network-cidir=192.168.0.0/16 --ignore-preflight-errors=all
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
# install calico SDN
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/tigera-operator.yaml
curl https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/custom-resources.yaml -O
kubectl create -f custom-resources.yaml
# Get the join command
$JOIN_COMMAND=$(kubeadm token create --print-join-command)
export $JOIN_COMMAND
EOF
誰かがこれを指摘できることを願っています。