kubeshpere安装

satuo20 1年前 ⋅ 509 阅读
#### [官方离线安装教程 3.1](https://kubesphere.com.cn/docs/installing-on-linux/introduction/air-gapped-installation/)
  1. 修改主机名称、禁用SELINUX、关闭防火墙

    # master节点执行(192.168.0.70)
    hostnamectl set-hostname master
    
    # worker1节点执行(192.168.0.74)
    hostnamectl set-hostname worker1
    
    # worker2节点执行(192.168.0.75)
    hostnamectl set-hostname worker2
    
    # worker3节点执行(192.168.0.79)
    hostnamectl set-hostname worker3
    
    # 打开/etc/selinux/config文件,修改SELINUX=disabled(所有节点均执行)
    vi /etc/selinux/config
    	SELINUX=disabled
    #关闭防火墙(所有节点均执行)
    systemctl stop firewalld && systemctl disable firewalld	
    
    # 必备软件
    yum install socat -y
    yum install conntrack -y
    yum install ebtables -y
    yum install openssl -y
    yum install ipset -y
    yum install wget -y
    
    # 重启(所有节点均执行)
    reboot
    
    
  2. 配置hosts文件

    # kubekey hosts BEGIN
    192.168.0.201  kubesphere.localdomain.cluster.local kubesphere.localdomain master
    192.168.0.201  lb.kubesphere.local
    192.168.0.201  blockdeviceclaims.openebs.io
    192.168.0.202  worker1
    192.168.0.203  worker2
    192.168.0.204  worker3
    192.168.0.201 kubesphere
    
  3. master到各worker的ssh免密登录

    # 在master节点生成公私钥
     ssh-keygen -t rsa
     回车三次
    
     # 复制公钥到目标主机
     ssh-copy-id root@master
     ssh-copy-id root@worker1
     ssh-copy-id root@worker2
     ssh-copy-id root@worker3
    
     # 复制master下.ssh/目录到所有节点
    	authorized_keys  id_rsa  id_rsa.pub  known_hosts
    
     # 重启SSH服务(所有节点均执行)
     sudo service sshd restart
    
     #修改权限(所有节点均执行)
     chmod -R 700 .ssh/
     chmod 600 .ssh/authorized_keys
    
  4. 时间同步

    #  master节点
    yum install ntpdate ntp -y
    
    # vi /etc/ntp.conf
    =======================ntp.conf start=================================
    driftfile /var/lib/ntp/drift
    
    restrict default nomodify notrap nopeer noquery
    restrict 127.0.0.1 
    restrict ::1
    
    includefile /etc/ntp/crypto/pw
    
    keys /etc/ntp/keys
    disable monitor
    
    #新增:日志目录.
    logfile /var/log/ntpd.log
    #这一行的含义是授权192.168.0.0网段上的所有机器可以从这台机器上查询和同步时间.
    restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap
    #新增:时间服务器列表.
    server 0.cn.pool.ntp.org iburst
    server 1.cn.pool.ntp.org iburst
    server 2.cn.pool.ntp.org iburst
    server 3.cn.pool.ntp.org iburst
    
    #新增:当外部时间不可用时,使用本地时间.
    server 127.0.0.1 iburst
    fudge 127.0.0.1 stratum 10
    
    #新增:允许上层时间服务器主动修改本机时间.
    restrict 0.cn.pool.ntp.org nomodify notrap noquery
    restrict 1.cn.pool.ntp.org nomodify notrap noquery
    restrict 2.cn.pool.ntp.org nomodify notrap noquery
    ============================ntp.conf end====================================
    
    # 开机自启
    systemctl enable ntpd
    systemctl enable ntpdate
    systemctl is-enabled ntpd
    
    
    #启动NTP服务器
    systemctl start ntpdate
    systemctl start ntpd
    
    # 客户端
    vi /etc/ntp.conf
    server master
    
    
    
    crontab -e
    0 0 * * * /usr/sbin/sntp -P no -r master;hwclock -w
    
    systemctl restart ntpd
    
    
    

    安装docker

  5. 安装

./kk create config --with-kubesphere v3.0.0
./kk create config --with-kubernetes v1.18.6 --with-kubesphere v3.0.0
./kk create cluster --with-kubernetes v1.18.6 --with-kubesphere v3.0.0

# 证书错误的解决办法:执行下面两条指令,并重新添加k8sconfig凭证
kubectl -n kubesphere-controls-system delete cm kubeconfig-admin
kubectl -n kubesphere-system rollout restart deployment ks-controller-manager ks-apiserver


# 查看安装结果
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f



./kk create cluster --with-kubernetes v1.18.6 --with-kubesphere v3.0.0

export KKZONE=cn;./offline-installation-tool.sh -b -v v1.18.6


  1. 相关命令

    #重启集群
    systemctl daemon-reload && systemctl restart kubelet
    
    # 重启ks-api或其它pod
    kubectl -n kubesphere-system rollout restart deploy/ks-apiserver
    kubectl -n kubesphere-system rollout restart deploy/ks-installer
    kubectl -n kubesphere-system rollout restart deploy/ks-controller-manager
    kubectl -n kube-system rollout restart deploy/calico-kube-controllers
    
    kubectl -n kubesphere-system rollout restart deploy/podname
    
    #配置 sornar
    https://kubesphere.com.cn/docs/devops-user-guide/how-to-integrate/sonarqube/
    
    #配置 jenkins
    https://kubesphere.com.cn/docs/devops-user-guide/how-to-use/jenkins-setting/
    
    
    
    kubectl edit pod ks-apiserver-7ffd954d6f-jsmp7 -n kubesphere-system
    kubectl edit pod redis-5db8fc9b7f-pq6cz -n kubesphere-system
    kubectl edit pod ks-controller-manager-578945c9f7-46m9j -n kubesphere-system
    
    # 查看deployment
    kubectl get deployments.apps -n kubesphere-system
    
    command: [ "/bin/sh", "-ce", "tail -f /dev/null" ]
    
    imagePullPolicy: IfNotPresent # 这个设置 会从本地先找,没有从远处拉取
    command: [ "/bin/bash", "-ce", "tail -f /dev/null" ]
    
    kubectl edit pod ks-apiserver-b95bb87f9-5wtws -n kubesphere-system
    ks-apiserver.yaml
    
    # 查看pods
    kubectl get pods -n kubesphere-system -o wide
    kubectl get pods -A
    
    # 查询svc
    kubectl get svc -n kubesphere-system
    
    kubectl apply -f ks-apiserver.yaml -n kubesphere-system
    kubectl apply -f controller.yaml -n kube-system
    
    # 删除pod
    kubectl delete pod -n kubesphere-system
    kubectl delete pod -n kube-system
    
    # 删除svc
    kubectl delete svc -n kubesphere-system
    
    # 查看日志
    kubectl logs -n kubesphere-system
    kubectl logs -n kube-system
    journalctl -xefu kubelet
    
    
    
  2. 修改110节点限制

    1. 找到maxPods进行修改

      vi /var/lib/kubelet/config.yaml	# 找到maxPods进行修改	maxPods: 888
      
    2. 重启集群

    #重启集群systemctl daemon-reload && systemctl restart kubelet
    
    1. 根据名称删除镜像

      docker images |grep "registry.cn-shenzhen.aliyuncs.com" | awk '{print $1":"$2}' | xargs docker rmi
      
    2. centos7 硬盘扩容

      https://blog.csdn.net/IDMANOR/article/details/106690344
      

全部评论: 0

    我有话说: