Fork me on GitHub

Ubuntu16.04下使用kubeadm一键部署kubernetes集群

一、环境规划

主机名 IP地址
k8s-master 192.168.56.121
k8s-node01 192.168.56.122
k8s-node02 192.168.56.103
k8s-node03 192.168.56.104

环境说明

  • 操作系统:Ubuntu 16.04 or CentOS 7
  • Kubernates版本:v1.10.3
  • Docker版本:17.03.2

CentOS7 关闭selinux,Ubuntu关闭swap

架构拓扑

二、安装说明

k8s-master、k8s-node01、k8s-node02、k8s-node03都需要做以下工作,如配置软件源,安装docker,配置docker镜像加速

2.1 配置ubuntu16.04阿里云源

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
sudo cp /etc/apk/sources.list /etc/apk/sources.list.$(date '+%Y%m%d%H%M%S').bak
sudo cat <<EOF > /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ xenial main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security universe
EOF

2.2 安装指定版本docker

1
2
3
4
5
6
7
8
9
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
sudo curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get -y update
#查看有哪些可用的docker版本
sudo apt-cache madison docker-ce
#sudo apt-get -y install docker-ce=[VERSION]
sudo apt-get -y install docker-ce=17.03.2~ce-0~ubuntu-xenial

2.2.1 配置docker镜像加速

1
2
3
4
5
6
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}
EOF

2.2.2 重启docker

1
sudo systemctl restart docker

三、安装k8s master

四、安装k8s node

参考

https://github.com/cookcodeblog/k8s-deploy

https://blog.csdn.net/zhenliang8/article/details/78611004