本文主要参考自:

https://blog.csdn.net/real_myth/article/details/78719244

还有一份更适合在生产环境使用的超强高可用(多master,nginx+keepalived负载)

https://www.cnblogs.com/dukuan/p/9856269.html

部分参考:

https://blog.csdn.net/u013760355/article/details/68061976

机器环境

主机 部署服务
192.168.201.181 etcd/master
192.168.201.182 etcd/flannel
192.168.201.183 etcd/

K8S核心概念等

https://www.cnblogs.com/radio/p/10572257.html

安装etcd:

查看之前的文章 https://www.cnblogs.com/radio/p/10572124.html

Master节点安装:

  • 在主节点181直接使用yum安装
yum -y install kubernetes

如果报错说docker-cli docker-ce冲突什么的,那就卸载掉docker, 然后重新运行上面的步骤,K8S会选择匹配版本的docker自动安装.

  yum list installed | grep docker
yum remove -y
yum remove -y docker-ce.x86_64
yum remove -y docker-ce-cli.x86_64

安装成功之后会显示K8S的版本和安装的以来版本,可以看到里面有docker:

已安装:
kubernetes.x86_64 0:1.5.2-0.7.git269f928.el7 作为依赖被安装:
PyYAML.x86_64 0:3.10-11.el7 atomic-registries.x86_64 1:1.22.1-26.gitb507039.el7.centos conntrack-tools.x86_64 0:1.4.4-4.el7
container-storage-setup.noarch 0:0.11.0-2.git5eaf76c.el7 containers-common.x86_64 1:0.1.31-8.gitb0b750d.el7.centos docker.x86_64 2:1.13.1-94.gitb2f74b2.el7.centos
docker-client.x86_64 2:1.13.1-94.gitb2f74b2.el7.centos docker-common.x86_64 2:1.13.1-94.gitb2f74b2.el7.centos kubernetes-client.x86_64 0:1.5.2-0.7.git269f928.el7
kubernetes-master.x86_64 0:1.5.2-0.7.git269f928.el7 kubernetes-node.x86_64 0:1.5.2-0.7.git269f928.el7 libnetfilter_cthelper.x86_64 0:1.0.0-9.el7
libnetfilter_cttimeout.x86_64 0:1.0.0-6.el7 libnetfilter_queue.x86_64 0:1.0.2-2.el7_2 libyaml.x86_64 0:0.1.4-11.el7_0
oci-register-machine.x86_64 1:0-6.git2b44233.el7 oci-systemd-hook.x86_64 1:0.1.18-3.git8787307.el7_6 oci-umount.x86_64 2:2.3.4-2.git87f9237.el7
python-backports.x86_64 0:1.0-8.el7 python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 python-ipaddress.noarch 0:1.0.16-2.el7
python-pytoml.noarch 0:0.1.14-1.git7dea353.el7 python-setuptools.noarch 0:0.9.8-7.el7 socat.x86_64 0:1.7.3.2-2.el7
subscription-manager-rhsm-certificates.x86_64 0:1.21.10-3.el7.centos yajl.x86_64 0:2.0.4-4.el7
  • 配置K8S:
#vim /etc/kubernetes/apiserver

###
# kubernetes system config
#
# The following values are used to configure the kube-apiserver
# # The address on the local server to listen to.
KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0" # The port on the local server to listen on.
KUBE_API_PORT="--port=8080" # Port minions listen on
KUBELET_PORT="--kubelet-port=10250" # Comma separated list of nodes in the etcd cluster
KUBE_ETCD_SERVERS="--etcd-servers=http://192.168.201.181:2379,http://192.168.201.182:2379,http://192.168.201.183:2379" # Address range to use for services
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16" # default admission control policies
#KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota"
# (PS:也有人说测试时需要把KUBE_ADMISSION_CONTROL中的SecurityContextDeny和ServiceAccount去掉,这是权限相关的 先试试吧)
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota" # Add your own!
KUBE_API_ARGS=""

还改了一个文件vim /etc/kubernetes/config,修改了KUBE_MASTER为当前181机器的master IP

