zoukankan      html  css  js  c++  java
  • kubeadm 搭建 K8S集群

    kubeadm是K8s官方推荐的快速搭建K8s集群的方法。

    环境:

       

    • Ubuntu 16.04

    1 安装docker

    Install Docker from Ubuntu’s repositories:

    apt-get update apt-get install -y docker.io
    or install Docker CE
    17.03 from Docker’s repositories for Ubuntu or Debian: apt-get update apt-get install -y apt-transport-https ca-certificates curl software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - add-apt-repository "deb https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") $(lsb_release -cs) stable" apt-get update && apt-get install -y docker-ce=$(apt-cache madison docker-ce | grep 17.03 | head -1 | awk '{print $3}')

    2 安装 kubeadm, kubelet and kubectl

    apt-get update && apt-get install -y apt-transport-https curl
    curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
    cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
    deb http://apt.kubernetes.io/ kubernetes-xenial main
    EOF
    apt-get update
    apt-get install -y kubelet kubeadm kubectl

     (注意:

    在cat <<EOF >abcd.txt命令 与下一个输入的EOF行之间的所有文本行都会被当做是stdin数据。
    root@unbuntu:/# cat << EOF >abcd.txt
    > uu
    > hello world
    > ii
    > hah
    
    > EOF

    )

     3:  

    kubeadm init --ignore-preflight-errors 'Swap'

    export KUBECONFIG=/etc/kubernetes/admin.conf

    mkdir -p $HOME/.kube
    sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
    sudo chown $(id -u):$(id -g) $HOME/.kube/config



     4:   cd /etc/kubernetes/ 下面有各种配置文件

    在Kubernetes中有一个DaemonSet类型的POD,这种类型的POD可以在某个节点上长期运行,这种类型的POD就是静态POD。

    静态POD直接由某个节点上的kubelet程序进行管理,不需要api server介入,静态POD也不需要关联任何RC,完全是由kubelet程序来监控,当kubelet发现静态POD停止掉的时候,重新启动静态POD。

    5: Installing a pod network

              CNI:网络容器接口:

      • 网络插件是独立的可执行文件,被上层的容器管理平台调用。网络插件只有两件事情要做:把容器加入到网络以及把容器从网络中删除。
      • 调用插件的数据通过两种方式传递:环境变量和标准输入。
      • kubernetes 使用了 CNI 网络插件之后 工作流程: 
        • kubernetes 先创建 pause 容器生成对应的 network namespace
        • 调用网络 driver(因为配置的是 CNI,所以会调用 CNI 相关代码
        • CNI driver 根据配置调用具体的 cni 插件
        • cni 插件给 pause 容器配置正确的网络,pod 中其他的容器都是用 pause 的网络.

       You MUST install a pod network add-on so that your pods can communicate with each other.

       用如下命令创建一个CNI(这里使用的是flannel

    kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.10.0/Documentation/kube-flannel.yml

    kubectl get pods --all-namespaces. And once the kube-dns pod is up and running, you can continue by joining your nodes.

     6: Master Isolation

          By default, your cluster will not schedule pods on the master for security reasons,If you want to be able to schedule pods on the master, e.g. for a single-machine Kubernetes cluster for development, run:

    kubectl taint nodes --all node-role.kubernetes.io/master-
    This will remove the node-role.kubernetes.io/master taint from any nodes that have it, including the master node, meaning that the scheduler will then be able to schedule pods everywhere.

    7 增加nodes

  • 相关阅读:
    vscode 在linux中,切换语言模式快捷键
    转载大神的一篇文章----【如何选择开源许可证?】
    Kibana6.x.x——源码发布
    Kibana6.x.x——【Running "run:optimizeBuild" (run) task】出现警告信息
    linux系统为文件添加执行权限
    Kibana6.x.x——执行yarn build出现的警告信息记录
    Kibana6.x.x——导航权限控制入门
    poj 2187:Beauty Contest(计算几何,求凸包,最远点对)
    poj 2386:Lake Counting(简单DFS深搜)
    蓝桥杯 第三届C/C++预赛真题(10) 取球游戏(博弈)
  • 原文地址:https://www.cnblogs.com/liufei1983/p/9142245.html
Copyright © 2011-2022 走看看