k8s集群搭建

转载
链接: k8s集群搭建

一、集群搭建

1.1 使用kubesphere搭建集群

在部署集群之前,我已经有三台干净的机器(静态ip、防火墙关闭等)。之后采用kubesphere进行搭建。在 VMware vSphere 安装 KubeSphere

先执行以下命令以确保您从正确的区域下载 KubeKey。

export KKZONE=cn

执行以下命令下载 KubeKey。

curl -sfL https://get-kk.kubesphere.io | VERSION=v3.0.13 sh -
chmod +x kk


./kk create config --with-kubernetes v1.22.12 --with-kubesphere v3.4.0
会创建出一个配置文件名为:config-sample.yaml 

我们需要对这个config-sample.yaml 修改为自己机器的参数。

下边是我的kubesphere的创建文件。命名为 config-sample.yaml

apiVersion: kubekey.kubesphere.io/v1alpha2
kind: Cluster
metadata:
  name: sample
spec:
  hosts:

  - {name: master,address: 192.168.20.10, internalAddress: 192.168.20.10, user: root, password: "123456"}

  - {name: node1, address: 192.168.20.11, internalAddress: 192.168.20.11, user: root, password: "123456"}

  - {name: node2, address: 192.168.20.12, internalAddress: 192.168.20.12, user: root, password: "123456"}
    roleGroups:
    etcd:

    - master
      control-plane: 
    - master
      worker:
    - node1
    - node2
      controlPlaneEndpoint:

    ## Internal loadbalancer for apiservers 

    # internalLoadbalancer: haproxy

    domain: lb.kubesphere.local
    address: ""
    port: 6443
      kubernetes:
    version: v1.23.10
    clusterName: cluster.local
    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.4.0
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
​      enableHA: 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: ""
​    opensearch:

      # master:

      #   volumeSize: 4Gi

      #   replicas: 1

      #   resources: {}

      # data:

      #   volumeSize: 20Gi

      #   replicas: 1

      #   resources: {}

​      enabled: true
​      logMaxAge: 7
​      opensearchPrefix: whizard
​      basicAuth:
​        enabled: true
​        username: "admin"
​        password: "admin"
​      externalOpensearchHost: ""
​      externalOpensearchPort: ""
​      dashboard:
​        enabled: false
  alerting:
​    enabled: false

    # thanosruler:

    #   replicas: 1

    #   resources: {}

  auditing:
    enabled: false

    # operator:

    #   resources: {}

    # webhook:

    #   resources: {}

  devops:
    enabled: false
    jenkinsCpuReq: 0.5
    jenkinsCpuLim: 1
    jenkinsMemoryReq: 4Gi
    jenkinsMemoryLim: 4Gi
    jenkinsVolumeSize: 16Gi
  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: false
  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: {}

  gatekeeper:
    enabled: false

    # controller_manager:

    #   resources: {}

    # audit:

    #   resources: {}

  terminal:
    timeout: 600
 开始安装k8s集群: ./kk create cluster -f config-sample.yaml

之后会在控制台看到部署的k8s集群的地址、账号、密码等。

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值