k8s部署安装:

    部署环境:

       centos7.1

       内核需要升级到4.xx以上版本

如下开始部署:

#vim /etc/docker/daemon.json

{
   "exec-opts" : [ "native.cgroupdriver=cgroupfs" ]

}

#systemctl enable docker && systemctl start docker

#/etc/yum.repos.d/kubernetes.repo

[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


国内源:

cat < /etc/yum.repos.d/kubernetes.repo

[kubernetes]name=Kubernetesbaseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/enabled=1gpgcheck=1repo_gpgcheck=1gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

exclude=kube*

EOF


备注这两个需要FQ:

  packages.cloud.google.com
  raw.githubusercontent.com


#setenforce 0

#yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes

#systemctl enable kubelet && systemctl start kubelet


#sysctl --system   关闭防火墙

# systemctl disable iptables-services firewalld 

# systemctl stop iptables-services firewalld

#rm -r -f /etc/kubernetes /var/lib/kubelet /var/lib/etcd /etc/etcd 

# swapoff -a    关闭swap分区

禁用ipv6: 

# /etc/sysctl.d/k8s.conf

net.bridge.bridge - nf - call - ip6tables  =  1
net.bridge.bridge - nf - call - iptables  =  1





初始化你的master 

kubeadm init --kubernetes-version=v1.14.1 --pod-network-cidr=10.244.0.0/16

#  mkdir -p $HOME/.kube

#  cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

#  chown $(id -u):$(id -g) $HOME/.kube/config


查看服务状态:

#kubectl get pods --all-namespaces -o wide

创建calico 网络


  1. 下载 rabc yaml: https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/rbac-kdd.yaml

  2. 下载 calico yaml https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/kubernetes-datastore/calico-networking/1.7/calico.yaml

  3. 修改 calico.yaml 的网段为 10.244.0.0/16。 key为 CALICO_IPV4POOL_CIDR 

  4. 安装: kubectl apply -f rbac-kdd.yaml && kubectl apply -f calico.yaml 

    #systemctl status kubelet

    #systemctl restart kubelet

  5. 重启kube dns pod: 只需要强制删除dns pod即可重启

    #kubectl delete pod --grace-period=0 --force --namespace=kube-system kube-dns-6f4fd4bdf-kn7rs

  6. 开启master节点允许部署pod: kubectl taint nodes --all node-role.kubernetes.io/master-



##############节点加入到集群######


  1. yum install -y docker 参考 CentOS Install Docker 

  2. yum install -y kubeadm 1.11.1-0

  3. yum install -y kubectl 1.11.1-0

  4. yum install -y kubelet 1.11.1-0

  • 2.0 启动依赖

  1. setenforce 0
  2. systemctl enable docker && systemctl start docker
  3. systemctl enable kubelet && systemctl start kubelet

  • 3.0 安装依赖镜像

  1. 依赖镜像 -  calico部分

     

  2. 设置

    echo  '1' > /proc/sys/net/bridge/bridge-nf-call-iptables
  • 4.0 执行join

  1. shell

    kubeadm join 192.168.35.51:6443 --token tpbi9f.3ot14qcehsmts4mj --discovery-token-ca-cert-hash sha256:xxxxx