真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

Kubernetes中怎么集成docker

Kubernetes中怎么集成docker,針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。

創(chuàng)新互聯(lián)公司于2013年創(chuàng)立,先為渝北等服務(wù)建站,渝北等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢(xún)服務(wù)。為渝北企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問(wèn)題。

K8s 是一個(gè)容器集群管理系統(tǒng),提供資源調(diào)度、均衡容災(zāi)、服務(wù)注冊(cè)、動(dòng)態(tài)擴(kuò)縮容等功能。

Kubernetes組件介紹:

etcd:存儲(chǔ)Kubernetes信息、存儲(chǔ)各種業(yè)務(wù)容器信息等,存儲(chǔ)flannel網(wǎng)絡(luò)配置信息,供各節(jié)點(diǎn)協(xié)調(diào)。就是kubernetes的數(shù)據(jù)庫(kù),

flannel :用于多容器之間跨主機(jī)網(wǎng)絡(luò)通信

kube-apiserver:k8s的管理接口

kube-controller-manager:執(zhí)行Kubernetes服務(wù)

kube-scheduler:容器的啟動(dòng)、遷移、擴(kuò)容縮減調(diào)度

kubelet:對(duì)容器的實(shí)際操作者

kube-proxy :對(duì)容器網(wǎng)絡(luò)反向代理

準(zhǔn)備:

1.關(guān)閉centos7的防火墻firewalld

$ systemctl stop firewalld

$ systemctl disable firewalld

2.安裝NTP并確保啟用和運(yùn)行

$ yum -y install ntp

$ systemctl start ntpd

$ systemctl enable ntpd

配置Kubernetes Master:

在master上執(zhí)行以下步驟

1.通過(guò)yum安裝etcd和Kubernetes:

$ yum -y install etcd kubernetes

2.配置etcd監(jiān)聽(tīng)/etc/etcd/etcd.conf中的所有地址:

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://localhost:2379"

3.配置Kubernetes接口服務(wù),/etc/kubernetes/apiserver

KUBE_API_ADDRESS="--address=0.0.0.0"

KUBE_API_PORT="--port=8080"

KUBELET_PORT="--kubelet_port=10250"

KUBE_ETCD_SERVERS="--etcd_servers=http://127.0.0.1:2379"

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

4.啟動(dòng)并啟用etcd、kube-apiserver、kube- controllermanager和kube-scheduler:

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

systemctl restart $SERVICES

systemctl enable $SERVICES

systemctl status $SERVICES

done

5.在etcd中定義flannel配置

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

6.檢查節(jié)點(diǎn)狀態(tài),沒(méi)有任何信息因?yàn)檫€沒(méi)啟動(dòng)

$ kubectl get nodes

NAME LABELS STATUS

配置Kubernetes Minions節(jié)點(diǎn):

以下步驟在minion1、minion2和minion3上執(zhí)行

1.安裝flannel和Kubernetes

$ yum -y install flannel kubernetes

2.配置用于flannel服務(wù)的etcd

# change the hostname to this host’s IP address

KUBELET_HOSTNAME="--hostname_override=192.168.204.31"

KUBELET_API_SERVER="--api_servers=http://192.168.204.30:8080"

KUBELET_ARGS=""

minion2:

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.204.32"

KUBELET_API_SERVER="--api_servers=http://192.168.204.30:8080"

KUBELET_ARGS=""

minion3:

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.204.33"

KUBELET_API_SERVER="--api_servers=http://192.168.204.30:8080"

KUBELET_ARGS=""

5.啟動(dòng)kube-proxy、kubelet、docker和flanneld服務(wù):

$ for SERVICES in kube-proxy kubelet docker flanneld; do

systemctl restart $SERVICES

systemctl enable $SERVICES

systemctl status $SERVICES

done

6.檢查每個(gè)minion上有docker0和flannel0。在flannel0上可以獲得不同范圍的IP地址

minion1:

$ ip a | grep flannel | grep inet

inet 172.17.59.0/16 scope global flannel0

minion2:

$ ip a | grep flannel | grep inet

inet 172.17.19.0/16 scope global flannel0

