在线安装 Kubernetes(k8s)集群和开源版KubeSphere

目录

[1. K8S前置条件准备](#1. K8S前置条件准备)

[2. 下载安装脚本kubekey](#2. 下载安装脚本kubekey)

[3. 创建配置](#3. 创建配置)

[4. 部署k8s集群和KubeSphere](#4. 部署k8s集群和KubeSphere)

[5. 部署后验证](#5. 部署后验证)

[5.1 KubeSphere登录验证](#5.1 KubeSphere登录验证)

[5.2 K8S验证](#5.2 K8S验证)


1. K8S前置条件准备

参考链接:

https://blog.csdn.net/lmzf2011/article/details/149253441?spm=1001.2014.3001.5501

2. 下载安装脚本kubekey

复制代码
[root@operation-k8s-test kubesphere]# wget https://github.com/kubesphere/kubekey/releases/download/v3.1.11/kubekey-v3.1.11-linux-amd64.tar.gz

下载完,解压压缩包

复制代码
[root@operation-k8s-test kubesphere]# ll
-rwxr-xr-x  1 root root 84046978 Aug 19 01:06 kk
-rw-r--r--  1 root root 38518611 Dec  3 17:33 kubekey-v3.1.11-linux-amd64.tar.gz

3. 创建配置

复制代码
./kk create config  --with-kubernetes v1.24.1   --with-kubesphere v3.4.1

自动生成配置文件config-sample.yaml,修改配置文件,修改后完整文件如下:

复制代码
apiVersion: kubekey.kubesphere.io/v1alpha2
kind: Cluster
metadata:
  name: sample
spec:
  hosts:
  - {name: operation-k8s-test, address: 10.10.14.222, internalAddress: 10.10.14.222, user: root, password: "Admin@123"}
  - {name: operation-k8s-node-test, address: 10.10.14.226, internalAddress: 10.10.14.226, user: root, password: "Admin@123"}
  roleGroups:
    etcd:
    - operation-k8s-test
    control-plane:
    - operation-k8s-test
    worker:
    - operation-k8s-test
    - operation-k8s-node-test
  controlPlaneEndpoint:
    ## Internal loadbalancer for apiservers
    # internalLoadbalancer: haproxy

    domain: lb.kubesphere.local
    address: ""
    port: 6443
  kubernetes:
    version: v1.24.1
    clusterName: cluster.local
    autoRenewCerts: true
    containerManager: containerd
  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.1
spec:
  persistence:
    storageClass: ""
  authentication:
    jwtSecret: ""
  local_registry: ""
  # 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: {}
      enabled: false
      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
  zone: ""

4. 部署k8s集群和KubeSphere

复制代码
[root@operation-k8s-test kubesphere]# export KKZONE=cn
[root@operation-k8s-test kubesphere]# ./kk create cluster  -f  config-sample.yaml  --with-kubernetes v1.24.1   --with-kubesphere v3.4.1

5. 部署后验证

5.1 KubeSphere登录验证

复制代码
NOTES:
Thank you for choosing KubeSphere Helm Chart.

Please be patient and wait for several seconds for the KubeSphere deployment to complete.

1. Wait for Deployment Completion

    Confirm that all KubeSphere components are running by executing the following command:

    kubectl get pods -n kubesphere-system
2. Access the KubeSphere Console

    Once the deployment is complete, you can access the KubeSphere console using the following URL:

    http://10.10.14.222:30880

3. Login to KubeSphere Console

    Use the following credentials to log in:

    Account: admin
    Password: P@88w0rd

5.2 K8S验证

相关推荐
冬奇Lab1 小时前
一天一个开源项目(第253篇):dsh-superagent —— DeepSeek 开源的“主动式”编程智能体原型,核心原则是少占人的注意力
人工智能·开源·资讯
字节跳动开源1 小时前
OpenViking 上线原生 3D 内容理解模型
数据库·开源
工业一体机老司机1 小时前
Docker部署工控机采集服务 Compose编排与开机自启
运维·docker·容器
車瑜9114 小时前
PM-Skills42个链式工作流-数据分析
开源·产品经理·pm·pm-skills
miaobinfei7 小时前
docker拉取dify镜像,执行docker compose up -d 报错
运维·docker·容器
kobe_OKOK_8 小时前
docker compose命名卷 映射到宿主机的路径
运维·docker·容器
m4Rk_8 小时前
【论文阅读】Agent 记忆机制(119):EvoLife——让具身 Agent 把主动问到的答案沉淀为可复用的空间经验
论文阅读·人工智能·学习·开源·github
fly-iot9 小时前
【FDE知识库】(4):企业知识库怎么选型,开源知识库分享几个,选择开源协议友好的版本,开发wiki-go项目
golang·开源·开源协议
无言听风雨丶9 小时前
Linux 容器本质探秘:Cgroup 与 Namespace 深度解析与实战
linux·运维·服务器·kubernetes
分布式存储与RustFS10 小时前
JuiceFS 接 RustFS 当数据后端:把对象存储挂成本地文件系统
运维·云原生·开源·对象存储·分布式存储·s3·性能基准