成都创新互联网站制作重庆分公司

ubuntu16.04下安装kubernetes1.6(二)-创新互联

4.3 安装etcd

在master上安装etcd,本文对应的是192.168.100.20这台机器

你所需要的网站建设服务,我们均能行业靠前的水平为你提供.标准是产品质量的保证,主要从事网站设计制作、网站制作、企业网站建设、手机网站制作设计、网页设计、成都品牌网站建设、网页制作、做网站、建网站。创新互联拥有实力坚强的技术研发团队及素养的视觉设计专才。

下载etcd安装包

wget /tupian/20230522/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启动脚本

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

启动etcd

systemctl start etcd.service

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

在master上安装apiserver

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

wget /tupian/20230522/kubernetes-server-linux-amd64.tar.gz

解包,并将kubernetes/server/bin下的kube-apiserver,kube-controller-manager,kube-scheduler,kubectl,kubefed 复制到/usr/local/bin下

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

制作apiserver ,controller-manager,scheduler的启动脚本

apiserver 启动脚本

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

[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

启动服务

systemctl start apiserver.service

controller-manager启动脚本

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

[Unit]

Description=Kubernetes Controller Manager

Documentation=/tupian/20230522/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

启动服务

systemctl start controller-manager.service

scheduler启动脚本

cat scheduler.sh

#!bin/sh

KUBE_LOGTOSTDERR=true

KUBE_LOG_LEVEL=4

KUBE_MASTER=192.168.100.20:8080

cat ?

[Unit]

Description=Kubernetes Scheduler

Documentation=/tupian/20230522/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

启动服务systemctl start scheduler.service

4.5 安装kubelet,kube-proxy

这两个组件安装在minion端,将在master下载的kubernetes-server-linux-amd64.tar.gz解压后的kubernetes/server/bin下的kubelet,kube-proxy复制到minion的/usr/local/bin下

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

制作启动脚本

kubelet启动脚本

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 ?

[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

启动服务

systemctl start kubelet.service

kube-proxy启动脚本

cat proxy.sh

#!/bin/sh

KUBE_LOGTOSTDERR=true

KUBE_LOG_LEVEL=4

KUBE_SERVERS=http://192.168.100.20:8080

cat ?

[Unit]

Description=Kubernetes Proxy

# the proxy crashes if etcd isn't reachable.

# /tupian/20230522/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

启动服务systemctl start proxy.service


当前题目:ubuntu16.04下安装kubernetes1.6(二)-创新互联
URL网址:http://cxhlcq.com/article/ipscj.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部