首页 > 其他分享 >安装

安装

时间:2022-08-26 22:22:59浏览次数:70  
标签:-- root work kubeconfig kubelet 安装 xianchaomaster1

创建kubelet-bootstrap.kubeconfig
[root@xianchaomaster1 work]# cd /data/work/
[root@xianchaomaster1 work]# BOOTSTRAP_TOKEN=$(awk -F "," '{print $1}' /etc/kubernetes/token.csv)

[root@xianchaomaster1 work]# rm -r kubelet-bootstrap.kubeconfig

[root@xianchaomaster1 work]#  kubectl config set-cluster kubernetes --certificate-authority=ca.pem --embed-certs=true --server=https://192.168.40.180:6443 --kubeconfig=kubelet-bootstrap.kubeconfig

[root@xianchaomaster1 work]# kubectl config set-credentials kubelet-bootstrap --token=${BOOTSTRAP_TOKEN} --kubeconfig=kubelet-bootstrap.kubeconfig

[root@xianchaomaster1 work]# kubectl config set-context default --cluster=kubernetes --user=kubelet-bootstrap --kubeconfig=kubelet-bootstrap.kubeconfig

[root@xianchaomaster1 work]# kubectl config use-context default --kubeconfig=kubelet-bootstrap.kubeconfig

[root@xianchaomaster1 work]# kubectl create clusterrolebinding kubelet-bootstrap --clusterrole=system:node-bootstrapper --user=kubelet-bootstrap

#创建配置文件kubelet.json
"cgroupDriver": "systemd"要和docker的驱动一致。
address替换为自己xianchaonode1的IP地址。

[root@xianchaomaster1 work]# vim kubelet.json 
{
  "kind": "KubeletConfiguration",
  "apiVersion": "kubelet.config.k8s.io/v1beta1",
  "authentication": {
    "x509": {
      "clientCAFile": "/etc/kubernetes/ssl/ca.pem"
    },
    "webhook": {
      "enabled": true,
      "cacheTTL": "2m0s"
    },
    "anonymous": {
      "enabled": false
    }
  },
  "authorization": {
    "mode": "Webhook",
    "webhook": {
      "cacheAuthorizedTTL": "5m0s",
      "cacheUnauthorizedTTL": "30s"
    }
  },
  "address": "192.168.40.183",
  "port": 10250,
  "readOnlyPort": 10255,
  "cgroupDriver": "systemd",
  "hairpinMode": "promiscuous-bridge",
  "serializeImagePulls": false,
  "featureGates": {
    "RotateKubeletClientCertificate": true,
    "RotateKubeletServerCertificate": true
  },
  "clusterDomain": "cluster.local.",
  "clusterDNS": ["10.255.0.2"]
}

[root@xianchaomaster1 work]# vim kubelet.service 
[Unit]
Description=Kubernetes Kubelet
Documentation=https://github.com/kubernetes/kubernetes
After=docker.service
Requires=docker.service
[Service]
WorkingDirectory=/var/lib/kubelet
ExecStart=/usr/local/bin/kubelet \
  --bootstrap-kubeconfig=/etc/kubernetes/kubelet-bootstrap.kubeconfig \
  --cert-dir=/etc/kubernetes/ssl \
  --kubeconfig=/etc/kubernetes/kubelet.kubeconfig \
  --config=/etc/kubernetes/kubelet.json \
  --network-plugin=cni \
  --pod-infra-container-image=k8s.gcr.io/pause:3.2 \
  --alsologtostderr=true \
  --logtostderr=false \
  --log-dir=/var/log/kubernetes \
  --v=2
Restart=on-failure
RestartSec=5
 
[Install]
WantedBy=multi-user.target


#注: –hostname-override:显示名称,集群中唯一 
–network-plugin:启用CNI 
–kubeconfig:空路径,会自动生成,后面用于连接apiserver 
–bootstrap-kubeconfig:首次启动向apiserver申请证书
–config:配置参数文件 
–cert-dir:kubelet证书生成目录 
–pod-infra-container-image:管理Pod网络容器的镜像

#注:kubelete.json配置文件address改为各个节点的ip地址,在各个work节点上启动服务

[root@xianchaonode1 ~]# mkdir /etc/kubernetes/ssl -p
[root@xianchaomaster1 work]# scp kubelet-bootstrap.kubeconfig kubelet.json xianchaonode1:/etc/kubernetes/
[root@xianchaomaster1 work]# scp  ca.pem xianchaonode1:/etc/kubernetes/ssl/
[root@xianchaomaster1 work]# scp  kubelet.service xianchaonode1:/usr/lib/systemd/system/

