k8s集群详细安装步骤,java架构师成长直通车pan
2021/12/5 14:20:19
本文主要是介绍k8s集群详细安装步骤,java架构师成长直通车pan,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
2.1.2kube-apiserver服务
2.1.2.1下载并复制
下载
wget https://dl.k8s.io/v1.19.0/kubernetes-server-linux-amd64.tar.gz
解压
tar -zxvf kubernetes-server-linux-amd64.tar.gz
解压后将kube-apiserver、kube-controller-manager、kube-scheduler以及管理要使用的kubectl二进制命令文件
放到/usr/bin目录,即完成这几个服务的安装。
cp kube-apiserver kube-controller-manager kube-scheduler kubectl /usr/bin/
2.1.2.2配置
下面是对kube-apiserver服务进行配置
编辑systemd服务文件
vim /usr/lib/systemd/system/kube-apiserver.service
[Unit]
Description=Kubernetes API Server
Documentation=https://github.com/kubernetes/kubernetes
After=etcd.service
Wants=etcd.service
[Service]
EnvironmentFile=/etc/kubernetes/apiserver
ExecStart=/usr/bin/kube-apiserver $KUBE_API_ARGS
Restart=on-failure
Type=notify
[Install]
WantedBy=multi-user.target
2.1.2.3配置文件
创建目录:mkdir /etc/kubernetes
vim /etc/kubernetes/apiserver
KUBE_API_ARGS="–storage-backend=etcd3 --etcd-servers=http://127.0.0.1:2379 --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,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,DefaultStorageClass,ResourceQuota --logtostderr=true --log-dir=/var/log/kubernetes --v=2"
2.1.3kube-controller-manager服务
kube-controller-manager服务依赖于kube-apiserver服务:
2.1.3.1配置systemd服务文件:
vim /usr/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
2.1.3.2配置文件
vim /etc/kubernetes/controller-manager
KUBE_CONTROLLER_MANAGER_ARGS="–master=http://192.168.168.151:8080 --logtostderr=true --log-dir=/var/log/kubernetes --v=2"
2.1.4 kube-scheduler服务
kube-scheduler服务也依赖于kube-apiserver服务。
2.1.4.1配置systemd服务文件:
vim /usr/lib/systemd/system/kube-
《一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义》
【docs.qq.com/doc/DSmxTbFJ1cmN1R2dB】 完整内容开源分享
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
2.1.4.2配置文件:
vim /etc/kubernetes/scheduler
KUBE_SCHEDULER_ARGS="–master=http://192.168.168.151:8080 --logtostderr=true --log-dir=/var/log/kubernetes --v=2"
2.1.5启动,完成以上配置后,按顺序启动服务
systemctl daemon-reload
systemctl enable kube-apiserver.service
systemctl start kube-apiserver.service
systemctl enable kube-controller-manager.service
systemctl start kube-controller-manager.service
systemctl enable kube-scheduler.service
systemctl start kube-scheduler.service
检查每个服务的健康状态:
systemctl status kube-apiserver.service
systemctl status kube-controller-manager.service
systemctl status kube-scheduler.service
2.2 node安装工作(以192.168.168.152为例)
2.2.1准备工作
在Node1节点上,以同样的方式把从压缩包中解压出的二进制文件kubelet kube-proxy放到/usr/bin目录中。
在Node1节点上需要预先安装docker,请参考Master上Docker的安装,并启动Docker
2.2.2kubelet服务
配置systemd服务文件:
vim /usr/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
KillMode=process
[Install]
WantedBy=multi-user.target
mkdir -p /var/lib/kubelet
配置文件:
vim /etc/kubernetes/kubelet
KUBELET_ARGS="–kubeconfig=/etc/kubernetes/kubeconfig --hostname-override=192.168.168.152 --logtostderr=false --log-dir=/var/log/kubernetes --v=2 --fail-swap-on=false"
用于kubelet连接Master Apiserver的配置文件
vim /etc/kubernetes/kubeconfig
apiVersion: v1
kind: Config
clusters:
- cluster:
server: http://192.168.168.151:8080
name: local
contexts:
- context:
cluster: local
name: mycontext
current-context: mycontext
2.2.3kube-proxy服务
配置systemd服务文件:
vim /usr/lib/systemd/system/kube-proxy.service
[Unit]
Description=Kubernetes Kube-proxy Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=network.service
Requires=network.service
[Service]
EnvironmentFile=/etc/kubernetes/proxy
ExecStart=/usr/bin/kube-proxy $KUBE_PROXY_ARGS
Restart=on-failure
LimitNOFILE=65536
KillMode=process
[Install]
WantedBy=multi-user.target
配置文件:
vim /etc/kubernetes/proxy
这篇关于k8s集群详细安装步骤,java架构师成长直通车pan的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-24怎么修改Kafka的JVM参数?-icode9专业技术文章分享
- 2024-12-23线下车企门店如何实现线上线下融合?
- 2024-12-23鸿蒙Next ArkTS编程规范总结
- 2024-12-23物流团队冬至高效运转,哪款办公软件可助力风险评估?
- 2024-12-23优化库存,提升效率:医药企业如何借助看板软件实现仓库智能化
- 2024-12-23项目管理零负担!轻量化看板工具如何助力团队协作
- 2024-12-23电商活动复盘,为何是团队成长的核心环节?
- 2024-12-23鸿蒙Next ArkTS高性能编程实战
- 2024-12-23数据驱动:电商复盘从基础到进阶!
- 2024-12-23从数据到客户:跨境电商如何通过销售跟踪工具提升营销精准度?