Skip to content

Instantly share code, notes, and snippets.

@yukirii
Last active December 15, 2019 14:38
Show Gist options
  • Save yukirii/bc0ab34b34b16f636582e6768809c25b to your computer and use it in GitHub Desktop.
Save yukirii/bc0ab34b34b16f636582e6768809c25b to your computer and use it in GitHub Desktop.
#!/bin/sh
## Wait other apt process
while fuser /var/lib/apt/lists/lock >/dev/null 2>&1 ; do
echo "Wait other apt process..."
sleep 5
done
## Install required packages
apt-get update && apt-get install -y apt-transport-https \
curl \
ca-certificates \
gnupg-agent \
software-properties-common \
cloud-init
## Install Docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update && apt-get install -y docker-ce docker-ce-cli containerd.io
## Install Kubernetes packages
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update && apt-get install -y kubelet=1.17.0-00 kubeadm=1.17.0-00 kubectl=1.17.0-00
apt-mark hold kubelet kubeadm kubectl
## Run cloud-init
cloud-init init --local
cloud-init init
cloud-init modules --mode=config
cloud-init modules --mode=final
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment