Skip to content

Instantly share code, notes, and snippets.

@mickael-kerjean
Last active July 13, 2023 11:35
Show Gist options
  • Save mickael-kerjean/c69f0b17fcee16b0442b78c5a920628e to your computer and use it in GitHub Desktop.
Save mickael-kerjean/c69f0b17fcee16b0442b78c5a920628e to your computer and use it in GitHub Desktop.
kubernetes install script
#!/bin/bash
set -e
# run like this:
# /bin/bash -c "$(curl -fsSL https://xxx)"
VERSION=1.27
########################
# docker stuff: https://kubernetes.io/docs/setup/production-environment/container-runtimes/
apt-get -y install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository -y \
"deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update && apt-get install -y \
docker-ce \
docker-ce-cli
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
mkdir -p /etc/systemd/system/docker.service.d
systemctl daemon-reload
systemctl restart docker
########################
# cri-dockerd stuff: https://github.com/Mirantis/cri-dockerd
curl -LO "https://github.com/Mirantis/cri-dockerd/releases/download/v0.3.3/cri-dockerd-0.3.3.$(dpkg --print-architecture).tgz"
tar -zxf cri-dockerd-0.3.3.$(dpkg --print-architecture).tgz && cd cri-dockerd
curl -LO "https://raw.githubusercontent.com/Mirantis/cri-dockerd/master/packaging/systemd/cri-docker.socket"
curl -LO "https://raw.githubusercontent.com/Mirantis/cri-dockerd/master/packaging/systemd/cri-docker.service"
install -o root -g root -m 0755 cri-dockerd /usr/bin/cri-dockerd
install cri-docker.socket /etc/systemd/system/cri-docker.socket
install cri-docker.service /etc/systemd/system/cri-docker.service
systemctl daemon-reload
systemctl enable cri-docker.service
systemctl enable --now cri-docker.socket
########################
# kubernetes stuff: https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/
apt-get update && sudo apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubelet=$VERSION.* kubeadm=$VERSION.* kubectl=$VERSION.*
apt-mark hold kubelet kubeadm kubectl
########################
# Filesystem
apt-get install -y nfs-common sshfs
ssh-keygen -t rsa -q -f "$HOME/.ssh/id_rsa" -N ""
# ssh-copy-id root@116.203.202.210
# echo "sshfs#root@116.203.202.210:/mnt/ /mnt/ fuse defaults,user,allow_other,reconnect,delay_connect,ConnectTimeout=5,ServerAliveInterval=5,IdentityFile=/root/.ssh/id_rsa 0 0" >> /etc/fstab
@mickael-kerjean
Copy link
Author

mickael-kerjean commented Jun 17, 2023

FILESYSTEM

check sshfs is fine:

sshfs -o allow_other root@116.203.202.210:/mnt/ /mnt/
umount /mnt/

add this to /etc/fstab:

sshfs#root@116.203.202.210:/mnt/        /mnt/   fuse    defaults,user,allow_other,reconnect,delay_connect,ConnectTimeout=5,ServerAliveInterval=5,IdentityFile=/root/.ssh/id_rsa 0 0

and reboot

JOIN THE CLUSTER

kubeadm token create --print-join-command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment