使用kubekey安装kubesphere

运维 系统运维
KubeKey 是新一代 Kubernetes 和 KubeSphere 安装器,可帮助您以简单、快速、灵活的方式安装 Kubernetes 和 KubeSphere。

[[380964]]

 下载 KubeKey

KubeKey 是新一代 Kubernetes 和 KubeSphere 安装器,可帮助您以简单、快速、灵活的方式安装 Kubernetes 和 KubeSphere。

  1. export KKZONE=cn 
  2. curl -sfL https://get-kk.kubesphere.io | VERSION=v1.0.1 sh - 

 准备镜像

如果您想让安装加快或者您的机房没有外网,可以使用公司内部的私有仓库,预先把镜像推送到私有仓库中,我这里的仓库使用harbor

下载离线安装工具,我这里只是用这个脚本来下载和推送镜像

  1. curl -L -O https://github.com/kubesphere/ks-installer/releases/download/v3.0.0/offline-installation-tool.sh 
  2. curl -L -O https://github.com/kubesphere/ks-installer/releases/download/v3.0.0/images-list.txt 

 拉取镜像

  1. ./offline-installation-tool.sh -s -l images-list.txt -d ./kubesphere-images 
  2. 在./kubesphere-images目录下能看到以下压缩包 
  3. # ll 
  4. total 8606088 
  5. -rw-r--r-- 1 root root  454465957 Feb  2 15:37 csi-images.tar.gz 
  6. -rw-r--r-- 1 root root 1231853258 Feb  2 15:33 example-images.tar.gz 
  7. -rw-r--r-- 1 root root  445244294 Feb  2 14:50 istio-images.tar.gz 
  8. -rw-r--r-- 1 root root  762326634 Feb  2 14:27 k8s-images.tar.gz 
  9. -rw-r--r-- 1 root root 1297767607 Feb  2 14:40 ks-core-images.tar.gz 
  10. -rw-r--r-- 1 root root 3439146357 Feb  2 15:19 ks-devops-images.tar.gz 
  11. -rw-r--r-- 1 root root  733165078 Feb  2 14:46 ks-logging-images.tar.gz 
  12. -rw-r--r-- 1 root root  448651153 Feb  2 15:23 openpitrix-images.tar.gz 

 推送镜像到私有仓库,待脚本完成即可

  1. ./offline-installation-tool.sh -l images-list.txt -d ./kubesphere-images -r hub.evbj.easou.com 

创建多节点集群

您可用使用 KubeKey 同时安装 Kubernetes 和 KubeSphere,通过自定义配置文件中的参数创建多节点集群。

创建安装有 KubeSphere 的 Kubernetes 集群(例如 --with-kubesphere v3.0.0)

  1. ./kk create config --with-kubernetes v1.17.9 --with-kubesphere v3.0.0 

