安装docker

sudo rm /var/lib/dpkg/lock-frontend
sudo rm /var/lib/dpkg/lock

curl -sSL https://get.docker.com | sh 
sudo usermod -aG docker $USER
重新登录

修改cgroup为system

sudo vi /etc/docker/daemon.json
输入
{
 "exec-opts":["native.cgroupdriver=systemd"]
}
sudo systemctl restart docker

使用kubeadm安装

1. 安装 kubelet、kubeadm 和 kubectl

sudo su
apt-get update && apt-get install -y apt-transport-https
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 http://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubelet kubeadm kubectl

source /usr/share/bash-completion/bash_completion
source <(kubectl completion bash)

2. 用kubeadm创建Cluster

2.1 初始化master

初始化master, 192.168.56.102需要换成master IP

sudo kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=10.11.64.64 --ignore-preflight-errors=NumCPU

sudo kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
2.2 配置kubectl

创建完cluster, 后面会有一些提升安装提示的做
提示中的创建

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

提示中的加入集群

kubeadm join 10.11.64.64:6443 --token h75o5f.s27h0ulodnemjlk2 --discovery-token-ca-cert-hash sha256:2c559b61de5f009a3704e8ccf0b221db482b0a76ab5d095005f62e4d23fefeec
2.3 安装Pod网络

https://github.com/flannel-io...

kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
2.4 添加node节点
kubeadm join 10.11.64.64:6443 --token h75o5f.s27h0ulodnemjlk2 --discovery-token-ca-cert-hash sha256:2c559b61de5f009a3704e8ccf0b221db482b0a76ab5d095005f62e4d23fefeec

引用

  1. 书籍《每天花5分钟玩转kubernetes》
  2. 书籍《kubernetes权威指南》

xxx小M
30 声望11 粉丝

暂时放一些读书笔记, 很多内容没有整理好