#启动kubelet服务
[root@xianchaonode1 ~]# mkdir /var/lib/kubelet
[root@xianchaonode1 ~]# mkdir /var/log/kubernetes
[root@xianchaonode1 ~]#  systemctl daemon-reload
[root@xianchaonode1 ~]# systemctl enable kubelet
[root@xianchaonode1 ~]# systemctl start kubelet
[root@xianchaonode1 ~]#  systemctl status kubelet
   Active: active (running) since 
确认kubelet服务启动成功后,接着到xianchaomaster1节点上Approve一下bootstrap请求。

[əˈpruːv]:批准

执行如下命令可以看到一个worker节点发送了一个 CSR 请求:
[root@xianchaomaster1 work]# kubectl get csr
NAME                                                   AGE   SIGNERNAME                                    REQUESTOR           CONDITION
node-csr-SY6gROGEmH0qVZhMVhJKKWN3UaWkKKQzV8dopoIO9Uc   87s   kubernetes.io/kube-apiserver-client-kubelet   kubelet-bootstrap   Pending

[root@xianchaomaster1 work]# kubectl certificate approve node-csr-SY6gROGEmH0qVZhMVhJKKWN3UaWkKKQzV8dopoIO9Uc
[root@xianchaomaster1 work]# kubectl get csr
NAME                                                   AGE     SIGNERNAME                                    REQUESTOR           CONDITION
node-csr-SY6gROGEmH0qVZhMVhJKKWN3UaWkKKQzV8dopoIO9Uc   2m25s   kubernetes.io/kube-apiserver-client-kubelet   kubelet-bootstrap   Approved,Issued

[root@xianchaomaster1 work]# kubectl get nodes
NAME    STATUS     ROLES    AGE   VERSION
xianchaonode1   NotReady   <none>   30s   v1.20.7

#注意:STATUS是NotReady表示还没有安装网络插件

  

标签:--,root,work,kubeconfig,kubelet,安装,xianchaomaster1
From: https://www.cnblogs.com/rdchenxi/p/16629419.html

相关文章

  • Centos7 安装jdk1.8
    Centos7安装jdk1.8一下载linux版jdk我们安装jdk1.8地址:https://www.oracle.com/java/technologies/oracle-java-archive-downloads.html找到对应版本下载:需要账号......
  • 用Linux安装Docker详细步骤以及Linux下使用docker安装elasticsearch
    https://blog.csdn.net/Saionyy/article/details/124243491 https://blog.csdn.net/weixin_42361442/article/details/121511762?spm=1001.2101.3001.6650.5&utm_medium......
  • Zabbix5.0的安装(超详细)
    一、安装zabbix-server首先在虚拟机上把Centos7安装完毕并关闭防火墙与SElinux。打开Zabbix官网选择Zabbix版本-OS系统-OS版本-数据库-WebServer2、替换阿......
  • JDK安装
    JDK安装去oracle官网下载JDK1.8,下载时需要账号密码。点击下一步安装配置环境变量,在高级系统设置中打开环境变量。添加环境变量:JAVA_HOME,C:\ProgramFiles\Java\jdk1......
  • Docker 环境安装postgres+postgis扩展
    一、单独安装Postgresql1、安装docker。(省略,自行百度安装)2、拉取postgresql镜像。dockerpullpostgres:123、运行postgresdockerrun--namepostgres--restart=always......
  • Oracle多租户容器数据库的安装和使用
    oracle多租户容器数据库:OracleMultitenantContainerDatabase(CDB)一、多租户架构有oracle体系结构链接:https://www.cnblogs.com/muhai/p/16333182.html二、多租户容......
  • MongoDB的安装配置及客户端登陆
    一、CentOS7MongoDB的安装及配置:到官网下载安装包https://www.mongodb.com/try/download/enterprise上传并解压到服务器#mkdir-p/usr/local/mongodb#tar......
  • MySQL主从安装
    mysql5.7 wget-i-chttp://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpmyum-yinstallmysql57-community-release-el7-10.noarch.rpmyum-......
  • Linux安装python并配置环境变量
    1.获取python3源码我们访问这个网址,就可以看到全部的python下载方式:【https://www.python.org/downloads/】   本人下载的是3.10.6版本   2.安装Python这......
  • cento7.6下yum安装Jenkins
    注意:有些java版本跟Jenkins版本不匹配 下载Jenkins源sudowget-O/etc/yum.repos.d/jenkins.repo\https://pkg.jenkins.io/redhat/jenkins.reposudorpm--imp......