阿里云国内节点centos7.2安装k8sv1.12.3
1.关闭防火墙systemctl stop firewalld && systemctl disable firewalld2.禁用selinuxsetenforce 03.确认selinux是否修改为disabledvi /etc/selinux/config4.创建/etc/sysctl.d/k8s.confnet.bridge.bridge-nf-call...
·
1.关闭防火墙
systemctl stop firewalld && systemctl disable firewalld
2.禁用selinux
setenforce 0
3.确认selinux是否修改为disabled
vi /etc/selinux/config
4.创建/etc/sysctl.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
ipv6需要增加配置
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0
net.ipv6.conf.all.forwarding=1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
proxy 使用 ipvs
cat > /etc/sysconfig/modules/ipvs.modules <<EOF
#!/bin/bash
ipvs_modules="ip_vs ip_vs_lc ip_vs_wlc ip_vs_rr ip_vs_wrr ip_vs_lblc ip_vs_lblcr ip_vs_dh ip_vs_sh ip_vs_nq ip_vs_sed ip_vs_ftp nf_conntrack_ipv4"
for kernel_module in \${ipvs_modules}; do
/sbin/modprobe \${kernel_module}
done
EOF
chmod 755 /etc/sysconfig/modules/ipvs.modules && bash /etc/sysconfig/modules/ipvs.modules && lsmod | grep ip_vs
5.使命令4生效
modprobe br_netfilter
sysctl -p
6.安装docker的yum源
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
7.安装docker,设置开机自启
yum makecache fast
yum install -y --setopt=obsoletes=0 \
docker-ce-18.06.1.ce-3.el7
systemctl start docker
systemctl enable docker
8.安装的kubelet、kubectl、kubeadm源
阿里云:
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
enabled=1
EOF
9.安装kubelet、kubectl、kubeadm
yum makecache fast
yum install -y kubernetes-cni-0.6.0-0.x86_64 kubelet-1.12.3 kubeadm-1.12.3 kubectl-1.12.3 //安装指定版本
10.关闭swap
swapoff -a
11.修改文件/etc/sysctl.d/k8s.conf添加vm.swappiness=0
12.kubelet开机启动
systemctl enable kubelet
systemctl start kubelet
13.拉取镜像
此时仅仅源为阿里云时需要拉镜像
docker pull mirrorgooglecontainers/kube-apiserver-amd64:v1.12.3
docker pull mirrorgooglecontainers/kube-controller-manager-amd64:v1.12.3
docker pull mirrorgooglecontainers/kube-scheduler-amd64:v1.12.3
docker pull mirrorgooglecontainers/kube-proxy-amd64:v1.12.3
docker pull mirrorgooglecontainers/pause-amd64:3.1
docker pull mirrorgooglecontainers/etcd-amd64:3.2.24
docker pull kuberneter/coredns:1.2.2
docker pull mirrorgooglecontainers/kubernetes-dashboard-amd64:v1.10.0
docker tag mirrorgooglecontainers/kube-apiserver-amd64:v1.12.3 k8s.gcr.io/kube-apiserver:v1.12.3
docker tag mirrorgooglecontainers/kube-controller-manager-amd64:v1.12.3 k8s.gcr.io/kube-controller-manager:v1.12.3
docker tag mirrorgooglecontainers/kube-scheduler-amd64:v1.12.3 k8s.gcr.io/kube-scheduler:v1.12.3
docker tag mirrorgooglecontainers/kube-proxy-amd64:v1.12.3 k8s.gcr.io/kube-proxy:v1.12.3
docker tag mirrorgooglecontainers/pause-amd64:3.1 k8s.gcr.io/pause:3.1
docker tag mirrorgooglecontainers/etcd-amd64:3.2.24 k8s.gcr.io/etcd:3.2.24
docker tag kuberneter/coredns:1.2.2 k8s.gcr.io/coredns:1.2.2
docker tag mirrorgooglecontainers/kubernetes-dashboard-amd64:v1.10.0 k8s.gcr.io/dashboard:v1.10.0
docker rmi mirrorgooglecontainers/kube-apiserver-amd64:v1.12.3
docker rmi mirrorgooglecontainers/kube-controller-manager-amd64:v1.12.3
docker rmi mirrorgooglecontainers/kube-scheduler-amd64:v1.12.3
docker rmi mirrorgooglecontainers/kube-proxy-amd64:v1.12.3
docker rmi mirrorgooglecontainers/pause-amd64:3.1
docker rmi mirrorgooglecontainers/etcd-amd64:3.2.24
docker rmi kuberneter/coredns:1.2.2
docker rmi mirrorgooglecontainers/kubernetes-dashboard-amd64:v1.10.0
14.初始化集群
kubeadm init --kubernetes-version=1.12.3 --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=140.143.0.194
15.部署集群失败
kubeadm reset
ifconfig cni0 down
ip link delete cni0
ifconfig flannel.1 down
ip link delete flannel.1
rm -rf /var/lib/cni/
16.初始化显示成功
a.当前为root用户
echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> ~/.bash_profile
source ~/.bash_profile
b.当前为普通用户
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
更多推荐
已为社区贡献1条内容
所有评论(0)