系统分层
就像Linux拥有内核(kernel)、核心系统类库、和可选的用户级工具,kubernetes也拥有功能和工具的层次。对于开发者来说,理解这些层次是非常重要的。kubernetes APIs、概念和功能都在下面的层级图中得到体现。
环境配置
增加节点DNS 别名
cat <<EOF >>/etc/hosts
192.168.209.160 k8a
192.168.209.172 k8b
192.168.209.173 k8c
EOF
验证下ping k8b && ping k8c
复制hosts到其他节点
scp /etc/hosts root@k8b:/etc/hosts
scp /etc/hosts root@k8c:/etc/hosts
添加kube-master到kube-node的秘钥认证
ssh-keygen
ssh-copy-id hostname
在k8a上验证下ssh key
ssh k8b
ssh k8c
关闭SELinux sed -i ‘s#SELINUX=enforcing#SELINUX=disabled#g‘ /etc/selinux/config setenforce 0
关闭系统防火墙
systemctl stop firewalld
systemctl disable firewalld
关闭sawp分区 swapoff -a vi /etc/fstab 注释掉swap分区 #/dev/mapper/cl-swap swap swap defaults 0 0
脚本
swapoff -a && sysctl -w vm.swappiness=0
添加配置内核参数/etc/sysctl.d/k8s.conf文件
cat > /etc/sysctl.d/k8s.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.conf.all.forwarding = 1
vm.swappiness = 0
EOF
sysctl -p /etc/sysctl.d/k8s.conf
更新依赖库
yum install -y device-mapper-persistent-data lvm2 yum-utils
增加淘宝docker源
yum-config-manager --add-repo? http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum install -y docker-ce
启动docker
systemctl enable docker && systemctl start docker
增加淘宝k8s源
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
安装k8s 组件
yum install -y kubeadm kubectl kubelet
master节点启动组件
systemctl enable kubelet && systemctl start kubelet
验证版本
kubeadm version
原文地址:http://blog.51cto.com/433266/2119874