5.K8S部署-------- 部署Node节点

没有特别其他说明一切按照文档执行

1.二进制包准备 将软件包从linux-node1复制到linux-node2 linux-node3中去。

[[email protected]1 ~]# cd /usr/local/src/kubernetes/server/bin/
[[email protected] bin]# cp kubelet kube-proxy /opt/kubernetes/bin/
[[email protected] bin]# scp kubelet kube-proxy 192.168.56.12:/opt/kubernetes/bin/
[[email protected] bin]# scp kubelet kube-proxy 192.168.56.13:/opt/kubernetes/bin/

2.创建角色绑定

[[email protected] ~]# kubectl create clusterrolebinding kubelet-bootstrap --clusterrole=system:node-bootstrapper --user=kubelet-bootstrap
clusterrolebinding "kubelet-bootstrap" created

3.创建 kubelet bootstrapping kubeconfig 文件 设置集群参数

[[email protected] ~]# kubectl config set-cluster kubernetes \
   --certificate-authority=/opt/kubernetes/ssl/ca.pem \
   --embed-certs=true \
   --server=https://192.168.56.11:6443 \
   --kubeconfig=bootstrap.kubeconfig
Cluster "kubernetes" set.

4.设置客户端认证参数

[[email protected] ~]# kubectl config set-credentials kubelet-bootstrap \
   --token=ad6d5bb607a186796d8861557df0d17f \
   --kubeconfig=bootstrap.kubeconfig  
User "kubelet-bootstrap" set.

红色部分是上节第三部生成的字符串

5.设置上下文参数

[[email protected] ~]# kubectl config set-context default \
   --cluster=kubernetes \
   --user=kubelet-bootstrap \
   --kubeconfig=bootstrap.kubeconfig
Context "default" created.

6.选择默认上下文

[[email protected] ~]# kubectl config use-context default --kubeconfig=bootstrap.kubeconfig
Switched to context "default".
[[email protected] kubernetes]# cp bootstrap.kubeconfig /opt/kubernetes/cfg
[[email protected] kubernetes]# scp bootstrap.kubeconfig 192.168.56.12:/opt/kubernetes/cfg
[[email protected] kubernetes]# scp bootstrap.kubeconfig 192.168.56.13:/opt/kubernetes/cfg

部署kubelet

1.设置CNI支持(只在node2 node3上执行即可)

[[email protected] ~]# mkdir -p /etc/cni/net.d
[[email protected] ~]# vim /etc/cni/net.d/10-default.conf
{
        "name": "flannel",
        "type": "flannel",
        "delegate": {
            "bridge": "docker0",
            "isDefaultGateway": true,
            "mtu": 1400
        }
}

[[email protected]3 ~]# mkdir -p /etc/cni/net.d
[[email protected]3~]# vim /etc/cni/net.d/10-default.conf
{
        "name": "flannel",
        "type": "flannel",
        "delegate": {
            "bridge": "docker0",
            "isDefaultGateway": true,
            "mtu": 1400
        }
}

2.创建kubelet目录(只在node2 node3上执行即可)

[[email protected] ~]# mkdir /var/lib/kubelet

3.创建kubelet服务配置(只在node2 node3上执行即可)

