下安装入门级别的Kubernetes集群,操作系统本地安
分类:pc28.am神测网

Kubernetes集群组件:
  - etcd 二个高可用的K/V键值对存款和储蓄和服务意识系统
  - flannel 达成夸主机的器皿互连网的通信
  - kube-apiserver 提供kubernetes集群的API调用
  - kube-controller-manager 确认保证集群服务
  - kube-scheduler 调节容器,分配到Node
  - kubelet 在Node节点上遵照安插文件中定义的容器规范运转容器
  - kube-proxy 提供互连网代理服务

kubernetes是google集团依据docker所做的八个布满式集群,有以下主件组成

前情表明: 三台CentOS7系统的设想机(1个master 2个node),三台机器上的防火墙,SELINUX全体关闭。笔者的尝试坏境可以上网,私下认可的YUM源就能够用。

一.安装配置Kubernetes Master 如下操作在master上实施1.使用yum安装etcd和kubernetes-master

etcd: 高可用存款和储蓄共享配置和服务意识

1.什么是kubernetes   

# yum -y install etcd kubernetes-master

flannel: 网络布局扶植

  Kubernetes(k8s)是Google开源的器皿集群管理种类(谷歌(Google)里面:Borg)。在Docker本事的基础上,为容器化的利用提供布署运维、财富调解、服务意识和动态伸缩等一多元完整意义,进步了广泛容器集群管理的便捷性。   

2.编辑/etc/etcd/etcd.conf文件

kube-apiserver: 不论通过kubectl依然使用remote api 直接调整,都要经过apiserver

  Kubernetes优势:       

ETCD_NAME=default
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"                
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"             #监听客户地址的端口
ETCD_ADVERTISE_CLIENT_URLS="http://主ip:2379"        #通知客户的地址及端口

kube-controller-manager: 对replication controller, endpoints controller, namespace controller, and serviceaccounts controller的轮回调整,与kube-apiserver交互,有限支撑那些controller职业

    - 容器编排         

3.编辑/etc/kubernetes/apiserver文件

kube-scheduler: Kubernetes scheduler的效应便是依附特定的调治算法将pod调治到钦定的干活节点(minion)上,这一进度也叫绑定(bind)

     - 轻量级         

KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"                              #服务器的监听地址
KUBE_API_PORT="--port=8080"                                                                  #监听端口
KUBELET_PORT="--kubelet-port=10250"                                            

kubelet: Kubelet运转在Kubernetes Minion Node上. 它是container agent的逻辑继任者

    - 开源          

KUBE_ETCD_SERVERS="--etcd-servers="                     #etcd 服务的地方及端口
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota"
KUBE_API_ARGS=""

kube-proxy: kube-proxy是kubernetes 里运营在minion节点上的三个零件, 它起的效应是多少个服务代办的剧中人物

    - 弹性伸缩         

cp /etc/kubernetes/config /etc/kubernetes/config.bak

kubernetes架构图 如下:

    - 负载均衡

vim /etc/kubernetes/config

图片 1

      •Kubernetes的为主概念

KUBE_LOGTOSTDERR=``"--logtostderr=true"

环境:Centos7 X86_64

  1)Pod   

KUBE_LOG_LEVEL=``"--v=0"

下载地址:

    运营于Node节点上,若干连锁容器的重组。Pod内包涵的器皿运转在同一宿主机上,使用同一的网络命名空间、IP地址和端口,能够通过localhost实行通。Pod是Kurbernetes实行创办、调整和管理的微小单位,它提供了比容器更高等级次序的虚幻,使得陈设和治本更灵敏。贰个Pod能够分包二个器皿恐怕四个相关容器。                       2)Replication Controller
      Replication Controller用来管理Pod的别本,保障集群中设有钦命数量的Pod别本。集群中别本的数额超越钦定数量,则会甘休钦赐数量之外的盈余容器数量,反之,则会运营少于钦定数量个数的容器,保险数据不改变。Replication Controller是贯彻弹性伸缩、动态扩大体积和滚动晋级的主干。

KUBE_ALLOW_PRIV=``"--allow-privileged=false"

master:192.168.50.130

  3)Service   

4.启动etcd、kube-apiserver、kube-controller-manager、kube-scheduler等服务,并设置开机启动。

monion01:192.168.50.131

     Service定义了Pod的逻辑集结和访谈该会集的方针,是真性服务的架空。Service提供了贰个统一的服务拜谒入口以至服务代办和意识体制,顾客不须求掌握后台Pod是何等运营。

for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler;

monion02:192.168.50.132

      4)Label     

do

