Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3759836
  • 博文数量: 880
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 6155
  • 用 户 组: 普通用户
  • 注册时间: 2016-11-11 09:12
个人简介

To be a better coder

文章分类

全部博文(880)

文章存档

2022年(5)

2021年(60)

2020年(175)

2019年(207)

2018年(210)

2017年(142)

2016年(81)

分类: LINUX

2020-01-11 17:13:01

[root@localhost /]# cat k8s.master.conf
    1  吃的/
    2  cd /
    3  hostnamectl set-hostname master
    4  cat <>/etc/hosts
192.168.27.32 master
192.168.27.34 node1
192.168.27.35 node2
EOF

    5  systemctl stop firewalld
    6  systemctl disable firewalld
    7  setenforce 0
    8  sed -i "s/^SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
    9  swapoff -a
   10  sed -i 's/.*swap.*/#&/' /etc/fstab
   11  cat > /etc/sysctl.d/k8s.conf < net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF

   12  sysctl --system
   13  yum install -y wget
   14  cd etc/yum.repos.d/
   15  ls
   16   ip route add default via 192.168.27.1
   17  echo "nameserver 114.114.114.114" >> /etc/resolv.conf
   18  echo "nameserver 8.8.8.8" >> /etc/resolv.conf
   19  ping
   20  yum install -y wget
   21  mkdir /etc/yum.repos.d/bak && mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak
   22  wget -O /etc/yum.repos.d/CentOS-Base.repo
   23  wget -O /etc/yum.repos.d/epel.repo
   24  yum clean all && yum makecache
   25  cat < /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=
EOF

   26  wget -O /etc/yum.repos.d/docker-ce.repo
   27  yum install -y docker-ce-18.06.1.ce-3.el7
   28  systemctl enable docker && systemctl start docker
   29  yum install -y kubelet kubeadm kubectl
   30  systemctl enable kubelet
   31  kubelet --version
   32  kubeadm init --kubernetes-version=1.17.0 --apiserver-advertise-address=192.168.27.32 --image-repository registry.aliyuncs.com/google_containers --service-cidr=10.1.0.0/16 --pod-network-cidr=10.244.0.0/16
   33  mkdir -p /root/.kube
   34  cp /etc/kubernetes/admin.conf /root/.kube/config
   35  kubectl get nodes
   36  kubectl get cs
   37  cd /
   38  kubectl get cs
   39  kubectl get nodes
   40  history > k8s.master.conf
[root@localhost /]#

k8s  node

[root@localhost /]# cat k8s.node1.conf
    1  吃的/
    2  cd /
    3  hostnamectl set-hostname node1
    4  cat <>/etc/hosts
192.168.27.32 master
192.168.27.34 node1
192.168.27.35 node2
EOF

    5  systemctl stop firewalld
    6  systemctl disable firewalld
    7  setenforce 0
    8  sed -i "s/^SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
    9  swapoff -a
   10  sed -i 's/.*swap.*/#&/' /etc/fstab
   11  cat > /etc/sysctl.d/k8s.conf < net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF

   12  sysctl --system
   13  ip route add default via 192.168.27.1
   14  echo "nameserver 114.114.114.114" >> /etc/resolv.conf
   15  echo "nameserver 8.8.8.8" >> /etc/resolv.conf
   16  yum install -y wget
   17  mkdir /etc/yum.repos.d/bak && mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak
   18  wget -O /etc/yum.repos.d/CentOS-Base.repo
   19  wget -O /etc/yum.repos.d/epel.repo
   20  yum clean all && yum makecache
   21  cat < /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=
EOF

   22  wget -O /etc/yum.repos.d/docker-ce.repo
   23  yum install -y docker-ce-18.06.1.ce-3.el7
   24  systemctl enable docker && systemctl start docker
   25  yum install -y kubelet kubeadm kubectl
   26  systemctl enable kubelet
   27  kubelet version
   28  kubelet -version
   29  kubelet --version
   30  kubeadm join 192.168.27.32:6443 --token 74rsnp.l2nhrg6fqhhhwkc9 --discovery-token-ca-cert-hash sha256:d932705b20da0d7783b389827827f39273bf3e27db5633d469f762e425826ad0
   31  history > k8s.node1.conf
[root@localhost /]#




容器网络  docker network  /  DNS


k8s网络之Calico网络  IPIP及BGP两种模式

https://www.cnblogs.com/goldsunshine/p/10701242.html

k8s卸载flannel网络

https://blog.csdn.net/weixin_34409741/article/details/92513036
#第一步,在master节点删除flannel
kubectl delete -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

#第二步,在node节点清理flannel网络留下的文件
ifconfig cni0 down
ip link delete cni0
ifconfig flannel.1 down
ip link delete flannel.1
rm -rf /var/lib/cni/
rm -f /etc/cni/net.d/*
注:执行完上面的操作,重启kubelet

#第三步,应用calico相关的yaml文件

调试

kubectl describe
kubectl logs
systemctl status
journal -u

yum的repo问题

kubeadm init 后master一直处于notready状态

查看日志定位问题 journalctl -f -u kubelet.service

Unable to update cni config: no networks found in /etc/cni/net.d



查看pod的日志kubectl describe pod ku
阅读(1344) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~