搭建KubeSphere v3.3.2集群教程

2023-03-08
3665
1
1

温馨提示:本文最后更新于 2023-07-07,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

bf802e90c684ec85da0447ade0d8bbb7_53

KubeSphere 是在 Kubernetes 之上构建的以应用为中心的多租户容器平台,提供全栈的 IT 自动化运维的能力,简化企业的 DevOps 工作流。KubeSphere 提供了运维友好的向导式操作界面,帮助企业快速构建一个强大和功能丰富的容器云平台

官网:https://kubesphere.io/zh/
All-in-One安装教程:https://kubesphere.io/zh/docs/v3.3/quick-start/all-in-one-on-linux/

本文参考使用 KubeKey 内置 HAproxy 创建高可用集群教程安装

如果需要跨网络、跨云组节点,可以先使用VPN组网,参考本文omniedge VPN异地组网工具使用教程

  • 使用ubuntu 20.04 LTS系统安装
  • KubeKey版本 v3.0.7
  • kubernetes版本 v1.23.15
  • kubesphere版本 v3.3.2
  • Docker版本 v23.0.1

1. 初始化服务器和安装必要包

参考本文https://4xx.me/archives/125.html
需关闭防火墙、各节点同步时间

apt install -y socat conntrack 

使用一键脚本安装Docker并配置镜像加速,参考本文https://4xx.me/archives/63.html

2. 下载KubeKey工具

# 配置为国内源加速下载
export KKZONE=cn
curl -sfL https://get-kk.kubesphere.io | VERSION=v3.0.7 sh -
chmod +x kk

3. 创建示例配置文件并修改

# 创建示例配置文件
./kk create config --with-kubernetes v1.23.15 --with-kubesphere v3.3.2 -f config-sample.yaml

我的配置文件


apiVersion: kubekey.kubesphere.io/v1alpha2
kind: Cluster
metadata:
  name: sample
spec:
  hosts:
  - {name: master, address: 124.221.168.1, internalAddress: 100.100.0.2, port: 1121, user: root, password: root}
  - {name: node1, address: 192.168.116.166, internalAddress: 100.100.0.5, port: 22, user: root, password: root}
  roleGroups:
    etcd:
    - master
    control-plane: 
    - master
    worker:
    - master
    - node1
  controlPlaneEndpoint:
    ## Internal loadbalancer for apiservers 
    internalLoadbalancer: haproxy

    domain: lb.kubesphere.local
    address: ""
    port: 6443
  kubernetes:
    version: v1.23.15
    clusterName: cluster.local
    apiserverArgs:
    - service-node-port-range=1000-65535
    autoRenewCerts: true
    containerManager: docker
  etcd:
    type: kubekey
  network:
    plugin: calico
    kubePodsCIDR: 10.233.64.0/18
    kubeServiceCIDR: 10.233.0.0/18
    ## multus support. https://github.com/k8snetworkplumbingwg/multus-cni
    multusCNI:
      enabled: false
  registry:
    privateRegistry: ""
    namespaceOverride: ""
    registryMirrors: []
    insecureRegistries: []
  addons: []



---
apiVersion: installer.kubesphere.io/v1alpha1
kind: ClusterConfiguration
metadata:
  name: ks-installer
  namespace: kubesphere-system
  labels:
    version: v3.3.2
