日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

基于Kubernetes构建Docker集群管理详解

發(fā)布時(shí)間:2025/7/25 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 基于Kubernetes构建Docker集群管理详解 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

from: 基于Kubernetes構(gòu)建Docker集群管理詳解

Kubernetes是Google開(kāi)源的容器集群管理系統(tǒng),基于Docker構(gòu)建一個(gè)容器的調(diào)度服務(wù),提供資源調(diào)度、均衡容災(zāi)、服務(wù)注冊(cè)、動(dòng)態(tài)擴(kuò)縮容等功能套件,目前最新版本為0.6.2。本文介紹如何基于CentOS7.0構(gòu)建Kubernetes平臺(tái)。


在正式介紹之前,大家有必要先理解Kubernetes幾個(gè)核心概念及其承擔(dān)的功能。以下為Kubernetes的架構(gòu)設(shè)計(jì)圖:

1. Pods

在Kubernetes系統(tǒng)中,調(diào)度的最小顆粒不是單純的容器,而是抽象成一個(gè)Pod,Pod是一個(gè)可以被創(chuàng)建、銷毀、調(diào)度、管理的最小的部署單元。比如一個(gè)或一組容器。

2. Replication Controllers

Replication Controller是Kubernetes系統(tǒng)中最有用的功能,實(shí)現(xiàn)復(fù)制多個(gè)Pod副本,往往一個(gè)應(yīng)用需要多個(gè)Pod來(lái)支撐,并且可以保證其復(fù)制的副本數(shù),即使副本所調(diào)度分配的宿主機(jī)出現(xiàn)異常,通過(guò)Replication Controller可以保證在其它主宿機(jī)啟用同等數(shù)量的Pod。Replication Controller可以通過(guò)repcon模板來(lái)創(chuàng)建多個(gè)Pod副本,同樣也可以直接復(fù)制已存在Pod,需要通過(guò)Label selector來(lái)關(guān)聯(lián)。

3. Services

Services是Kubernetes最外圍的單元,通過(guò)虛擬一個(gè)訪問(wèn)IP及服務(wù)端口,可以訪問(wèn)我們定義好的Pod資源,目前的版本是通過(guò)iptables的nat轉(zhuǎn)發(fā)來(lái)實(shí)現(xiàn),轉(zhuǎn)發(fā)的目標(biāo)端口為Kube_proxy生成的隨機(jī)端口,目前只提供GOOGLE云上的訪問(wèn)調(diào)度,如GCE。如果與我們自建的平臺(tái)進(jìn)行整合?請(qǐng)關(guān)注下篇《kubernetes與HECD架構(gòu)的整合》文章。

4. Labels

Labels是用于區(qū)分Pod、Service、Replication Controller的key/value鍵值對(duì),僅使用在Pod、Service、Replication Controller之間的關(guān)系識(shí)別,但對(duì)這些單元本身進(jìn)行操作時(shí)得使用name標(biāo)簽。

5. Proxy

Proxy不但解決了同一主宿機(jī)相同服務(wù)端口沖突的問(wèn)題,還提供了Service轉(zhuǎn)發(fā)服務(wù)端口對(duì)外提供服務(wù)的能力,Proxy后端使用了隨機(jī)、輪循負(fù)載均衡算法。

說(shuō)說(shuō)個(gè)人一點(diǎn)看法,目前Kubernetes 保持一周一小版本、一個(gè)月一大版本的節(jié)奏,迭代速度極快,同時(shí)也帶來(lái)了不同版本操作方法的差異,另外官網(wǎng)文檔更新速度相對(duì)滯后及欠缺,給初學(xué)者帶來(lái)一定挑戰(zhàn)。在上游接入層官方側(cè)重點(diǎn)還放在GCE(Google Compute Engine)的對(duì)接優(yōu)化,針對(duì)個(gè)人私有云還未推出一套可行的接入解決方案。在v0.5版本中才引用service代理轉(zhuǎn)發(fā)的機(jī)制,且是通過(guò)iptables來(lái)實(shí)現(xiàn),在高并發(fā)下性能令人擔(dān)憂。但作者依然看好Kubernetes未來(lái)的發(fā)展,至少目前還未看到另外一個(gè)成體系、具備良好生態(tài)圈的平臺(tái),相信在V1.0時(shí)就會(huì)具備生產(chǎn)環(huán)境的服務(wù)支撐能力。

一、環(huán)境部署

