kubenetes安装

kubenetes安装,第1张

概述1.安装etcd 下载解压 wget https://github.com/etcd-io/etcd/releases/download/v2.1.0-rc.0/etcd-v2.1.0-rc.0-linux-amd64.tar.gz tar -xvf  etcd-v2.1.0-rc.0-linux-amd64.tar.gz cp etcd etcdctl  /usr/bin 1.1 配置servi

1.安装etcd

下载解压
wget https://github.com/etcd-io/etcd/releases/download/v2.1.0-rc.0/etcd-v2.1.0-rc.0-linux-amd64.tar.gz

tar -xvf  etcd-v2.1.0-rc.0-linux-amd64.tar.gz

cp etcd etcdctl  /usr/bin

1.1 配置service文件
/lib/systemd/system/etcd.service

[Unit]
Description=Etcd Server
After=network.target

[Service]
Type=simple
WorkingDirectory=/var/lib/etcd/
Environmentfile=/etc/etcd/etcd.conf
ExecStart=/usr/bin/etcd

[Install]
WantedBy=multi-user.target


1.2 创建相关文件夹(etcd配置文件不需要特殊指定,只创建文件夹即可)
mkdir -p /etc/etcd/
cd /etc/etcd/
touch etcd.conf

mkdir -p /var/lib/etcd/


检测是否安装成功
etcdctl ls

服务重新加载和启动
systemctl daemon-reload
systemctl enable etcd
systemctl start etcd

2.安装docker

apt-get update
apt-get install docker.io

修改docker镜像加速
vim /etc/docker/daemon.Json
添加下面的内容
{"registry-mirrors": ["https://s1qqahp3.mirror.aliyuncs.com"]}

查检是否安装成功
docker ps

3.安装kubenetes

老版本的kubenets里,包括二进制执行文件。但3版本以后就没了。因此为简单起建,实验中使用v1.3.0

master节点安装 kube-APIserver /kube-controller-manager /kube-scheduler
下载文件
复制相关文件到/usr/bin

3.1安装kube-APIserver

3.1.1service文件
cat /lib/systemd/system/kube-APIserver.service

[Unit]
Description=Kubernetes API Server
documentation=https://github.com/GoogleCloudplatform/kubernetes
After=etcd.service
Requires=etcd.service

[Service]
Environmentfile=/etc/kubernetes/APIserver
ExecStart=/usr/bin/kube-APIserver $KUBE_API_ARGS
Type=notify
limitNOfile=65536

[Install]
WantedBy=multi-user.target

3.1.2配置文件
cat /etc/kubernetes/APIserver
KUBE_API_ARGS="--etcd_servers=http://127.0.0.1:4001 --insecure-bind-address=0.0.0.0 --insecure-port=8080 --service-cluster-ip-range=169.169.0.0/16 --service-node-port-range=1-65535 --admission_control=namespacelifecycle,limitRanger,ResourceQuota --logtostderr=false --log-dir=/var/log/kubernetes --v=2"


3.2安装kube-controller-manager

3.2.1 service文件
cat /lib/systemd/system/kube-controller-manager.service
[Unit]
Description=Kubernetes Controller Manager
documentation=https://github.com/GoogleCloudplatform/kubernetes
After=kube-APIserver.service
Requires=kube-APIserver.service

[Service]
Environmentfile=/etc/kubernetes/controller-manager
ExecStart=/usr/bin/kube-controller-manager $KUBE_CONTRolLER_MANAGER_ARGS
Restart=on-failure
limitNOfile=65536

[Install]
WantedBy=multi-user.target

3.2.2 配置文件
cat /etc/kubernetes/controller-manager
KUBE_CONTRolLER_MANAGER_ARGS="--master=http://192.168.122.144:8080 --logtostderr=false --log-dir=/var/log/kubernetes --v=2"

3.3 安装kube-scheduler
3.3.1 servicey文件
cat /lib/systemd/system/kube-scheduler.service
[Unit]
Description=Kubernetes Scheduler
documentation=https://github.com/GoogleCloudplatform/kubernetes
After=kube-APIserver.service
Requires=kube-APIserver.service

[Service]
Environmentfile=/etc/kubernetes/scheduler
ExecStart=/usr/bin/kube-scheduler $KUBE_SCHEDulER_ARGS
Restart=on-failure
limitNOfile=65536

[Install]
WantedBy=multi-user.target

