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 - | 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

最新文章

  1. .Net Core 系列:1、环境搭建
  2. 读书笔记--SQL必知必会09--汇总数据
  3. Monkey工具使用详解
  4. ubuntu14.04计划任务无法执行
  5. (转)Could not create the view: An unexpected exception was thrown. 电脑突然断电,myeclipse非正常关闭,出现错误
  6. PLSQL_长脚本如何判断需耗时多久v.sql / v.sqltext / v.sqlarea / v.sql_plan及nohup(案例)
  7. LNK1123: 转换到 COFF 期间失败: 文件无效或损坏[汇总]
  8. 【转】Android应用开发性能优化完全分析
  9. 今天,Java编程周末提高班(第一期)正式结束
  10. iOS经常使用类别
  11. 原生js获取left值和top值
  12. [转]Web应用防火墙WAF详解
  13. Java多线程的创建与简单使用
  14. 剑指Offer 66. 机器人的运动范围 (回溯)
  15. Cookiecutter: 更好的项目模板工具:(2)安装及基础使用
  16. 【BZOJ1879】[SDOI2009]Bill的挑战(动态规划)
  17. awk计算最大值,最小值,平均值的脚本
  18. MyEclipse和Eclipse
  19. 数据结构与算法--最小生成树之Prim算法
  20. Win8交互UX——触摸板交互

热门文章

  1. win7 32位下载安装redis并安装php_redis扩展
  2. python cookbook第三版学习笔记十六:抽象基类
  3. Swift——(四)Swift中&quot;#&quot;的妙用
  4. C#聚合运算方法
  5. linux下tomcat的配置及项目的部署流程
  6. 每天一个Linux命令(28)df命令
  7. Java InetAddress.getByAddress()的使用
  8. Data Structure Graph: prim
  9. P3506 [POI2010]MOT-Monotonicity 2
  10. Vue-Quill-Editor回显不显示空格的处理办法