###
# kubernetes system config
#
# The following values are used to configure various aspects of all
# kubernetes services, including
#
# kube-apiserver.service
# kube-controller-manager.service
# kube-scheduler.service
# kubelet.service
# kube-proxy.service
# logging to stderr means we get it in the systemd journal
KUBE_LOGTOSTDERR="--logtostderr=true" # journal message level, 0 is debug
KUBE_LOG_LEVEL="--v=0" # Should this cluster be allowed to run privileged docker containers
KUBE_ALLOW_PRIV="--allow-privileged=false" # How the controller-manager, scheduler, and proxy find the apiserver
KUBE_MASTER="--master=http://192.168.201.181:8080"
  • 重启服务
for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler; do systemctl restart $SERVICES ; systemctl enable $SERVICES ; systemctl status $SERVICES ; done
  • 配置etcd内网信息

    etcdctl -C //192.168.201.181:2379 set /atomic.io/network/config '{"Network":"172.17.0.0/16"}'

    PS:其中网络号172.17.0.0/16与docker中的docker0网络一致(若不一致,可修改docker0网络或者配置上述etcd网络);atomic.io与下面的Flannel配置中的FLANNEL_ETCD_PREFIX对应

  • 至此master配置完成,运行kubectl get nodes可以查看有多少minion在运行,以及其状态。这里我们的minion还都没有开始安装配置,所以运行之后结果为空

