1、准备三台服务器

  • 4c8g (master)
  • 8c16g * 2(worker)
  • centos7.9
  • 内网互通
  • 每个机器有自己域名
  • 防火墙开放30000~32767端口

2、使用KubeKey创建集群

1、下载KubeKey

  1. export KKZONE=cn
  2. curl -sfL https://get-kk.kubesphere.io | VERSION=v1.1.1 sh -
  3. chmod +x kk

2、创建集群配置文件

  1. ./kk create config --with-kubernetes v1.20.4 --with-kubesphere v3.1.1

3、创建集群

  1. ./kk create cluster -f config-sample.yaml
  2. #可能需要下面命令
  3. yum install -y conntrack

4、查看进度

  1. kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f

附录

1、config-sample.yaml示例文件

  1. apiVersion: kubekey.kubesphere.io/v1alpha1
  2. kind: Cluster
  3. metadata:
  4. name: sample
  5. spec:
  6. hosts:
  7. - {name: master, address: 10.140.126.6, internalAddress: 10.140.126.6, user: root, password: Hello777}
  8. - {name: node1, address: 10.140.122.56, internalAddress: 10.140.122.56, user: root, password: Hello777}
  9. - {name: node2, address: 10.140.122.39, internalAddress: 10.140.122.39, user: root, password: Hello777}
  10. roleGroups:
  11. etcd:
  12. - master
  13. master:
  14. - master
  15. worker:
  16. - node1
  17. - node2
  18. controlPlaneEndpoint:
  19. domain: lb.kubesphere.local
  20. address: ""
  21. port: 6443
  22. kubernetes:
  23. version: v1.20.4
  24. imageRepo: kubesphere
  25. clusterName: cluster.local
  26. network:
  27. plugin: calico
  28. kubePodsCIDR: 10.233.64.0/18
  29. kubeServiceCIDR: 10.233.0.0/18
  30. registry:
  31. registryMirrors: []
  32. insecureRegistries: []
  33. addons: []
  34. ---
  35. apiVersion: installer.kubesphere.io/v1alpha1
  36. kind: ClusterConfiguration
  37. metadata:
  38. name: ks-installer
  39. namespace: kubesphere-system
  40. labels:
  41. version: v3.1.1
  42. spec:
  43. persistence:
  44. storageClass: ""
  45. authentication:
  46. jwtSecret: ""
  47. zone: ""
  48. local_registry: ""
  49. etcd:
  50. monitoring: false
  51. endpointIps: localhost
  52. port: 2379
  53. tlsEnable: true
  54. common:
  55. redis:
  56. enabled: false
  57. redisVolumSize: 2Gi
  58. openldap:
  59. enabled: false
  60. openldapVolumeSize: 2Gi
  61. minioVolumeSize: 20Gi
  62. monitoring:
  63. endpoint: http://prometheus-operated.kubesphere-monitoring-system.svc:9090
  64. es:
  65. elasticsearchMasterVolumeSize: 4Gi
  66. elasticsearchDataVolumeSize: 20Gi
  67. logMaxAge: 7
  68. elkPrefix: logstash
  69. basicAuth:
  70. enabled: false
  71. username: ""
  72. password: ""
  73. externalElasticsearchUrl: ""
  74. externalElasticsearchPort: ""
  75. console:
  76. enableMultiLogin: true
  77. port: 30880
  78. alerting:
  79. enabled: false
  80. # thanosruler:
  81. # replicas: 1
  82. # resources: {}
  83. auditing:
  84. enabled: false
  85. devops:
  86. enabled: false
  87. jenkinsMemoryLim: 2Gi
  88. jenkinsMemoryReq: 1500Mi
  89. jenkinsVolumeSize: 8Gi
  90. jenkinsJavaOpts_Xms: 512m
  91. jenkinsJavaOpts_Xmx: 512m
  92. jenkinsJavaOpts_MaxRAM: 2g
  93. events:
  94. enabled: false
  95. ruler:
  96. enabled: true
  97. replicas: 2
  98. logging:
  99. enabled: false
  100. logsidecar:
  101. enabled: true
  102. replicas: 2
  103. metrics_server:
  104. enabled: false
  105. monitoring:
  106. storageClass: ""
  107. prometheusMemoryRequest: 400Mi
  108. prometheusVolumeSize: 20Gi
  109. multicluster:
  110. clusterRole: none
  111. network:
  112. networkpolicy:
  113. enabled: false
  114. ippool:
  115. type: none
  116. topology:
  117. type: none
  118. openpitrix:
  119. store:
  120. enabled: false
  121. servicemesh:
  122. enabled: false
  123. kubeedge:
  124. enabled: false
  125. cloudCore:
  126. nodeSelector: {"node-role.kubernetes.io/worker": ""}
  127. tolerations: []
  128. cloudhubPort: "10000"
  129. cloudhubQuicPort: "10001"
  130. cloudhubHttpsPort: "10002"
  131. cloudstreamPort: "10003"
  132. tunnelPort: "10004"
  133. cloudHub:
  134. advertiseAddress:
  135. - ""
  136. nodeLimit: "100"
  137. service:
  138. cloudhubNodePort: "30000"
  139. cloudhubQuicNodePort: "30001"
  140. cloudhubHttpsNodePort: "30002"
  141. cloudstreamNodePort: "30003"
  142. tunnelNodePort: "30004"
  143. edgeWatcher:
  144. nodeSelector: {"node-role.kubernetes.io/worker": ""}
  145. tolerations: []
  146. edgeWatcherAgent:
  147. nodeSelector: {"node-role.kubernetes.io/worker": ""}
  148. tolerations: []