monion03:192.168.50.133

       Kubernetes中的大肆API对象都以通过Label举行标志,Label的真相是一多种的K/V键值对。Label是Replication Controller和Service运转的基本功,二者通过Label来进展关联Node上运营的Pod。

  systemctl restart $SERVICES;

master部署:

      5)Node   

  systemctl enable $SERVICES;

1.关门防火墙

      Node是Kubernetes集群框架结构中运转Pod的服务节点(或agent)。Node是Kubernetes集群操作的单元,用来承载被分配Pod的运营,是Pod运营的宿主机。

  systemctl status $SERVICES ;

#systemctl stop firewalld

2.先安装 Kubernetes Master

done

#systemctl disable firewalld

  1)使用yum安装etcd和kubernetes-master

5.在etcd中定义flannel网络

2.禁用selinux

# yum -y install etcd kubernetes-master  flannel

etcdctl mk /atomic.io/network/config '{"Network":"172.17.0.0/16"}'

setenforce 0

  2)编辑/etc/etcd/etcd.conf文件

二.设置配备Kubernetes Node

3.安装ntp

ETCD_NAME=default
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_CLIENT_URLS=""
ETCD_ADVERTISE_CLIENT_URLS=""

正如操作在node1、node2上推行

yum -y install ntp

  3)编辑/etc/kubernetes/apiserver文件

1.使用yum安装flannel和kubernetes-node

systemctl start ntpd

KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"
KUBE_API_PORT="--port=8080"
KUBELET_PORT="--kubelet-port=10250"
KUBE_ETCD_SERVERS="--etcd-servers="
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota"
//注意:上一句里面包车型地铁ServerCount一定要去掉,不然pod会未有数量的。

yum -y install flannel kubernetes-node

systemctl enable ntpd

  4)在etcd中定义flannel网络

2.为flannel互联网钦点etcd服务,修改/etc/sysconfig/flanneld文件

4.安装etcd与kubernete

# etcdctl mk /atomic.io/network/config '{"Network":"172.17.0.0/16"}'

FLANNEL_ETCD=""                                           #etcd运营在哪个服务器上
FLANNEL_ETCD_KEY="/atomic.io/network"

yum -y install etcd kubernetes

   5)编辑/etc/sysconfig/flanneld

3.修改/etc/kubernetes/config文件

5.修改etcd配置文件

FLANNEL_ETCD_ENDPOINTS=""
FLANNEL_ETCD_PREFIX="/atomic.io/network"

KUBE_LOGTOSTDERR="--logtostderr=true"
KUBE_LOG_LEVEL="--v=0"
KUBE_ALLOW_PRIV="--allow-privileged=false"
KUBE_MASTER="--master="                              #主服务器的地址和端口

vi /etc/etcd/etcd.conf

   6)运行etcd、kube-apiserver、kube-controller-manager、kube-scheduler、flanneld等服务,并安装开机运维。

4.遵纪守法如下内容改换对应node的布署文件/etc/kubernetes/kubelet

ETCD_NAME=default

# for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler flanneld;
   do
    systemctl restart $SERVICES;
    systemctl enable $SERVICES;
    systemctl status $SERVICES ;
    done

首先个节点

ETCD_DATA_DIR="/var/lib/etcd/default.etcd"

3.安装配置Kubernetes Node

KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_PORT="--port=10250"
KUBELET_HOSTNAME="--hostname-override=192.168.1.21" #修改成相应Node的IP
KUBELET_API_SERVER="--api-servers=" #指定Master节点的API Server
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"
KUBELET_ARGS=""

ETCD_LISTEN_CLIENT_URLS=""

  1)使用yum安装flannel和kubernetes-node

第三个节点

ETCD_ADVERTISE_CLIENT_URLS=""

# yum -y install flannel kubernetes-node  

KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_PORT="--port=10250"
KUBELET_HOSTNAME="--hostname-override=192.168.1.141" #修改成相应Node的IP
KUBELET_API_SERVER="--api-servers=" #指定Master节点的API Server
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"
KUBELET_ARGS=""

6.修改kubernetes apiserver

  2)为flannel互连网钦点etcd服务,修改/etc/sysconfig/flanneld文件

5.在颇负Node节点上运维kube-proxy,kubelet,docker,flanneld等劳动,并设置开机运行。

vi /etc/kubernetes/apiserver

FLANNEL_ETCD=""
FLANNEL_ETCD_KEY="/atomic.io/network"  

for SERVICES in kube-proxy kubelet docker flanneld;

KUBE_API_ADDRESS="--address=0.0.0.0"

  3)修改/etc/kubernetes/config文件

do

KUBE_API_PORT="--port=8080"

