溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

ubuntu 16.04下安裝kubernetes1.6(二)

發(fā)布時(shí)間:2020-08-08 18:37:07 來(lái)源:ITPUB博客 閱讀:143 作者:wang_0720 欄目:云計(jì)算

4.3 安裝etcd

在master上安裝etcd,本文對(duì)應(yīng)的是192.168.100.20這臺(tái)機(jī)器

下載etcd安裝包

wget https://github.com/coreos/etcd/releases/download/v3.2.7/etcd-v3.2.7-linux-amd64.tar.gz

解包,將etcd-v3.2.7-linux-amd64下的etcd,etcdctl到/usr/local/bin目錄下

cp etcd-v3.2.7-linux-amd64/{etcd,etcdctl} /usr/local/bin

制作etcd啟動(dòng)腳本

cat etcd.sh

#!/bin/sh

ETCD_ADDR=http://0.0.0.0:2379

ETCD_DATA_DIR=/var/lib/etcd

ETCD_NAME=kubernetes

! test -d $ETCD_DATA_DIR && mkdir -p $ETCD_DATA_DIR

cat ? << EOF >/usr/lib/systemd/system/etcd.service

[Unit]

Description=Etcd Server

[Service]

ExecStart=/usr/local/bin/etcd --listen-client-urls='$ETCD_ADDR' --advertise-client-urls='$ETCD_ADDR'

[Install]

WantedBy=multi-user.target

EOF

systemctl daemon-reload

systemctl enable etcd

systemctl start etcd

啟動(dòng)etcd

systemctl start etcd.service

4.4 安裝apiserver,controller-manager,scheduler,kubectl

在master上安裝apiserver

apiserver,controller-manager,sheduler等組件都在kubernetes包中,所以下載kubernetes包即可

wget https://storage.googleapis.com/kubernetes-release/release/v1.6.10/kubernetes-server-linux-amd64.tar.gz

解包,并將kubernetes/server/bin下的kube-apiserver,kube-controller-manager,kube-scheduler,kubectl,kubefed 復(fù)制到/usr/local/bin下

cp kubernetes/server/bin/{kube-apiserver,kube-controller-manager,kube-scheduler,kubectl,kubefed} /usr/local/bin

制作apiserver ,controller-manager,scheduler的啟動(dòng)腳本

apiserver 啟動(dòng)腳本

cat apiserver.sh

#!/bin/sh

KUBE_LOGTOSTDERR=true

KUBE_LOG_LEVEL=2

KUBE_ETCD_SERVERS=http://192.168.100.20:2379

KUBE_CLUSTER_IP=10.10.10.0/24

INSECURE_BIND_ADDR=0.0.0.0

INSECURE_PORT=8080

LOG_DIR=/var/log/kubernetes

cat</usr/lib/systemd/system/apiserver.service

[Unit]

Description=Kubernetes API Server

After=network.target

After=etcd.service

[Service]

ExecStart=/usr/local/bin/kube-apiserver  \\

--logtostderr=${KUBE_LOGTOSTDERR} \\

--v=${KUBE_LOG_LEVEL} \\

--log-dir='${LOG_DIR}' \\

--etcd_servers=${KUBE_ETCD_SERVERS} \\

--service-cluster-ip-range=${KUBE_CLUSTER_IP} \\

--service-node-port-range=1-65535 \\

--admission_control=NamespaceLifecycle,LimitRanger,SecurityContextDeny,ResourceQuota \\

--insecure-bind-address=${INSECURE_BIND_ADDR} \\

--insecure-port=${INSECURE_PORT}

Restart=on-failure

[Install]

WantedBy=multi-user.target

EOF

systemctl daemon-reload

systemctl enable apiserver

systemctl start apiserver

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

systemctl start apiserver.service

controller-manager啟動(dòng)腳本

cat controller-mananger.sh

#!/bin/sh

KUBE_LOGTOSTDERR=true

KUBE_LOG_LEVEL=4kubernetes-server-linux-amd64.tar.gz

KUBE_MASTER=192.168.100.20:8080

cat </usr/lib/systemd/system/controller-manager.service

[Unit]

Description=Kubernetes Controller Manager

Documentation=https://github.com/GoogleCloudPlatform/kubernetes

After=network.target

After=apiserver.service

[Service]

ExecStart=/usr/local/bin/kube-controller-manager \\

--logtostderr=${KUBE_LOGTOSTDERR} \\

--v=${KUBE_LOG_LEVEL} \\

--log-dir="/var/log/controller" \\

--master=${KUBE_MASTER} \\

--service-cluster-ip-range=10.10.10.0/24

Restart=on-failure

[Install]

WantedBy=multi-user.target

EOF

systemctl daemon-reload

systemctl enable controller-manager

systemctl start controller-manager

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

systemctl start controller-manager.service

scheduler啟動(dòng)腳本

cat scheduler.sh

#!bin/sh

KUBE_LOGTOSTDERR=true

KUBE_LOG_LEVEL=4

KUBE_MASTER=192.168.100.20:8080

cat ?</usr/lib/systemd/system/scheduler.service

[Unit]

Description=Kubernetes Scheduler

Documentation=https://github.com/GoogleCloudPlatform/kubernetes

[Service]

ExecStart=/usr/local/bin/kube-scheduler \\

--logtostderr=${KUBE_LOGTOSTDERR} \\

--v=${KUBE_LOG_LEVEL} \\

--master=${KUBE_MASTER} \\

--log-dir='/var/log/scheduler'

Restart=on-failure

[Install]

WantedBy=multi-user.target

EOF

systemctl daemon-reload

systemctl enable scheduler

systemctl start scheduler

啟動(dòng)服務(wù)systemctl start scheduler.service

4.5 安裝kubelet,kube-proxy

這兩個(gè)組件安裝在minion端,將在master下載的kubernetes-server-linux-amd64.tar.gz解壓后的kubernetes/server/bin下的kubelet,kube-proxy復(fù)制到minion的/usr/local/bin下

cp kubernetes/server/bin/{kubelet,kube-proxy} /usr/local/bin

制作啟動(dòng)腳本

kubelet啟動(dòng)腳本

cat kubelet.sh

#!/bin/sh

KUBE_LOGTOSTDERR=true

KUBE_LOG_LEVEL=4

KUBE_SERVERS=http://192.168.100.20:8080

MINION_HOSTNAME=192.168.100.93

cat ?</usr/lib/systemd/system/kubelet.service

[Unit]

Description=Kubernetes Kubelet

After=docker.socket cadvisor.service

Requires=docker.socket

[Service]

ExecStart=/usr/local/bin/kubelet \\

--logtostderr=${KUBE_LOGTOSTDERR} \\

--v=${KUBE_LOG_LEVEL} \\

--api_servers=${KUBE_SERVERS} \\

--hostname_override=${MINION_HOSTNAME} \\

--cluster-dns=10.10.10.10 \\

--cluster-domain=cluster.local \\

--allow-privileged=true \\

--pod-infra-container-image=registry:5000/pause-amd64:3.0

Restart=on-failure

[Install]

WantedBy=multi-user.target

EOF

systemctl daemon-reload

systemctl enable kubelet

systemctl start kubelet

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

systemctl start kubelet.service

kube-proxy啟動(dòng)腳本

cat proxy.sh

#!/bin/sh

KUBE_LOGTOSTDERR=true

KUBE_LOG_LEVEL=4

KUBE_SERVERS=http://192.168.100.20:8080

cat ?</usr/lib/systemd/system/proxy.service

[Unit]

Description=Kubernetes Proxy

# the proxy crashes if etcd isn't reachable.

# https://github.com/GoogleCloudPlatform/kubernetes/issues/1206

After=network.target

[Service]

ExecStart=/usr/local/bin/kube-proxy \\

--logtostderr=${KUBE_LOGTOSTDERR} \\

--v=${KUBE_LOG_LEVEL} \\

--master=${KUBE_SERVERS}

Restart=on-failure

[Install]

WantedBy=multi-user.target

EOF

systemctl daemon-reload

systemctl enable proxy

systemctl start proxy

啟動(dòng)服務(wù)systemctl start proxy.service

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI