编程语言
首页 > 编程语言> > k8s集群详细安装步骤,java架构师成长直通车pan

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

标签:kube,java,service,kubernetes,--,apiserver,etc,架构师,k8s
来源: https://blog.csdn.net/m0_64867003/article/details/121727892