3.3.2配置文件
cat /etc/kubernetes/scheduler
KUBE_SCHEDulER_ARGS="--master=http://192.168.122.144:8080 --logtostderr=false --log-dir=/var/log/kubernetes --v=2"


3.4在node节点安装 kubelet

3.4.1 service文件
cat /lib/systemd/system/kubelet.service
[Unit]
Description=Kubernetes Kubelet Server
documentation=https://github.com/GoogleCloudplatform/kubernetes
After=docker.service
Requires=docker.service

[Service]
WorkingDirectory=/var/lib/kubelet
Environmentfile=/etc/kubernetes/kubelet
ExecStart=/usr/bin/kubelet $KUBELET_ARGS
Restart=on-failure

[Install]
WantedBy=multi-user.target

3.4.2配置文件
cat /etc/kubernetes/kubelet
KUBELET_ARGS="--API-servers=http://192.168.122.144:8080 --hostname-overrIDe=192.168.122.144 --logtostderr=false --log-dir=/var/log/kubernetes --v=2"

说明:  --hostname-overrIDe=192.168.122.144 指当前node节点的名称

启动相关服务
systemctl daemon-reload
systemctl enable kube-APIserver
systemctl enable kube-controller-manager
systemctl enable kube-scheduler


3.5在node节点安装kube-proxy

3.5.1 service文件
cat /lib/systemd/system/kube-proxy.service
[Unit]
Description=Kubernetes Kube-Proxy Server
documentation=https://github.com/GoogleCloudplatform/kubernetes
After=network.target
Requires=network.target
[Service]
Environmentfile=/etc/kubernetes/proxy
ExecStart=/usr/bin/kube-proxy $KUBE_PROXY_ARGS
Restart=on-failure
limitNOfile=65536

[Install]
WantedBy=multi-user.target
3.5.2 配置文件
cat /etc/kubernetes/proxy
KUBE_PROXY_ARGS="--master=http://192.168.122.144:8080 --logtostderr=false --log-dir=/var/log/kubernetes --v=2"

启动node节点中的服务
systemctl daemon-reload
systemctl enable kubelet
systemctl start kubelet
systemctl enable kube-proxy
systemctl start kube-proxy


3.6 网络配置 (flanneld)

3.6.1 service文件
cat /lib/systemd/system/flanneld.service
[Unit]
Description=flanneld overlay address etcd agent
After=network.target
Before=docker.service

[Service]
Type=notify
Environmentfile=/etc/sysconfig/flannel
ExecStart=/usr/bin/flanneld --etcd-endpoints=${FLANNEL_ETCD} ${FLANNEL_OPTIONS}

[Install]
requiredBy=docker.service
WantedBy=multi-user.target

3.6.2配置文件
cat /etc/sysconfig/flannel
FLANNEL_ETCD="http://192.168.122.144:4001"
FLANNEL_ETCD_KEY="/coreos.com/network"
FLANNEL_OPTIONS="--iface=ens33"

说明 FLANNEL_OPTIONS="--iface=ens33" 指定网卡

3.6.3 配置docker启动参数

执行 mk-docker-opts.sh -i  会生成两个文件
查看文件(这两个文件重起后会消失,因此可以把该命令设置为开机启动)
cat /run/docker_opts.env
DOCKER_OPT_BIP="--bip=10.1.78.1/24"
DOCKER_OPT_IPMASQ="--ip-masq=true"
DOCKER_OPT_MTU="--mtu=1472"

cat /run/flannel/subnet.env
FLANNEL_NETWORK=10.1.0.0/16
FLANNEL_subnet=10.1.78.1/24
FLANNEL_MTU=1472
FLANNEL_IPMASQ=false

修改docker.service
cat /lib/systemd/system/docker.service
修改Service下的配置,以下两行
Environmentfile=/run/docker_opts.env
ExecStart=/usr/bin/dockerd ${DOCKER_OPT_BIP} ${DOCKER_OPT_IPMASQ} ${DOCKER_OPT_MTU} -H fd:// --containerd=/run/containerd/containerd.sock

启动flanneld
systemctl daemon-reload
systemctl enable flanneld
systemctl start flanneld

重新启动docker
systemctl restart docker

3.7 Dns设置
待整理kubedns或skydns


3.8日志查看
容器控制台输出日志都在node节点/var/logs/container里
使用elk或efk可以通过监控此文件夹,进行日志收集。

3.9 kubenets中的查关概念

总结

以上是内存溢出为你收集整理的kubenetes安装全部内容,希望文章能够帮你解决kubenetes安装所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1021779.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存