系统将创建默认的 config-sample.yaml 文件。您可以根据您的环境修改此文件。

  1. apiVersion: kubekey.kubesphere.io/v1alpha1 
  2. kind: Cluster 
  3. metadata: 
  4.   name: ESCloud 
  5. spec: 
  6.   hosts: 
  7.   - {name: kubesphere001, address: 10.26.31.34, internalAddress: 10.26.31.34, privateKeyPath: "~/.ssh/id_dsa", port: 20755} 
  8.   - {name: kubesphere002, address: 10.26.31.36, internalAddress: 10.26.31.36, privateKeyPath: "~/.ssh/id_dsa", port: 20755} 
  9.   - {name: kubesphere003, address: 10.26.31.42, internalAddress: 10.26.31.42, privateKeyPath: "~/.ssh/id_dsa", port: 20755} 
  10.   - {name: kubesphere004, address: 10.26.31.46, internalAddress: 10.26.31.46, privateKeyPath: "~/.ssh/id_dsa", port: 20755} 
  11.   - {name: kubesphere005, address: 10.26.31.118, internalAddress: 10.26.31.118, privateKeyPath: "~/.ssh/id_dsa", port: 20755} 
  12.   - {name: kubesphere006, address: 10.26.31.119, internalAddress: 10.26.31.119, privateKeyPath: "~/.ssh/id_dsa", port: 20755} 
  13.   - {name: kubesphere007, address: 10.26.31.120, internalAddress: 10.26.31.120, privateKeyPath: "~/.ssh/id_dsa", port: 20755} 
  14.   - {name: kubesphere008, address: 10.26.31.121, internalAddress: 10.26.31.121, privateKeyPath: "~/.ssh/id_dsa", port: 20755} 
  15.   roleGroups: 
  16.     etcd: 
  17.     - kubesphere001 
  18.     - kubesphere002 
  19.     - kubesphere003 
  20.     master:  
  21.     - kubesphere001 
  22.     - kubesphere002 
  23.     - kubesphere003 
  24.     worker: 
  25.     - kubesphere004 
  26.     - kubesphere005 
  27.     - kubesphere006 
  28.     - kubesphere007 
  29.     - kubesphere008 
  30.   controlPlaneEndpoint: 
  31.     domain: lb.kubesphere.local 
  32.     address: "" 
  33.     port: "6443" 
  34.   kubernetes: 
  35.     version: v1.17.9 
  36.     imageRepo: kubesphere 
  37.     clusterName: cluster.local 
  38.   network: 
  39.     plugin: calico 
  40.     kubePodsCIDR: 10.233.64.0/18 
  41.     kubeServiceCIDR: 10.233.0.0/18 
  42.   registry: 
  43.     registryMirrors: [] 
  44.     insecureRegistries: ["hub.kubeops.net"
  45.     privateRegistry: "hub.kubeops.net" 
  46.   addons: [] 
  47.  
  48.  
  49. --- 
  50. apiVersion: installer.kubesphere.io/v1alpha1 
  51. kind: ClusterConfiguration 
  52. metadata: 
  53.   name: ks-installer 
  54.   namespace: kubesphere-system 
  55.   labels: 
  56.     version: v3.0.0 
  57. spec: 
  58.   local_registry: "hub.kubeops.net" 
  59.   persistence: 
  60.     storageClass: "" 
  61.   authentication: 
  62.     jwtSecret: "" 
  63.   etcd: 
  64.     monitoring: true 
  65.     endpointIps: localhost 
  66.     port: 2379 
  67.     tlsEnable: true 
  68.   common: 
  69.     es: 
  70.       elasticsearchDataVolumeSize: 20Gi 
  71.       elasticsearchMasterVolumeSize: 4Gi 
  72.       elkPrefix: logstash 
  73.       logMaxAge: 7 
  74.     mysqlVolumeSize: 20Gi 
  75.     minioVolumeSize: 20Gi 
  76.     etcdVolumeSize: 20Gi 
  77.     openldapVolumeSize: 2Gi 
  78.     redisVolumSize: 2Gi 
  79.   console: 
  80.     enableMultiLogin: true  # enable/disable multi login 
  81.     port: 30880 
  82.   alerting: 
  83.     enabled: false 
  84.   auditing: 
  85.     enabled: false 
  86.   devops: 
  87.     enabled: false 
  88.     jenkinsMemoryLim: 2Gi 
  89.     jenkinsMemoryReq: 1500Mi 
  90.     jenkinsVolumeSize: 8Gi 
  91.     jenkinsJavaOpts_Xms: 512m 
  92.     jenkinsJavaOpts_Xmx: 512m 
  93.     jenkinsJavaOpts_MaxRAM: 2g 
  94.   events: 
  95.     enabled: false 
  96.     ruler: 
  97.       enabled: true 
  98.       replicas: 2 
  99.   logging: 
  100.     enabled: false 
  101.     logsidecarReplicas: 2 
  102.   metrics_server: 
  103.     enabled: true 
  104.   monitoring: 
  105.     prometheusMemoryRequest: 400Mi 
  106.     prometheusVolumeSize: 20Gi 
  107.   multicluster: 
  108.     clusterRole: none  # host | member | none 
  109.   networkpolicy: 
  110.     enabled: false 
  111.   notification: 
  112.     enabled: false 
  113.   openpitrix: 
  114.     enabled: false 
  115.   servicemesh: 
  116.     enabled: false 

 环境初始化

  1. ./kk init os -f config-sample.yaml 
  2. INFO[14:04:19 CST] Init operating system 
  3. INFO[14:04:20 CST] Start initializing kubesphere008 [10.26.31.121]  node=10.26.31.121 
  4. INFO[14:04:20 CST] Start initializing kubesphere001 [10.26.31.34]  node=10.26.31.34 
  5. INFO[14:04:20 CST] Start initializing kubesphere003 [10.26.31.42]  node=10.26.31.42 
  6. INFO[14:04:20 CST] Start initializing kubesphere005 [10.26.31.118]  node=10.26.31.118 
  7. INFO[14:04:20 CST] Start initializing kubesphere006 [10.26.31.119]  node=10.26.31.119 
  8. INFO[14:04:20 CST] Start initializing kubesphere004 [10.26.31.46]  node=10.26.31.46 
  9. INFO[14:04:20 CST] Start initializing kubesphere007 [10.26.31.120]  node=10.26.31.120 
  10. INFO[14:04:20 CST] Start initializing kubesphere002 [10.26.31.36]  node=10.26.31.36 
  11. INFO[14:06:34 CST] Complete initialization kubesphere005 [10.26.31.118]  node=10.26.31.118 
  12. INFO[14:06:56 CST] Complete initialization kubesphere002 [10.26.31.36]  node=10.26.31.36 
  13. INFO[14:07:04 CST] Complete initialization kubesphere006 [10.26.31.119]  node=10.26.31.119 
  14. INFO[14:07:04 CST] Complete initialization kubesphere007 [10.26.31.120]  node=10.26.31.120 
  15. INFO[14:07:07 CST] Complete initialization kubesphere003 [10.26.31.42]  node=10.26.31.42 
  16. INFO[14:07:11 CST] Complete initialization kubesphere004 [10.26.31.46]  node=10.26.31.46 
  17. INFO[14:08:23 CST] Complete initialization kubesphere001 [10.26.31.34]  node=10.26.31.34 
  18. INFO[14:10:57 CST] Complete initialization kubesphere008 [10.26.31.121]  node=10.26.31.121 
  19. INFO[14:10:57 CST] Init operating system successful. 

 部署

以上准备工作完成且再次检查配置文件无误后,执行安装。

  1. ./kk create cluster -f config-sample.yaml 
  2. +-------------------------+------+------+---------+----------+-------+-------+-----------+--------+------------+-------------+------------------+--------------+ 
  3. name                    | sudo | curl | openssl | ebtables | socat | ipset | conntrack | docker | nfs client | ceph client | glusterfs client | time         | 
  4. +-------------------------+------+------+---------+----------+-------+-------+-----------+--------+------------+-------------+------------------+--------------+ 
  5. | kubesphere005 | y    | y    | y       | y        | y     | y     | y         | y      | y          | y           | y                | CST 14:16:55 | 
  6. | kubesphere006 | y    | y    | y       | y        | y     | y     | y         | y      | y          | y           | y                | CST 14:16:55 | 
  7. | kubesphere007 | y    | y    | y       | y        | y     | y     | y         | y      | y          | y           | y                | CST 14:16:55 | 
  8. | kubesphere004 | y    | y    | y       | y        | y     | y     | y         | y      | y          | y           | y                | CST 14:16:55 | 
  9. | kubesphere001 | y    | y    | y       | y        | y     | y     | y         | y      | y          | y           | y                | CST 14:16:55 | 
  10. | kubesphere003 | y    | y    | y       | y        | y     | y     | y         | y      | y          | y           | y                | CST 14:16:55 | 
  11. | kubesphere002 | y    | y    | y       | y        | y     | y     | y         | y      | y          | y           | y                | CST 14:16:55 | 
  12. | kubesphere008 | y    | y    | y       | y        | y     | y     | y         | y      | y          | y           | y                | CST 14:16:55 | 
  13. +-------------------------+------+------+---------+----------+-------+-------+-----------+--------+------------+-------------+------------------+--------------+ 
  14.  
  15. This is a simple check of your environment. 
  16. Before installation, you should ensure that your machines meet all requirements specified at 
  17. https://github.com/kubesphere/kubekey#requirements-and-recommendations 
  18.  
  19. Continue this installation? [yes/no]: yes 
  20. INFO[14:17:25 CST] Downloading Installation Files 
  21. INFO[14:17:25 CST] Downloading kubeadm ... 
  22.  
  23. ************************************************** 
  24. ##################################################### 
  25. ###              Welcome to KubeSphere!           ### 
  26. ##################################################### 
  27.  
  28. Console: http://10.26.31.34:30880 
  29. Account: admin 
  30. Password: P@88w0rd 
  31.  
  32. NOTES: 
  33.   1. After logging into the console, please check the 
  34.      monitoring status of service components in 
  35.      the "Cluster Management". If any service is not 
  36.      ready, please wait patiently until all components  
  37.      are ready. 
  38.   2. Please modify the default password after login. 
  39.  
  40. ##################################################### 
  41. https://kubesphere.io             2021-02-05 15:47:21 
  42. ##################################################### 

 至此kubesphere安装成功,可以通过浏览器访问http://10.26.31.34:30880 验证

验证

您可以使用默认的帐户和密码 admin/P@88w0rd 登录 KubeSphere 控制台并开始使用 KubeSphere。请在登录后修改默认密码。


登录后如下图

 现在就可以开始您的kubesphere之旅了,更多详情请参见官网。

 

责任编辑:姜华 来源: 今日头条
相关推荐

2021-10-08 08:59:32

CentOSAll-in-One KubeSphere

2022-07-13 08:49:27

DevOpsKubeSphere

2022-08-08 07:05:36

KubeSphere分级管理

2022-06-30 11:36:10

KubeSphereGitOpsLinux

2023-01-06 07:55:44

外网IP部署

2011-01-21 14:03:35

Thunderbird安装

2021-11-26 15:07:53

FreeDOSLinux

2011-01-21 09:00:21

sendmail

2014-03-18 09:27:30

2019-04-30 11:22:04

KubeSphereForrester容器

2020-06-30 15:39:36

青云容器集群

2022-04-08 09:53:56

TektonJenkinsKubesphere

2023-03-30 09:17:42

KubesprayKubernetesLinux

2023-04-02 21:45:46

Vim文本编辑器

2020-10-10 20:30:05

Ansible自动化工具系统运维

2022-02-11 09:24:05

树莓派OpenWrt固定IP服务

2011-03-10 15:47:45

2017-06-09 14:22:31

AnsibleTiDB分布式数据库

2011-06-21 17:45:27

Qt Creator

2010-01-18 10:07:07

Freebsdbash
点赞
收藏

51CTO技术栈公众号