手动安装K8s第六节:node节点部署-kubelet

部署kubelet
1、准备二进制包
[[email protected] ~]# cd /usr/local/src/kubernetes/server/bin/

[[email protected] bin]# scp kubelet kube-proxy k8snode1:/opt/kubernetes/bin/
[[email protected] bin]# scp kubelet kube-proxy k8snode2:/opt/kubernetes/bin/

2.创建角色绑定
[[email protected] bin]# cd /usr/local/src/ssl/
[[email protected] ssl]# kubectl create clusterrolebinding kubelet-bootstrap --clusterrole=system:node-bootstrapper --user=kubelet-bootstrap
clusterrolebinding.rbac.authorization.k8s.io "kubelet-bootstrap" created

3.创建 kubelet bootstrapping kubeconfig 文件 设置集群参数
[[email protected] ssl]# kubectl config set-cluster kubernetes \
--certificate-authority=/opt/kubernetes/ssl/ca.pem \
--embed-certs=true \
--server=https://192.168.137.171:6443 \
--kubeconfig=bootstrap.kubeconfig
Cluster "kubernetes" set.

设置客户端认证参数
[[email protected] ssl]# kubectl config set-credentials kubelet-bootstrap \
--token=ad6d5bb607a186796d8861557df0d17f \
--kubeconfig=bootstrap.kubeconfig
User "kubelet-bootstrap" set.

设置上下文参数
[[email protected] ssl]# kubectl config set-context default \
--cluster=kubernetes \
--user=kubelet-bootstrap \
--kubeconfig=bootstrap.kubeconfig
Context "default" created.

选择默认上下文
[[email protected] ~]# kubectl config use-context default --kubeconfig=bootstrap.kubeconfig
Switched to context "default".

[[email protected] ssl]# cp bootstrap.kubeconfig /opt/kubernetes/cfg/
[[email protected] ssl]# scp bootstrap.kubeconfig k8snode1:/opt/kubernetes/cfg/bootstrap.kubeconfig
[[email protected] ssl]# scp bootstrap.kubeconfig k8snode2:/opt/kubernetes/cfg/bootstrap.kubeconfig

node节点部署kubelet
1.设置CNI支持(master节点可不配置)
[[email protected] ssl]# mkdir -p /etc/cni/net.d
[[email protected] ssl]# vim /etc/cni/net.d/10-default.conf

{
"name": "flannel",
"type": "flannel",
"delegate": {
"bridge": "docker0",
"isDefaultGateway": true,
"mtu": 1400
}
}

[[email protected] ssl]# scp /etc/cni/net.d/10-default.conf k8snode1:/etc/cni/net.d
[[email protected] ssl]# scp /etc/cni/net.d/10-default.conf k8snode2:/etc/cni/net.d

[[email protected] ssl]#

2、 创建kubelet目录
[[email protected] ~]# mkdir /var/lib/kubelet
[[email protected] ~]# vim /usr/lib/systemd/system/kubelet.service

[Unit]
Description=Kubernetes Kubelet
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=docker.service
Requires=docker.service

[Service]
WorkingDirectory=/var/lib/kubelet
ExecStart=/opt/kubernetes/bin/kubelet \
--address=192.168.137.201 \
--hostname-override=192.168.137.201 \
--pod-infra-container-image=mirrorgooglecontainers/pause-amd64:3.0 \
--experimental-bootstrap-kubeconfig=/opt/kubernetes/cfg/bootstrap.kubeconfig \
--kubeconfig=/opt/kubernetes/cfg/kubelet.kubeconfig \
--cert-dir=/opt/kubernetes/ssl \
--network-plugin=cni \
--cni-conf-dir=/etc/cni/net.d \
--cni-bin-dir=/opt/kubernetes/bin/cni \
--cluster-dns=10.1.0.2 \
--cluster-domain=cluster.local. \
--hairpin-mode hairpin-veth \
--allow-privileged=true \
--fail-swap-on=false \
--logtostderr=true \
--v=2 \
--logtostderr=false \
--log-dir=/opt/kubernetes/log
Restart=on-failure
RestartSec=5

[[email protected] ~]# systemctl daemon-reload
[[email protected] ~]# systemctl enable kubelet
[[email protected] ~]# systemctl start kubelet
[[email protected] ~]# systemctl status kubelet

查看csr请求 注意是在k8smster上执行。
[[email protected] bin]# kubectl get csr
NAME AGE REQUESTOR CONDITION
node-csr--H3IeaAXhDIlgw3nvfJZxfbJdURjjzNBBng4GthssxE 6m kubelet-bootstrap Pending
node-csr-s32pz33uIKZWEkXwIDHR09pxZKXwy1R6lug6KbXBBvE 6m kubelet-bootstrap Pending