No resources found.```
- 此时访问master:8080可以看到api服务支持的路径:
![](https://img2018.cnblogs.com/blog/475953/201903/475953-20190321163837871-1532218737.png) ## Node节点安装flannel > https://www.jianshu.com/p/165a256fb1da 使用`yum install flannel`安装,然后修改配置文件`vim /etc/sysconfig/flanneld `:

Flanneld configuration options

etcd url location. Point this to the server where etcd runs

FLANNEL_ETCD_ENDPOINTS="http://192.168.201.181:2379,http://192.168.201.182:2379,http://192.168.201.183:2379"

etcd config key. This is the configuration key that flannel queries

For address range assignment

FLANNEL_ETCD_PREFIX="/atomic.io/network"

Any additional options that you want to pass

FLANNEL_OPTIONS=""

PS:其中atomic.io与上面etcd中的Network对应!!

## Node节点安装kubernetes-node
`yum install kubernetes-node` `vim /etc/kubernetes/config`
配置k8s公共配置文件,指定etcd的节点信息,和k8s的master信息:

kubernetes system config

The following values are used to configure various aspects of all

kubernetes services, including

kube-apiserver.service

kube-controller-manager.service

kube-scheduler.service

kubelet.service

kube-proxy.service

logging to stderr means we get it in the systemd journal

KUBE_LOGTOSTDERR="--logtostderr=true"

journal message level, 0 is debug

KUBE_LOG_LEVEL="--v=0"

Should this cluster be allowed to run privileged docker containers

KUBE_ALLOW_PRIV="--allow-privileged=false"

How the controller-manager, scheduler, and proxy find the apiserver

KUBE_MASTER="--master=http://192.168.201.181:8080"

KUBE_ETCD_SERVERS="--etcd-servers=http://192.168.201.181:2379,http://192.168.201.182:2379,http://192.168.201.183:2379"


### 配置Node节点的 kubernetes kubelet (minion) config:
`vim /etc/kubernetes/kubelet `
修改下面的`KUBELET_ADDRESS`和`KUBELET_HOSTNAME`为当前机器,`KUBELET_API_SERVER`为真实Master

kubernetes kubelet (minion) config

The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces)

KUBELET_ADDRESS="--address=0.0.0.0"

The port for the info server to serve on

KUBELET_PORT="--port=10250"

You may leave this blank to use the actual hostname

KUBELET_HOSTNAME="--hostname-override=192.168.201.182"

location of the api-server

KUBELET_API_SERVER="--api-servers=http://192.168.201.181:8080"

pod infrastructure container

KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"

Add your own!

KUBELET_ARGS=""

### 启动并配置开机启动

systemctl enable kubelet kube-proxy

systemctl start kubelet kube-proxy

kubernetes安装的更多相关文章

  1. Docker系列(九)Kubernetes安装

    环境: A.B两天机器A机器IP:192.169.0.104,B机器IP:192.168.0.102,其中A为Master节点,B为Slave节点 操作系统:Centos7 Master与Slave节 ...

  2. 轻松加愉快的 Kubernetes 安装教程

    轻松加愉快的 Kubernetes 安装教程 马哥Linux运维 2 days ago 作者:无聊的学习者 来源:见文末 在国内安装 K8S,一直是大家很头痛的问题,各种麻烦,关键是还不知道需要下载什 ...

  3. Kuboard Kubernetes安装

    一.简介 Kubernetes 容器编排已越来越被大家关注,然而使用 Kubernetes 的门槛却依然很高,主要体现在这几个方面: 集群的安装复杂,出错概率大 Kubernetes相较于容器化,引入 ...

  4. kubernetes安装-kubeadm

    系统信息 角色 系统 CPU Core memory master 18.04.1-Ubuntu 4 8G slave 18.04.1-Ubuntu 4 4G 安装前准备(主节点和从节点都需要执行) ...

  5. kubernetes安装-二进制

    主要参考https://github.com/opsnull/follow-me-install-kubernetes-cluster,采用Flanel和docker 系统信息 角色 系统 CPU C ...

  6. 服务网格Istio入门-详细记录Kubernetes安装Istio并使用

    我最新最全的文章都在南瓜慢说 www.pkslow.com,文章更新也只在官网,欢迎大家来喝茶~~ 1 服务网格Istio Istio是开源的Service Mesh实现,一般用于Kubernetes ...

  7. kubernetes 安装备注

    一.安装环境 阿里云:centos 7.3 master节点:外网IP(116.62.205.90).内网IP(172.16.223.200) node节点:外网IP(116.62.212.174). ...

  8. kubernetes 安装kong、kong-ingress-controlor

    一.关于kong的详细内容这里不再赘述,可以查看官网. kong升级到1.0以后功能越来越完善,并切新版本的kong可以作为service-mesh使用,并可以将其作为kubernetes的ingre ...

  9. kubernetes 安装手册(成功版)

    管理组件采用staticPod或者daemonSet形式跑的,宿主机os能跑docker应该本篇教程能大多适用安装完成仅供学习和实验 本次安裝的版本: Kubernetes v1.10.0 (1.10 ...

随机推荐

  1. apache安装软负载的配置说明

    安装Apache:yum -y install httpd 首先要查看apache的安装版本 命令:httpd –v 第一种: 若安装是2.2版本,则把复制 mod_wl_22.so和mod_wl.s ...

  2. 饮冰三年-人工智能-Python-19 Python网络编程

    Socket:套接字.作用:我们只需要安照socket的规定去编程,就不需要深入理解tcp/udp协议也可以实现 1:TCP协议 1.1  客户端服务端循环收发消息 # 1:引入stock模块(导包) ...

  3. 阿里云学生服务器搭建网站-Ubuntu16.04安装php开发环境

    阿里云学生服务器搭建网站(2)-Ubuntu16.04安装php开发环境  优秀博文:https://www.linuxidc.com/Linux/2016-10/136327.htm https:/ ...

  4. java请求参数转换

    public class HttpServletRequestUtil { //转换请求参数 public static int getInt(HttpServletRequest request, ...

  5. 【工具】idea工具 java代码 gbk转utf8

    idea工具 https://github.com/downgoon/gbk2utf8 安装在目录下: /usr/local/gbk2utf8/bin 进入目录后直接执行 gbk2utf8 sourc ...

  6. lintcode 447 Search in a Big Sorted Array(倍增+二分)

    题意:给一个按照升序排序的正整数数组.这个数组很大以至于只能通过固定的接口ArrayReader->get(k)来访问第k个数.并且也没有办法得知这个数组有多大.找到给出的整数target第一次 ...

  7. vue在jsx中使用for循环

    return <div domPropsInnerHTML="titles" style={{ color: 'red', fontSize: '14px' }}> { ...

  8. sql多字段相减///单字段多值

    SELECT IFNULL(t.预算金额,)-IFNULL(t.实使用金额,)-IFNULL(SUM(f.已审核.待审核总数),)remainingMoney FROM 表名 t LEFT JOIN ...

  9. 百度语音+react+loopback实现语音合成返回播放

    1.在百度语音中创建自己的项目,需要拿到APP_ID.API_KEY.SECRET_KEY. 2.loopback端提供接口服务,在./boot目录下新建root.js文件,编写不依赖模型的自定义接口 ...

  10. PostgreSQL自学笔记:9 索引

    9 索引 9.1 索引简介 索引是对数据库表中一列或多列值进行排序的一种结构,使用 索引可提高数据库中特定数据的查询速度 9.1.1 索引的含义和特点 索引是一种单独的.存储在磁盘上的数据库结构,他们 ...