标签:k8s
一、环境准备操作系统 Centos 7.4
主机信息
kb-001 192.168.0.11
kb-002 192.168.0.12
kb-003 192.168.0.13
添加kube-master到kube-node的秘钥认证
ssh-keygen
ssh-copy-id 主机名
安装docker
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum-config-manager --enable docker-ce-edge
yum-config-manager --enable docker-ce-testing
yum-config-manager --disable docker-ce-edge
yum erase docker-engine-selinux -y
yum makecache fast
yum install -y docker-ce
mkdir -p /etc/systemd/system/docker.service.d
cat > /etc/systemd/system/docker.service.d/docker.conf <<EOF
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd --debug=false -s overlay --graph=/data/docker/images --insecure-registry registry.xxxxxxxxxx.com -H unix:///var/run/docker.sock -H tcp://10.17.2.13:2371 $DOCKER_NETWORK_OPTIONS
EOF
格式化磁盘ftype mkfs.xfs -n ftype=1 /dev/vdb
挂载:mkdir /data && mount /dev/vdb /data
service docker start
关闭SELinux
sed -i ‘s#SELINUX=enforcing#SELINUX=disabled#g‘ /etc/selinux/config
setenforce 0
关闭sawp分区
swapoff -a
vi /etc/fstab
注释掉swap分区
#/dev/mapper/cl-swap swap swap defaults 0 0
关闭系统防火墙
systemctl stop firewalld
systemctl disable firewalld
添加配置内核参数/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
vm.swappiness = 0
EOF
sysctl -p /etc/sysctl.d/k8s.
或者
echo "net.bridge.bridge-nf-call-ip6tables = 1" >> /etc/sysctl.conf
echo "net.bridge.bridge-nf-call-iptables = 1" >> /etc/sysctl.conf
sysctl -p
#若问题
执行sysctl -p 时出现:
sysctl -p
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-ip6tables: No such file or directory
sysctl: cannot stat /proc/sys/net/bridge/bridge-nf-call-iptables: No such file or directory
解决方法:
modprobe br_netfilter
ls /proc/sys/net/bridge
安装socat等工具
yum install -y ebtables socat
安装kubernetes的时候,需要安装kubelet, kubeadm等包,但k8s官网给的yum源是packages.cloud.google.com,国内访问不了,此时我们可以使用阿里云的yum仓库镜像。
阿里云上没有附Help说明连接,简单摸索了下,如下设置可用(centos)。注意不要开启check。
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
配置防火墙
docker1.13以后将iptables的FORWARD默认设置为drop,因此要配置:
iptables -P FORWARD ACCEPT
service iptables save
并将该命令加入rc.local的exit之前
安装kubeadm
yum install -y kubeadm
初始化管理节点
kubeadm init --kubernetes-version=1.9.4 --apiserver-advertise-address 192.168.1.11 --pod-network-cidr 10.244.0.0/16 --skip-preflight-checks
标签:k8s
原文地址:http://blog.51cto.com/aaronsa/2086963