KUBE_LOGTOSTDERR="--logtostderr=true"
KUBE_LOG_LEVEL="--v=0"
KUBE_ALLOW_PRIV="--allow-privileged=false"
KUBE_MASTER="--master="

  systemctl restart $SERVICES;

KUBELET_PORT="--kubelet_port=10250"

  4)根据如下内容改换对应node的配备文件/etc/kubernetes/kubelet

  systemctl enable $SERVICES;

KUBE_ETCD_SERVERS="--etcd_servers="

node1:

  systemctl status $SERVICES;

KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"

KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_PORT="--port=10250"
KUBELET_HOSTNAME="--hostname-override=192.168.118.140" #修改成对应Node的IP
KUBELET_API_SERVER="--api-servers=" #指定Master节点的API Server
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.RedHat.com/rhel7/pod-infrastructure:latest"
KUBELET_ARGS=""

done

KUBE_ADMISSION_CONTROL="--admission_control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota"

node2:

三.验证集群是不是安装成功

KUBE_API_ARGS=""

KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_PORT="--port=10250"
KUBELET_HOSTNAME="--hostname-override=192.168.118.141"
KUBELET_API_SERVER="--api-servers="
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"
KUBELET_ARGS=""

在master上实施如下命令

7.启动kube-apiserver  kube-controller-manager  kube-scheduler

  5)在具有Node节点上运维kube-proxy,kubelet,docker,flanneld等劳务,并设置开机运维。

kubectl get node

forSERVICESinetcd kube-apiserver kube-controller-manager kube-scheduler;do

# for SERVICES in kube-proxy kubelet docker flanneld;do systemctl restart $SERVICES;systemctl enable $SERVICES;systemctl status $SERVICES; done

讲解:上述2个节点平常展现,状态为Ready,则证实集群搭建变成功。

systemctl restart $SERVICES

4.验证是还是不是中标

图片 2

systemctl enable $SERVICES

[root@master ~]# kubectl get node
NAME              STATUS    AGE
192.168.118.140  Ready    3d
192.168.118.141  Ready    3d

 

systemctl status $SERVICES

5.常用排错命令

 

done

#kubectl describe pod/rc    .....  -n=kube-system

 

8.创办网络

本文永世更新链接地址:http://www.linuxidc.com/Linux/2017-10/148042.htm

etcdctl mk /atomic.io/network/config'{"Network":"172.17.0.0/16"}'

图片 3

9.查看节点

kubectlgetnodes

图片 4

到此master端配置完结

客商端配置

1.在monion01、monion02、monion03上部署

yum -y install flannel kubernetes

2.配置flanneld

1

vi /etc/sysconfig/flanneld
FLANNEL_ETCD=""

3.配置kubernetes

vi /etc/kubernetes/config

KUBE_MASTER="--master="

4.配置kubelet

monion01

vi /etc/kubernetes/kubelet

KUBELET_ADDRESS="--address=0.0.0.0"

KUBELET_PORT="--port=10250"

# change the hostname to this host’s IP address

KUBELET_HOSTNAME="--hostname_override=192.168.50.131"

KUBELET_API_SERVER="--api_servers="

KUBELET_ARGS=""

monion02

vi /etc/kubernetes/kubelet

KUBELET_ADDRESS="--address=0.0.0.0"

KUBELET_PORT="--port=10250"

# change the hostname to this host’s IP address

KUBELET_HOSTNAME="--hostname_override=192.168.50.132"

KUBELET_API_SERVER="--api_servers="

KUBELET_ARGS=""

monion03

KUBELET_ADDRESS="--address=0.0.0.0"

KUBELET_PORT="--port=10250"

# change the hostname to this host’s IP address

KUBELET_HOSTNAME="--hostname_override=192.168.50.133"

KUBELET_API_SERVER="--api_servers="

KUBELET_ARGS=""

5.起步服务

forSERVICESinkube-proxy kubelet docker flanneld;do

systemctl restart $SERVICES

systemctl enable $SERVICES

systemctl status $SERVICES

done

6.验证

monion01

ip a | grep flannel | grep inet

图片 5

在monion02和monion3上实践查看

master

kubect lget nodes

NAME             LABELS                                  STATUS

192.168.50.131   kubernetes.io/hostname=192.168.50.131   Ready

192.168.50.132   kubernetes.io/hostname=192.168.50.132   Ready

192.168.50.133   kubernetes.io/hostname=192.168.50.133   Ready

测验成功!

本文由pc28.am发布于pc28.am神测网,转载请注明出处:下安装入门级别的Kubernetes集群,操作系统本地安

上一篇:文件下载,使用全称 下一篇:没有了
猜你喜欢
热门排行
精彩图文