minion3:

$ ip a | grep flannel | grep inet

inet 172.17.80.0/16 scope global flannel0

7.檢查節(jié)點(diǎn)狀態(tài)

$ kubectl get nodes

NAME STATUS AGE

192.168.204.31 Ready 8m

192.168.204.32 Ready 7m

192.168.204.33 Ready 7m

Kubernetes集群已經(jīng)配置并運(yùn)行了。開(kāi)始配置 pods

配置 pods(Containers)

1.在Kubernetes master中定義一個(gè)yaml文件,使用kubectl命令根據(jù)定義創(chuàng)建pods。創(chuàng)建一個(gè)MySQL.yaml文件:

$ mkdir pods

$ cd pods

$ vim mysql.yaml

2.添加以下幾行:

apiVersion: v1

kind: Pod

metadata:

name: mysql

labels:

name: mysql

spec:

containers:

- resources:

limits :

cpu: 1

image: mysql

name: mysql

env:

- name: MYSQL_ROOT_PASSWORD

# change this

value: yourpassword

ports:

- containerPort: 3306

name: mysql

3.創(chuàng)建pod

$ kubectl create -f mysql.yaml

4.驗(yàn)證pod的創(chuàng)建和運(yùn)行:

$ kubectl get pods

POD IP CONTAINER(S) IMAGE(S) HOST LABELS STATUS CREATED

mysql 172.17.38.2 mysql mysql 192.168.204.32/192.168.204.32 name=mysql Running 3 hours

Kubernetes在192.168.204.32創(chuàng)建了一個(gè)Docker容器?,F(xiàn)在需要?jiǎng)?chuàng)建一個(gè)服務(wù),讓其他pods訪問(wèn)已知端口和主機(jī)上的mysql數(shù)據(jù)庫(kù)。

創(chuàng)建服務(wù)

1.在192.168.204.32里面有一個(gè)MySQL pod,定義一個(gè) mysql-service.yaml

apiVersion: v1

kind: Service

metadata:

labels:

name: mysql

name: mysql

spec:

externalIPs:

- 192.168.204.32

ports:

# 這個(gè)端口是該服務(wù)的端口

- port: 3306

# label keys and values that must match in order to receive traffic for this service

selector:

name: mysql

2.運(yùn)行服務(wù)

$ kubectl create -f mysql-service.yaml

報(bào)異常:Error from server (BadRequest): error when creating "mysql.yaml": Pod in version "v1" cannot be handled as a Pod: [pos 177]: json: expect char '"' but got char '1'

3. 查看服務(wù),10.254.x.x是定義在/etc/kubernetes/apiserver的 Kubernetes內(nèi)部IP地址,所以定義了連接到外部的網(wǎng)絡(luò)ip:

$ kubectl get services

NAME LABELS SELECTOR IP PORT(S)

kubernetes component=apiserver,provider=kubernetes 10.254.0.2 443/TCP

kubernetes-ro component=apiserver,provider=kubernetes 10.254.0.1 80/TCP

mysql name=mysql name=mysql 10.254.13.156 3306/TCP

                                                    192.168.204.32

4.外部連接數(shù)據(jù)庫(kù)

$ mysql -uroot -p -h292.168.204.32

MySQL [(none)]> show variables like '%version%';

+-------------------------+------------------------------+

| Variable_name | Value |

+-------------------------+------------------------------+

| innodb_version | 5.6.24 |

| protocol_version | 10 |

| slave_type_conversions | |

| version | 5.6.24 |

| version_comment | MySQL Community Server (GPL) |

| version_compile_machine | x86_64 |

| version_compile_os | Linux |

+-------------------------+------------------------------+

7 rows in set (0.01 sec)

關(guān)于Kubernetes中怎么集成docker問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒(méi)有解開(kāi),可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識(shí)。


新聞標(biāo)題:Kubernetes中怎么集成docker
轉(zhuǎn)載來(lái)源:
http://weahome.cn/article/ipcdsh.html

其他資訊

在線咨詢(xún)

微信咨詢(xún)

電話咨詢(xún)

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部