批准kubelet 的 TLS 证书请求
[[email protected] bin]# kubectl get csr|grep ‘Pending‘ | awk ‘NR>0{print $1}‘| xargs kubectl certificate approve
certificatesigningrequest.certificates.k8s.io "node-csr--H3IeaAXhDIlgw3nvfJZxfbJdURjjzNBBng4GthssxE" approved
certificatesigningrequest.certificates.k8s.io "node-csr-s32pz33uIKZWEkXwIDHR09pxZKXwy1R6lug6KbXBBvE" approved

查看node节点状态
[[email protected] ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8snode1 Ready <none> 38s v1.10.1
k8snode2 Ready <none> 38s v1.10.1

原文地址:http://blog.51cto.com/andyliu/2129072

时间: 2024-10-29 19:50:56

手动安装K8s第六节:node节点部署-kubelet的相关文章

Kubernetes(K8s)安装部署过程(六)--node节点部署

hi,everybody,我回来了,之前安装到flannel之后,文章一直没有更新,甚至不少小伙伴都来加qq询问是否继续更新了, 这里说明下原因,我在部署1.91node的时候的确出现了各种各样的问题,导致节点启动后哦,master总是看不到,遇到的问题大概有 1.虚拟机时间同步不一致问题,导致etcd创建资源不成功 2.node节点无法自动创建kubelet.kubeconfig问题,这个是最严重的问题,原因是config文件没有拷贝到node的/etc/kubernetes文件夹内,因为ku

手动安装K8s第四节:Master节点

0.准备软件包 cd /usr/local/src/kubernetes[[email protected] kubernetes]# cp server/bin/kube-apiserver /opt/kubernetes/bin/[[email protected] kubernetes]# cp server/bin/kube-controller-manager /opt/kubernetes/bin/[[email protected] kubernetes]# cp server/b

手动安装K8s第五节:master节点kubectl命令部署

1.部署kubectl 命令行工具准备二进制包[[email protected] ~]# cd /usr/local/src/kubernetes/client/bin[[email protected] bin]# cp kubectl /opt/kubernetes/bin/ 2.创建 admin 证书签名请求[[email protected] bin]# cd /usr/local/src/ssl/[[email protected] ssl]# vim admin-csr.json

二进制安装kubernetes v1.11.2 (第十一章 node节点部署)

继续前一章部署. 十一.node节点部署 kubernetes node 节点运行了如下组件: flannel docker kubelet kube-proxy 11.1 部署flanneld 请参考 第五章 11.2 安装依赖包 centos: source /opt/k8s/bin/environment.sh for node_ip in ${NODE_IPS[@]} do echo ">>> ${node_ip}" ssh [email protected]

手动安装K8s第三节:etcd集群部署

准备安装包https://github.com/coreos/etcd版本:3.2.18wget https://github.com/coreos/etcd/releases/download/v3.2.18/etcd-v3.2.18-linux-amd64.tar.gz 0.安装[[email protected] src]# tar zxf etcd-v3.2.18-linux-amd64.tar.gz[[email protected] src]# cd etcd-v3.2.18-lin

三 node节点部署k8s组件

接着第二篇,master上面部署完了三个角色,接着部署node节点主要部署:kubelet kube-proxy 一 环境准备(以下都是在master上操作) 1建立目录,拷贝两个组件 mkdir /home/yx/kubernetes/{bin,cfg,ssl} -p # 两个node节点都拷贝 scp -r /home/yx/src/kubernetes/server/bin/kubelet [email protected]:/home/yx/kubernetes/bin scp -r /

k8s node节点部署(v1.13.10)

系统环境: node节点 操作系统: CentOS-7-x86_64-DVD-1908.iso node节点 IP地址: 192.168.1.204 node节点 hostname(主机名, 请和保持node节点主机名 和master不同):k8s.node03 目标: 在该机器安装k8s node节点,并加入指定集群 步骤如下: 1. 安装基础工具 yum install vim yum install lrzsz yum install dockersystemctl start docke

生产环境二进制k8s集群扩容node节点的实践

K8s二进制生产环境扩容node节点由于项目微服务也是部署在k8s集群中去维护的,所以扩容node节点也是必要的联系,扩容node节点一定要保证你整个集群的容器环境的网络都是互通的,这也是很重要的一步,这里我根据自己的经验去扩容,仅供参考首先我这里是安装的二进制方式去部署的k8s集群,进行扩容node的时候,也是非常方便的扩容node节点分为两步,第一步先将我们旧的node节点上的配置先去拷贝到我们新的节点上,第二点就是将我们的容器网络环境打通这里我是直接扩容两个node节点.第一步: 我们先去

Kubernetes集群部署之五node节点部署

部署kubelet: 1.二进制包准备 将软件包可执行文件从k8s-master复制到node节点中去. [[email protected] ~]# cd /usr/local/src/kubernetes/server/bin [[email protected]-master bin]# scp kubelet kube-proxy 10.200.3.106:/opt/kubernetes/bin/ [[email protected]-master bin]# scp kubelet k