[[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.56.12 \
  --hostname-override=192.168.56.12 \
  --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

4.启动Kubelet(只在node2 node3上执行即可)

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

5.查看服务状态(只在node2 node3上执行即可)

[[email protected] kubernetes]# systemctl status kubelet

6.查看csr请求 (注意是在linux-node1上执行。)

[[email protected] ~]# kubectl get csr
NAME                                                   AGE       REQUESTOR           CONDITION
node-csr-0_w5F1FM_la_SeGiu3Y5xELRpYUjjT2icIFk9gO9KOU   1m        kubelet-bootstrap   Pending

7.批准kubelet 的 TLS 证书请求(在linux-node1上执行。)

[[email protected] ~]# kubectl get csr|grep 'Pending' | awk 'NR>0{print $1}'| xargs kubectl certificate approve

8.执行完毕后,查看节点状态已经是Ready的状态了:命令如下:

[[email protected] ssl]# kubectl get node

部署Kubernetes Proxy

1.配置kube-proxy使用LVS

[[email protected] ~]# yum install -y ipvsadm ipset conntrack

[[email protected]~]# yum install -y ipvsadm ipset conntrack

2.创建 kube-proxy 证书请求

[[email protected] ~]# cd /usr/local/src/ssl/
[[email protected] ~]# vim kube-proxy-csr.json
{
  "CN": "system:kube-proxy",
  "hosts": [],
  "key": {
    "algo": "rsa",
    "size": 2048
  },
  "names": [
    {
      "C": "CN",
      "ST": "BeiJing",
      "L": "BeiJing",
      "O": "k8s",
      "OU": "System"
    }
  ]
}

3.生成证书

[[email protected]~]# cfssl gencert -ca=/opt/kubernetes/ssl/ca.pem \
   -ca-key=/opt/kubernetes/ssl/ca-key.pem \
   -config=/opt/kubernetes/ssl/ca-config.json \
   -profile=kubernetes  kube-proxy-csr.json | cfssljson -bare kube-proxy

4.分发证书到所有Node节点

[[email protected] ssl]# cp kube-proxy*.pem /opt/kubernetes/ssl/
[[email protected] ssl]# scp kube-proxy*.pem 192.168.56.12:/opt/kubernetes/ssl/
[[email protected] ssl]# scp kube-proxy*.pem 192.168.56.13 :/opt/kubernetes/ssl/

5.创建kube-proxy配置文件

[[email protected] ~]# kubectl config set-cluster kubernetes \
   --certificate-authority=/opt/kubernetes/ssl/ca.pem \
   --embed-certs=true \
   --server=https://192.168.56.11:6443 \
   --kubeconfig=kube-proxy.kubeconfig
Cluster "kubernetes" set.

[[email protected]1 ~]# kubectl config set-credentials kube-proxy \
   --client-certificate=/opt/kubernetes/ssl/kube-proxy.pem \
   --client-key=/opt/kubernetes/ssl/kube-proxy-key.pem \
   --embed-certs=true \
   --kubeconfig=kube-proxy.kubeconfig
User "kube-proxy" set.

[[email protected]1 ~]# kubectl config set-context default \
   --cluster=kubernetes \
   --user=kube-proxy \
   --kubeconfig=kube-proxy.kubeconfig
Context "default" created.

[[email protected]1 ~]# kubectl config use-context default --kubeconfig=kube-proxy.kubeconfig
Switched to context "default".

6.分发kubeconfig配置文件

[[email protected] ssl]# cp kube-proxy.kubeconfig /opt/kubernetes/cfg/
[[email protected] ~]# scp kube-proxy.kubeconfig 192.168.56.12:/opt/kubernetes/cfg/
[[email protected] ~]# scp kube-proxy.kubeconfig 192.168.56.13:/opt/kubernetes/cfg/

7.创建kube-proxy服务配置(只在node2,node3上创建)

[[email protected] bin]# mkdir /var/lib/kube-proxy

[[email protected] ~]# vim /usr/lib/systemd/system/kube-proxy.service
[Unit]
Description=Kubernetes Kube-Proxy Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=network.target

[Service]
WorkingDirectory=/var/lib/kube-proxy
ExecStart=/opt/kubernetes/bin/kube-proxy \
  --bind-address=192.168.56.12 \
  --hostname-override=192.168.56.12 \
  --kubeconfig=/opt/kubernetes/cfg/kube-proxy.kubeconfig \
--masquerade-all \
  --feature-gates=SupportIPVSProxyMode=true \
  --proxy-mode=ipvs \
  --ipvs-min-sync-period=5s \
  --ipvs-sync-period=5s \
  --ipvs-scheduler=rr \
  --logtostderr=true \
  --v=2 \
  --logtostderr=false \
  --log-dir=/opt/kubernetes/log

Restart=on-failure
RestartSec=5
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

8.启动Kubernetes Proxy(只在node2,node3上执行)
[[email protected] ~]# systemctl daemon-reload
[[email protected] ~]# systemctl enable kube-proxy
[[email protected] ~]# systemctl start kube-proxy

9.查看服务状态 查看kube-proxy服务状态(只在node2,node3上执行)

[[email protected] scripts]# systemctl status kube-proxy

10.检查LVS状态(只在node2,node3上执行)
[[email protected] ~]# ipvsadm -L -n
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  10.1.0.1:443 rr persistent 10800
  -> 192.168.56.11:6443           Masq    1      0          0

11.使用下面的命令可以检查node状态:

[[email protected] ssl]#  kubectl get node
NAME            STATUS    ROLES     AGE       VERSION
192.168.56.12   Ready     <none>    22m       v1.10.1
192.168.56.13   Ready     <none>    3m        v1.10.1

原文地址:http://blog.51cto.com/maomaochong/2122651

时间: 2024-11-06 20:25:22

5.K8S部署-------- 部署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

[转帖]k8s集群node节点一直NotReady, 且node节点(并非master)的kubelet报错:Unable to update cni config: No networks found in /etc/cni/net.d

k8s集群node节点一直NotReady, 且node节点(并非master)的kubelet报错:Unable to update cni config: No networks found in /etc/cni/net.d http://www.voidcn.com/article/p-wpuagtbj-byy.html ? 考虑到node节点的kubelet报错Unable to update cni config: No networks found in /etc/cni/net.

Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列之部署master/node节点组件(四)

0.前言 整体架构目录:ASP.NET Core分布式项目实战-目录 k8s架构目录:Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录 1.部署master组件 master 服务器的组件有:kube-apiserver.kube-controller-manager.kube-scheduler 因此需要下载k8s master,下载地址:https://github.com/kubernetes/kubernetes/blob/master/CHANGE

k8s安装之node节点

kubernetes node 安装kubelet wget https://storage.googleapis.com/kubernetes-release/release/v1.11.0/kubernetes-server-linux-amd64.tar.gz tar -xzvf kubernetes-server-linux-amd64.tar.gz cd kubernetes tar -zxf kubernetes-src.tar.gz scp kubernetes/server/bi

二进制安装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]

08-部署node节点

部署kubernetes node节点 kubernetes node 节点包含如下组件: Flanneld: 省略,参照之前部署的文档 Docker1.12.5: 省略,参照之前部署的文档 kubelet kube-proxy 目录和文件 我们再检查一下三个节点上,经过前几步操作已经生成的配置文件 # #master节点: # ls /etc/kubernetes/ssl admin-key.pem admin.pem ca-key.pem ca.pem kube-proxy-key.pem

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

部署kubelet1.准备二进制包[[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.创建角色绑定[[ema

三 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