1. 平臺(tái)版本說(shuō)明

  • Centos7.0 OS
  • Kubernetes V0.6.2
  • etcd version 0.4.6
  • Docker version 1.3.2
  • 2. 平臺(tái)環(huán)境說(shuō)明

    3. 環(huán)境安裝

    1)系統(tǒng)初始化工作(所有主機(jī))

    系統(tǒng)安裝-選擇[最小化安裝]

    # yum -y install wget ntpdate bind-utils
    # wget?http://mirror.centos.org/centos/7/extras/x86_64/Packages/epel-release-7-2.noarch.rpm
    # yum update

    CentOS 7.0默認(rèn)使用的是firewall作為防火墻,這里改為iptables防火墻(熟悉度更高,非必須)。

    1.1 關(guān)閉firewall:1.1、關(guān)閉firewall:

    # systemctl stop firewalld.service #停止firewall
    # systemctl disable firewalld.service #禁止firewall開(kāi)機(jī)啟動(dòng)

    1.2 安裝iptables防火墻

    # yum install iptables-services #安裝
    # systemctl start iptables.service #最后重啟防火墻使配置生效
    # systemctl enable iptables.service #設(shè)置防火墻開(kāi)機(jī)啟動(dòng)

    2)安裝Etcd(192.168.1.10主機(jī))

    # mkdir -p /home/install && cd /home/install ?
    # wget?https://github.com/coreos/etcd/releases/download/v0.4.6/etcd-v0.4.6-linux-amd64.tar.gz??
    # tar -zxvf etcd-v0.4.6-linux-amd64.tar.gz ?
    # cd etcd-v0.4.6-linux-amd64 ?
    # cp etcd* /bin/ ?
    # /bin/etcd -version ?
    etcd version 0.4.6?

    啟動(dòng)服務(wù)etcd服務(wù),如有提供第三方管理需求,另需在啟動(dòng)參數(shù)中添加“-cors='*'”參數(shù)。

    # mkdir /data/etcd ?
    # /bin/etcd -name etcdserver -peer-addr 192.168.1.10:7001 -addr 192.168.1.10:4001 -data-dir /data/etcd -peer-bind-addr 0.0.0.0:7001 -bind-addr 0.0.0.0:4001 &

    配置etcd服務(wù)防火墻,其中4001為服務(wù)端口,7001為集群數(shù)據(jù)交互端口。

    # iptables -I INPUT -s 192.168.1.0/24 -p tcp --dport 4001 -j ACCEPT
    # iptables -I INPUT -s 192.168.1.0/24 -p tcp --dport 7001 -j ACCEPT

    3)安裝Kubernetes(涉及所有Master、Minion主機(jī))

    通過(guò)yum源方式安裝,默認(rèn)將安裝etcd, docker, and cadvisor相關(guān)包。

    # curl?https://copr.fedoraproject.org/coprs/eparis/kubernetes-epel-7/repo/epel-7/eparis-kubernetes-epel-7-epel-7.repo?-o /etc/yum.repos.d/eparis-kubernetes-epel-7-epel-7.repo
    #yum -y install kubernetes

    升級(jí)至v0.6.2,覆蓋bin文件即可,方法如下:

    # mkdir -p /home/install && cd /home/install
    # wgethttps://github.com/GoogleCloudPlatform/kubernetes/releases/download/v0.6.2/kubernetes.tar.gz
    # tar -zxvf kubernetes.tar.gz
    # tar -zxvf kubernetes/server/kubernetes-server-linux-amd64.tar.gz
    # cp kubernetes/server/bin/kube* /usr/bin

    校驗(yàn)安裝結(jié)果,出版以下信息說(shuō)明安裝正常。

    [root@SN2014-12-200 bin]# /usr/bin/kubectl version
    Client Version: version.Info{Major:"0", Minor:"6+", GitVersion:"v0.6.2", GitCommit:"729fde276613eedcd99ecf5b93f095b8deb64eb4", GitTreeState:"clean"}
    Server Version: &version.Info{Major:"0", Minor:"6+", GitVersion:"v0.6.2", GitCommit:"729fde276613eedcd99ecf5b93f095b8deb64eb4", GitTreeState:"clean"}

    4)Kubernetes配置(僅Master主機(jī))

    master運(yùn)行三個(gè)組件,包括apiserver、scheduler、controller-manager,相關(guān)配置項(xiàng)也只涉及這三塊。

    4.1【/etc/kubernetes/config】

    # Comma seperated list of nodes in the etcd cluster ?
    KUBE_ETCD_SERVERS="--etcd_servers=http://192.168.1.10:4001" ?
    # 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 privleged docker containers ?
    KUBE_ALLOW_PRIV="--allow_privileged=false" ?

    4.2【/etc/kubernetes/apiserver】

    # The address on the local server to listen to. ?
    KUBE_API_ADDRESS="--address=0.0.0.0" ?
    # The port on the local server to listen on. ?
    KUBE_API_PORT="--port=8080" ?
    # How the replication controller and scheduler find the kube-apiserver ?
    KUBE_MASTER="--master=192.168.1.200:8080" ?
    # Port minions listen on ?
    KUBELET_PORT="--kubelet_port=10250" ?
    # Address range to use for services ?
    KUBE_SERVICE_ADDRESSES="--portal_net=10.254.0.0/16" ?
    # Add you own! ?
    KUBE_API_ARGS=""

    4.3【/etc/kubernetes/controller-manager】

    # Comma seperated list of minions ?
    KUBELET_ADDRESSES="--machines= 192.168.1.201,192.168.1.202" ?
    # Add you own! ?
    KUBE_CONTROLLER_MANAGER_ARGS="" ?

    4.4【/etc/kubernetes/scheduler】

    # Add your own! ?
    KUBE_SCHEDULER_ARGS="" ?

    啟動(dòng)master側(cè)相關(guān)服務(wù)

    # systemctl daemon-reload
    # systemctl start kube-apiserver.service kube-controller-manager.service kube-scheduler.service
    # systemctl enable kube-apiserver.service kube-controller-manager.service kube-scheduler.service

    5)Kubernetes配置(僅minion主機(jī))

    minion運(yùn)行兩個(gè)組件,包括kubelet、proxy,相關(guān)配置項(xiàng)也只涉及這兩塊。

    Docker啟動(dòng)腳本更新

    # vi /etc/sysconfig/docker

    添加:-H tcp://0.0.0.0:2375,最終配置如下,以便以后提供遠(yuǎn)程API維護(hù)。

    OPTIONS=--selinux-enabled -H tcp://0.0.0.0:2375 -H fd://

    修改minion防火墻配置,通常master找不到minion主機(jī)多半是由于端口沒(méi)有連通。

    iptables -I INPUT -s 192.168.1.200 -p tcp --dport 10250 -j ACCEPT

    修改kubernetes minion端配置,以192.168.1.201主機(jī)為例,其它minion主機(jī)同理。

    5.1【/etc/kubernetes/config】

    # Comma seperated list of nodes in the etcd cluster ?
    KUBE_ETCD_SERVERS="--etcd_servers=http://192.168.1.10:4001" ?
    # 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 privleged docker containers ?
    KUBE_ALLOW_PRIV="--allow_privileged=false" ?

    5.2【/etc/kubernetes/kubelet】

    ### ?
    # 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.1.201" ?
    # Add your own! ?
    KUBELET_ARGS="" ?

    5.3【/etc/kubernetes/proxy】

    KUBE_PROXY_ARGS="" ?

    啟動(dòng)kubernetes服務(wù)

    # systemctl daemon-reload
    # systemctl enable docker.service kubelet.service kube-proxy.service
    # systemctl start docker.service kubelet.service kube-proxy.service

    3.校驗(yàn)安裝(在master主機(jī)操作,或可訪問(wèn)master主機(jī)8080端口的client api主機(jī))

    1) kubernetes常用命令

    # kubectl get minions ? ?#查查看minion主機(jī)
    # kubectl get pods ? ?#查看pods清單
    # kubectl get services 或 kubectl get services -o json ? ?#查看service清單
    # kubectl get replicationControllers ? ?#查看replicationControllers清單
    # for i in `kubectl get pod|tail -n +2|awk '{print $1}'`; do kubectl delete pod $i; done ? ?#刪除所有pods

    或者通過(guò)Server api for REST方式(推薦,及時(shí)性更高):

    # curl -s -L?http://192.168.1.200:8080/api/v1beta1/version?| python -mjson.tool ? ?#查看kubernetes版本
    # curl -s -L?http://192.168.1.200:8080/api/v1beta1/pods?| python -mjson.tool ? ?#查看pods清單
    # curl -s -L?http://192.168.1.200:8080/api/v1beta1/replicationControllers?| python -mjson.tool ? ?#查看replicationControllers清單
    # curl -s -L?http://192.168.1.200:8080/api/v1beta1/minions?| python -m json.tool ? ?#查查看minion主機(jī)
    # curl -s -L?http://192.168.1.200:8080/api/v1beta1/services?| python -m json.tool ? ?#查看service清單

    注:在新版Kubernetes中,所有的操作命令都整合至kubectl,包括kubecfg、kubectl.sh、kubecfg.sh等

    2)創(chuàng)建測(cè)試pod單元

    # /home/kubermange/pods && cd /home/kubermange/pods

    # vi apache-pod.json

    { ?
    ? "id": "fedoraapache", ?
    ? "kind": "Pod", ?
    ? "apiVersion": "v1beta1", ?
    ? "desiredState": { ?
    ? ? "manifest": { ?
    ? ? ? "version": "v1beta1", ?
    ? ? ? "id": "fedoraapache", ?
    ? ? ? "containers": [{ ?
    ? ? ? ? "name": "fedoraapache", ?
    ? ? ? ? "image": "fedora/apache", ?
    ? ? ? ? "ports": [{ ?
    ? ? ? ? ? "containerPort": 80, ?
    ? ? ? ? ? "hostPort": 8080 ?
    ? ? ? ? }] ?
    ? ? ? }] ?
    ? ? } ?
    ? }, ?
    ? "labels": { ?
    ? ? "name": "fedoraapache" ?
    ? } ?
    } ?

    # kubectl create -f apache-pod.json

    # kubectl get pod

    NAME ? ? ? ? ? ? ? ?IMAGE(S) ? ? ? ? ? ?HOST ? ? ? ? ? ? ? ?LABELS ? ? ? ? ? ? ?STATUS
    fedoraapache ? ? ? ?fedora/apache ? ? ? 192.168.1.202/ ? ? ?name=fedoraapache ? Running

    啟動(dòng)瀏覽器訪問(wèn)http://192.168.1.202:8080/,對(duì)應(yīng)的服務(wù)端口切記在iptables中已添加。效果圖如下:

    觀察kubernetes在etcd中的數(shù)據(jù)存儲(chǔ)結(jié)構(gòu)

    觀察單個(gè)pods的數(shù)據(jù)存儲(chǔ)結(jié)構(gòu),以json的格式存儲(chǔ)。

    二、實(shí)戰(zhàn)操作

    任務(wù):通過(guò)Kubernetes創(chuàng)建一個(gè)LNMP架構(gòu)的服務(wù)集群,以及觀察其負(fù)載均衡,涉及鏡像“yorko/webserver”已經(jīng)push至registry.hub.docker.com,大家可以通過(guò)“docker pull yorko/webserver”下載。

    # mkdir -p /home/kubermange/replication && mkdir -p /home/kubermange/service
    # cd /home/kubermange/replication?

    1. 創(chuàng)建一個(gè)replication,本例直接在replication模板中創(chuàng)建pod并復(fù)制,也可獨(dú)立創(chuàng)建pod再通過(guò)replication來(lái)復(fù)制。

    【replication/lnmp-replication.json】

    { ?
    ? "id": "webserverController", ?
    ? "kind": "ReplicationController", ?
    ? "apiVersion": "v1beta1", ?
    ? "labels": {"name": "webserver"}, ?
    ? "desiredState": { ?
    ? ? "replicas": 2, ?
    ? ? "replicaSelector": {"name": "webserver_pod"}, ?
    ? ? "podTemplate": { ?
    ? ? ? "desiredState": { ?
    ? ? ? ? ?"manifest": { ?
    ? ? ? ? ? ?"version": "v1beta1", ?
    ? ? ? ? ? ?"id": "webserver", ?
    ? ? ? ? ? ?"volumes": [ ?
    ? ? ? ? ? ? ?{"name":"httpconf", "source":{"hostDir":{"path":"/etc/httpd/conf"}}}, ?
    ? ? ? ? ? ? ?{"name":"httpconfd", "source":{"hostDir":{"path":"/etc/httpd/conf.d"}}}, ?
    ? ? ? ? ? ? ?{"name":"httproot", "source":{"hostDir":{"path":"/data"}}} ?
    ? ? ? ? ? ? ], ?
    ? ? ? ? ? ?"containers": [{ ?
    ? ? ? ? ? ? ?"name": "webserver", ?
    ? ? ? ? ? ? ?"image": "yorko/webserver", ?
    ? ? ? ? ? ? ?"command": ["/bin/sh", "-c", "/usr/bin/supervisord -c /etc/supervisord.conf"], ?
    ? ? ? ? ? ? ?"volumeMounts": [ ?
    ? ? ? ? ? ? ? ?{"name":"httpconf", "mountPath":"/etc/httpd/conf"}, ?
    ? ? ? ? ? ? ? ?{"name":"httpconfd", "mountPath":"/etc/httpd/conf.d"}, ?
    ? ? ? ? ? ? ? ?{"name":"httproot", "mountPath":"/data"} ?
    ? ? ? ? ? ? ? ], ?
    ? ? ? ? ? ? ?"cpu": 100, ?
    ? ? ? ? ? ? ?"memory": 50000000, ?
    ? ? ? ? ? ? ?"ports": [{ ?
    ? ? ? ? ? ? ? ?"containerPort": 80, ?
    ? ? ? ? ? ? ?},{ ?
    ? ? ? ? ? ? ? ?"containerPort": 22, ?
    ? ? ? ? ? ? }] ?
    ? ? ? ? ? ?}] ?
    ? ? ? ? ?} ?
    ? ? ? ?}, ?
    ? ? ? ?"labels": {"name": "webserver_pod"}, ?
    ? ? ? }, ?
    ? } ?
    } ?

    執(zhí)行創(chuàng)建命令

    #kubectl create -f lnmp-replication.json

    觀察生成的pod副本清單:

    [root@SN2014-12-200 replication]# kubectl get pod

    NAME ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? IMAGE(S) ? ? ? ? ? ?HOST ? ? ? ? ? ? ? ?LABELS ? ? ? ? ? ? ? STATUS
    84150ab7-89f8-11e4-970d-000c292f1620 ? yorko/webserver ? ? 192.168.1.202/ ? ? ?name=webserver_pod ? Running
    84154ed5-89f8-11e4-970d-000c292f1620 ? yorko/webserver ? ? 192.168.1.201/ ? ? ?name=webserver_pod ? Running
    840beb1b-89f8-11e4-970d-000c292f1620 ? yorko/webserver ? ? 192.168.1.202/ ? ? ?name=webserver_pod ? Running
    84152d93-89f8-11e4-970d-000c292f1620 ? yorko/webserver ? ? 192.168.1.202/ ? ? ?name=webserver_pod ? Running
    840db120-89f8-11e4-970d-000c292f1620 ? yorko/webserver ? ? 192.168.1.201/ ? ? ?name=webserver_pod ? Running
    8413b4f3-89f8-11e4-970d-000c292f1620 ? yorko/webserver ? ? 192.168.1.201/ ? ? ?name=webserver_pod ? Running

    2.創(chuàng)建一個(gè)service,通過(guò)selector指定 "name": "webserver_pod"與pods關(guān)聯(lián)。

    【service/lnmp-service.json】

    { ?
    ? "id": "webserver", ?
    ? "kind": "Service", ?
    ? "apiVersion": "v1beta1", ?
    ? "selector": { ?
    ? ? "name": "webserver_pod", ?
    ? }, ?
    ? "protocol": "TCP", ?
    ? "containerPort": 80, ?
    ? "port": 8080 ?
    } ?

    執(zhí)行創(chuàng)建命令:

    # kubectl create -f lnmp-service.json

    登錄minion主機(jī)(192.168.1.201),查詢主宿機(jī)生成的iptables轉(zhuǎn)發(fā)規(guī)則(最后一行)

    # iptables -nvL -t nat

    Chain KUBE-PROXY (2 references)
    pkts bytes target ? ? prot opt in ? ? out ? ? source ? ? ? ? ? ? ? destination ? ? ? ?
    ? ? 2 ? 120 REDIRECT ? tcp ?-- ?* ? ? ?* ? ? ? 0.0.0.0/0 ? ? ? ? ? ?10.254.102.162 ? ? ? /* kubernetes */ tcp dpt:443 redir ports 47700
    ? ? 1 ? ?60 REDIRECT ? tcp ?-- ?* ? ? ?* ? ? ? 0.0.0.0/0 ? ? ? ? ? ?10.254.28.74 ? ? ? ? /* kubernetes-ro */ tcp dpt:80 redir ports 60099
    ? ? 0 ? ? 0 REDIRECT ? tcp ?-- ?* ? ? ?* ? ? ? 0.0.0.0/0 ? ? ? ? ? ?10.254.216.51 ? ? ? ?/* webserver */ tcp dpt:8080 redir ports 40689

    訪問(wèn)測(cè)試,http://192.168.1.201:40689/info.php,刷新瀏覽器發(fā)現(xiàn)proxy后端的變化,默認(rèn)為隨機(jī)輪循算法。

    三、測(cè)試過(guò)程

    1.pods自動(dòng)復(fù)制、銷毀測(cè)試,觀察Kubernetes自動(dòng)保持副本數(shù)(6份)

    刪除replicationcontrollers中一個(gè)副本fedoraapache

    [root@SN2014-12-200 pods]# kubectl delete pods fedoraapache

    I1219 23:59:39.305730 ? ?9516 restclient.go:133] Waiting for completion of operation 142530

    fedoraapache

    [root@SN2014-12-200 pods]# kubectl get pods

    NAME ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? IMAGE(S) ? ? ? ? ? ?HOST ? ? ? ? ? ? ? ?LABELS ? ? ? ? ? ? ?STATUS
    5d70892e-8794-11e4-970d-000c292f1620 ? fedora/apache ? ? ? 192.168.1.201/ ? ? ?name=fedoraapache ? Running
    5d715e56-8794-11e4-970d-000c292f1620 ? fedora/apache ? ? ? 192.168.1.202/ ? ? ?name=fedoraapache ? Running
    5d717f8d-8794-11e4-970d-000c292f1620 ? fedora/apache ? ? ? 192.168.1.202/ ? ? ?name=fedoraapache ? Running
    5d71c584-8794-11e4-970d-000c292f1620 ? fedora/apache ? ? ? 192.168.1.201/ ? ? ?name=fedoraapache ? Running
    5d71a494-8794-11e4-970d-000c292f1620 ? fedora/apache ? ? ? 192.168.1.202/ ? ? ?name=fedoraapache ? Running

    #自動(dòng)生成出一個(gè)副本,保持6份的效果

    [root@SN2014-12-200 pods]# kubectl get pods

    NAME ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? IMAGE(S) ? ? ? ? ? ?HOST ? ? ? ? ? ? ? ?LABELS ? ? ? ? ? ? ?STATUS
    5d717f8d-8794-11e4-970d-000c292f1620 ? fedora/apache ? ? ? 192.168.1.202/ ? ? ?name=fedoraapache ? Running
    5d71c584-8794-11e4-970d-000c292f1620 ? fedora/apache ? ? ? 192.168.1.201/ ? ? ?name=fedoraapache ? Running
    5d71a494-8794-11e4-970d-000c292f1620 ? fedora/apache ? ? ? 192.168.1.202/ ? ? ?name=fedoraapache ? Running
    2a8fb993-8798-11e4-970d-000c292f1620 ? fedora/apache ? ? ? 192.168.1.201/ ? ? ?name=fedoraapache ? Running
    5d70892e-8794-11e4-970d-000c292f1620 ? fedora/apache ? ? ? 192.168.1.201/ ? ? ?name=fedoraapache ? Running
    5d715e56-8794-11e4-970d-000c292f1620 ? fedora/apache ? ? ? 192.168.1.202/ ? ? ?name=fedoraapache ? Running

    2.測(cè)試不同角色模塊中的hostPort

    1)pod中hostPort為空,而replicationcontrollers為指定端口,則異常;兩側(cè)都指定端口,相同或不同時(shí)都異常;pod的hostport為指定,另replicationcon為空,則正常;pod的hostport為空,另replicationcon為空,則正常;結(jié)論是在replicationcontrollers場(chǎng)景不能指定hostport,否則異常,待持續(xù)測(cè)試。

    2)結(jié)論:在replicationcontronllers.json中,"replicaSelector": {"name": "webserver_pod"}要與"labels": {"name": "webserver_pod"}以及service中的"selector": {"name": "webserver_pod"}保持一致;

    下篇文章中,劉天斯計(jì)劃介紹《Kubernetes與HECD架構(gòu)的整合》,敬請(qǐng)期待!

    參考文獻(xiàn):

    Kubernetes?fedora_manual_config.md

    kubernetes/DESIGN.md

    Kubernetes系統(tǒng)架構(gòu)簡(jiǎn)介

    總結(jié)

    以上是生活随笔為你收集整理的基于Kubernetes构建Docker集群管理详解的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

    如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。