0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Kubernetes インストールのチートシート

Posted at

私がKubernetsをインストールする時に見てるチートシートを備忘録程度に残しておきます。
スクリプトっぽく記述してますが、それぞれ1行ずつ実行してもらう方が確実です。

######################################################
#             kubernetes install script              #
######################################################
sudo apt update

# docker install
# https://qiita.com/zembutsu/items/bedb18e1061303e217b8
cd ~
wget -O get-docker.sh https://get.docker.com
sudo sh ./get-docker.sh
sudo apt install docker-compose -y

# Docker driver
# https://qiita.com/rottneer/items/5dad5193b1577c4edc29
# この辺りはスクリプトに最適化してないので手動がおすすめ
sudo echo \
'{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}'  >/etc/docker/daemon.json
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo docker info | grep Cgroup

# kubeadm 
# この辺りはスクリプトに最適化してないので手動がおすすめ
sudo passwd root
su root

cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system

logout

# レガシーバイナリがインストールされていることを確認してください
sudo apt-get install -y iptables arptables ebtables

# レガシーバージョンに切り替えてください。
sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
sudo update-alternatives --set arptables /usr/sbin/arptables-legacy
sudo update-alternatives --set ebtables /usr/sbin/ebtables-legacy

# この辺りはスクリプトに最適化してないので手動がおすすめ

sudo 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
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
sudo apt-mark hold kubelet kubeadm kubectl

sudo apt update && sudo apt upgrade -y && sudo apt-get update && sudo apt-get upgrade -y

# Master node の場合はコチラ
<sudo kubeadm init>

# mkdir -p $HOME/.kube
# sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
# sudo chown $(id -u):$(id -g) $HOME/.kube/config
# export KUBECONFIG=/etc/kubernetes/admin.conf

# Control node の場合はコチラ
<sudo kubeadm join <IP_ADDRESS> --token <TOKEN> --discovery-token-ca-cert-hash sha256:<HASH>>
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?