1. 3台裸机Linux就可以部署KubeSphere并且可以自动的安装好K8s环境

1.环境准备

  • 4c 8 g (master)
  • 8c 16g *2(work)

2.步骤

2.0环境准备(3台都执行)

  1. #设置hostname
  2. yum install -y socat
  3. yum install -y conntrack
  4. yum install -y ebtables
  5. yum install -y ipset

docker加速器配置

  1. sudo mkdir -p /etc/docker
  2. sudo tee /etc/docker/daemon.json <<-'EOF'
  3. {
  4. "registry-mirrors": ["https://vovncyjm.mirror.aliyuncs.com"],
  5. "exec-opts": ["native.cgroupdriver=systemd"],
  6. "log-driver": "json-file",
  7. "log-opts": {
  8. "max-size": "100m"
  9. },
  10. "storage-driver": "overlay2"
  11. }
  12. EOF
  13. sudo systemctl daemon-reload

2.1下载KubeKey

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

2.2创建集群配置文件

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

image.png
image.png

2.3创建集群

  1. ./kk create cluster -f config-sample.yaml

2.4查看进度

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

image.png
image.png

3.附录

ip需要更改为自己的内网ip

  1. apiVersion: kubekey.kubesphere.io/v1alpha1
  2. kind: Cluster
  3. metadata:
  4. name: sample
  5. spec:
  6. hosts:
  7. - {name: master, address: 192.168.0.4, internalAddress: 192.168.0.4, user: root, password: Gaoxi.123}
  8. - {name: node1, address: 192.168.0.3, internalAddress: 192.168.0.3, user: root, password: Gaoxi.123}
  9. - {name: node2, address: 192.168.0.2, internalAddress: 192.168.0.2, user: root, password: Gaoxi.123}
  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: []