Centos7 部署k8s集群

-------------------------------------------------kubenet 安装---------------------------------------------------------------------
一. 系统安装准备 
配置yum
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

yum makecache
yum install docker
systemctl enable docker && systemctl start docker
yum install -y kubelet kubeadm kubectl

关闭交换空间
swapoff -s


关闭防火墙
$ setenforce 0
$ cat /etc/selinux/config
SELINUX=disabled
systemctl stop firewalld
systemctl disable firewalld


创建/etc/sysctl.d/k8s.conf文件,添加如下内容:
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1

重新加载内核
modprobe br_netfilter
sysctl -p /etc/sysctl.d/k8s.conf

修改配置
cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf # 添加如下配置
Environment="KUBELET_EXTRA_ARGS=--fail-swap-on=false (满足先决条件)
sed -i 's/--cgroup-driver=systemd/--cgroup-driver=cgroupfs/' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
systemctl daemon-reload
systemctl enable kubelet && systemctl start kubelet
以上master,node都需执行


集群安装初始化(master)
kubeadm init --kubernetes-version=v1.10.0 --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.1.177 –ignore-preflight-errors=Swap

配置kubelet运行环境
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config  
chown $(id -u):$(id -g) $HOME/.kube/config

查看集群状态
kubectl get cs
kubectl get pods --all-namespaces -o wide

配置pod网路
wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

添加节点
kubeadm join 192.168.201.178:6443 --token jk4o5o.gx9n8xn4poppgwkc --discovery-token-ca-cert-hash sha256:a29060c019c810171b2830262b278ad6a4495dc684b1d66976a195997f2b91fb


重置master
kubeadm reset
ifconfig cni0 down && ip link delete cni0
ifconfig flannel.1 down && ip link delete flannel.1
rm -rf /var/lib/cni/

 
--------------------------------------------------kurbenets架构-----------------------------------------------------------------------
master
    APIserver
    scheduler
    controller manager
    etcd
    pod网络

nodes
    kubelet
    kube-proxy

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试