spec:
  persistence:
    storageClass: ""
  authentication:
    jwtSecret: ""
  zone: ""
  local_registry: ""
  namespace_override: ""
  # dev_tag: ""
  etcd:
    monitoring: false
    endpointIps: localhost
    port: 2379
    tlsEnable: true
  common:
    core:
      console:
        enableMultiLogin: true
        port: 30880
        type: NodePort
    # apiserver:
    #  resources: {}
    # controllerManager:
    #  resources: {}
    redis:
      enabled: false
      volumeSize: 2Gi
    openldap:
      enabled: false
      volumeSize: 2Gi
    minio:
      volumeSize: 20Gi
    monitoring:
      # type: external
      endpoint: http://prometheus-operated.kubesphere-monitoring-system.svc:9090
      GPUMonitoring:
        enabled: false
    gpu:
      kinds:
      - resourceName: "nvidia.com/gpu"
        resourceType: "GPU"
        default: true
    es:
      # master:
      #   volumeSize: 4Gi
      #   replicas: 1
      #   resources: {}
      # data:
      #   volumeSize: 20Gi
      #   replicas: 1
      #   resources: {}
      logMaxAge: 7
      elkPrefix: logstash
      basicAuth:
        enabled: false
        username: ""
        password: ""
      externalElasticsearchHost: ""
      externalElasticsearchPort: ""
  alerting:
    enabled: true
    # thanosruler:
    #   replicas: 1
    #   resources: {}
  auditing:
    enabled: false
    # operator:
    #   resources: {}
    # webhook:
    #   resources: {}
  devops:
    enabled: false
    # resources: {}
    jenkinsMemoryLim: 8Gi
    jenkinsMemoryReq: 4Gi
    jenkinsVolumeSize: 8Gi
  events:
    enabled: false
    # operator:
    #   resources: {}
    # exporter:
    #   resources: {}
    # ruler:
    #   enabled: true
    #   replicas: 2
    #   resources: {}
  logging:
    enabled: false
    logsidecar:
      enabled: true
      replicas: 2
      # resources: {}
  metrics_server:
    enabled: false
  monitoring:
    storageClass: ""
    node_exporter:
      port: 9100
      # resources: {}
    # kube_rbac_proxy:
    #   resources: {}
    # kube_state_metrics:
    #   resources: {}
    # prometheus:
    #   replicas: 1
    #   volumeSize: 20Gi
    #   resources: {}
    #   operator:
    #     resources: {}
    # alertmanager:
    #   replicas: 1
    #   resources: {}
    # notification_manager:
    #   resources: {}
    #   operator:
    #     resources: {}
    #   proxy:
    #     resources: {}
    gpu:
      nvidia_dcgm_exporter:
        enabled: false
        # resources: {}
  multicluster:
    clusterRole: none
  network:
    networkpolicy:
      enabled: false
    ippool:
      type: none
    topology:
      type: none
  openpitrix:
    store:
      enabled: true
  servicemesh:
    enabled: false
    istio:
      components:
        ingressGateways:
        - name: istio-ingressgateway
          enabled: false
        cni:
          enabled: false
  edgeruntime:
    enabled: false
    kubeedge:
      enabled: false
      cloudCore:
        cloudHub:
          advertiseAddress:
            - ""
        service:
          cloudhubNodePort: "30000"
          cloudhubQuicNodePort: "30001"
          cloudhubHttpsNodePort: "30002"
          cloudstreamNodePort: "30003"
          tunnelNodePort: "30004"
        # resources: {}
        # hostNetWork: false
      iptables-manager:
        enabled: true
        mode: "external"
        # resources: {}
      # edgeService:
      #   resources: {}
  terminal:
    timeout: 600

只需修改spec:hostsspec:roleGroups

4. 使用配置文件安装KubeSphere

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

看到类似如下信息,则表示安装成功

#####################################################
###              Welcome to KubeSphere!           ###
#####################################################

Console: http://192.168.0.3:30880
Account: admin
Password: P@88w0rd
...

使用ip+端口访问控制台即可

5. 一键卸载脚本

./kk delete cluster -f config-sample.yaml

注意事项

  • 节点最好有4G以上内存,不然会卡,用着不顺畅
  • 各节点时间必须同步
  • 不能开启swap虚拟内存
  • 如果需要开启devops流水线,最好16G内存以上

安装体验了下,对我来说使用没rancher简洁,资源占用太多,端口映射太麻烦。最后还是换回了rancher2.4


评论

Polar.
最重要的,是拥有跟随内心与直觉的勇气

文章目录