zoukankan      html  css  js  c++  java
  • 安装k8s-1master多node节点

    卸载比较新的18.3版本,安装17.03版本

    删除旧版本
    
    

      sudo yum remove docker
      docker-client
      docker-client-latest
      docker-common
      docker-latest
      docker-latest-logrotate
      docker-logrotate
      docker-selinux
      docker-engine-selinux
      docker-engine

       sudo yum install -y yum-utils device-mapper-persistent-data lvm2

       sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

     yum install -y --setopt=obsoletes=0 
    docker-ce-17.03.2.ce-1.el7.centos.x86_64
    docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch
    /ect/docker/json: { "registry-mirrors": [ "https://iv7stq00.mirror.aliyuncs.com" ], "graph": "/opt/docker", "hosts": [ "tcp://0.0.0.0:2375", "unix:///var/run/docker.sock" ] } 新版本存储root目录是参数 data-root 旧版本为 graph

    安装k8s之前的准备工作

    关闭防火墙
    systemctl stop firewalld.service
    systemctl disable firewalld.service
    永久关闭SELinux
    vim /etc/selinux/config
    SELINUX=disabled
    同步集群系统时间
    yum -y install ntp
    ntpdate 0.asia.pool.ntp.org
    重启机器
    reboot
      关闭SWAP  
      swapoff -a
     

    安装yum源

    #阿里云yum源:
        wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
        yum clean all
        yum makecache
    #docker yum源
        cat >> /etc/yum.repos.d/docker.repo <<EOF
        [docker-repo]
        name=Docker Repository
        baseurl=http://mirrors.aliyun.com/docker-engine/yum/repo/main/centos/7
        enabled=1
        gpgcheck=0
        EOF
    #kubernetes yum源
        cat >> /etc/yum.repos.d/kubernetes.repo <<EOF
        [kubernetes]
        name=Kubernetes
        baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
        enabled=1
        gpgcheck=0
        EOF

    yum -y install docker kubeadm kubelet kubectl

    下载k8s镜像脚本执行

    images=(kube-proxy-amd64:v1.11.0 kube-scheduler-amd64:v1.11.0 kube-controller-manager-amd64:v1.11.0 kube-apiserver-amd64:v1.11.0
    etcd-amd64:3.2.18 coredns:1.1.3 pause-amd64:3.1 kubernetes-dashboard-amd64:v1.8.3 k8s-dns-sidecar-amd64:1.14.9 k8s-dns-kube-dns-amd64:1.14.9
    k8s-dns-dnsmasq-nanny-amd64:1.14.9 )
    for imageName in ${images[@]} ; do
    docker pull keveon/$imageName
    docker tag keveon/$imageName k8s.gcr.io/$imageName
    docker rmi keveon/$imageName
    done
    # 个人新加的一句,V 1.11.0 必加
    docker tag da86e6ba6ca1 k8s.gcr.io/pause:3.1

    docker pull registry.cn-hangzhou.aliyuncs.com/pycf/flannel:v0.10.0-amd64

      docker tag registry.cn-hangzhou.aliyuncs.com/pycf/flannel:v0.10.0-amd64 quay.io/coreos/flannel:v0.10.0-amd64
      docker rmi -f registry.cn-hangzhou.aliyuncs.com/pycf/flannel:v0.10.0-amd64

     

    启动master节点

    kubeadm init --kubernetes-version=1.11.0 --token-ttl 0 --pod-network-cidr=10.244.0.0/16
    root export KUBECONFIG=/etc/kubernetes/admin.conf

    安装网络插件


    vim /etc/sysctl.conf,添加以下内容 net.ipv4.ip_forward=1 net.bridge.bridge-nf-call-iptables=1 net.bridge.bridge-nf-call-ip6tables=1 修改后,及时生效 sysctl -p
    安装flannel网络插件
    wget https://raw.githubusercontent.com/coreos/flannel/v0.10.0/Documentation/kube-flannel.yml

    kubectl apply -f kube-flannel.yml
     
     
     

    添加node节点

    systemctl start kubelet
    kubeadm join 10.211.55.6:6443 --token 63nuhu.quu72c0hl95hc82m --discovery-token-ca-cert-hash sha256:3971ae49e7e5884bf191851096e39d8e28c0b77718bb2a413638057da66ed30a

     安装Dashboard 

    下载 https://github.com/gh-Devin/kubernetes-dashboard 文件到新建目录ds下
    在ds目录下新建文件dashboard-admin.yaml 内容如下:
    apiVersion: rbac.authorization.k8s.io/v1beta1
    kind: ClusterRoleBinding
    metadata:
      name: kubernetes-dashboard
      labels:
        k8s-app: kubernetes-dashboard
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: cluster-admin
    subjects:
    - kind: ServiceAccount
      name: kubernetes-dashboard
      namespace: kube-system

    kubectl -n kube-system create -f . 启动 访问 master:30090

  • 相关阅读:
    C# vb .net实现淡出效果特效滤镜
    <<薪资至少10K的一道题,你能拿下吗>>练习
    职场生存规则--水
    简单摸拟电梯程序
    回收期计算
    徒手写汉诺塔
    没有方法的算法代码
    听说是阿里笔试题
    工作任务的分解
    纯吐槽,关于现在的一些混乱情况.
  • 原文地址:https://www.cnblogs.com/1ssqq1lxr/p/9608399.html
Copyright © 2011-2022 走看看