当前位置: 首页 > news >正文

[云原生] [kubernetes] 基于K8S安装kubesphere

简介

KubeSphere 是在 Kubernetes 之上构建的面向云原生应用的分布式操作系统,完全开源,支持多云与多集群管理,提供全栈的 IT 自动化运维能力,简化企业的 DevOps 工作流。它的架构可以非常方便地使第三方应用与云原生生态组件进行即插即用 (plug-and-play) 的集成。

作为全栈的多租户容器平台,KubeSphere 提供了运维友好的向导式操作界面,帮助企业快速构建一个强大和功能丰富的容器云平台。KubeSphere 为用户提供构建企业级 Kubernetes 环境所需的多项功能,例如多云与多集群管理、Kubernetes 资源管理、DevOps、应用生命周期管理、微服务治理(服务网格)、日志查询与收集、服务与网络、多租户管理、监控告警、事件与审计查询、存储管理、访问权限控制、GPU 支持、网络策略、镜像仓库管理以及安全管理等。

方法 / 步骤

一:前置环境

本文环境:CentOS7.9 / K8S 1.20.x

1.1 查看是否安装K8S

如果没有安装可以参考 安装K8S 进行安装

# 查看K8S版本
kubectl version
# 节点状态
kubectl get nodes

在这里插入图片描述

k8s与kubesphere版本对应关系:

kubespherek8s版本要求详情地址
v1.0.0不支持k8s基础上安装https://v1-0.docs.kubesphere.io/docs/zh-CN/installation/intro/
v2.0.x1.13.0 ≤ K8s Version < 1.16https://v2-0.docs.kubesphere.io/docs/zh-CN/installation/install-on-k8s/
V2.1.x1.15.x ≤ K8s version ≤ 1.17.xhttps://v2-1.docs.kubesphere.io/docs/zh-CN/installation/prerequisites/
V3.0.01.15.x,1.16.x,1.17.x,1.18.xhttps://v3-0.docs.kubesphere.io/zh/docs/installing-on-kubernetes/introduction/prerequisites/
V3.1.xv1.17.x,v1.18.x,v1.19.x 或 v1.20.x。https://v3-1.docs.kubesphere.io/zh/docs/installing-on-kubernetes/introduction/prerequisites/
V3.2.xv1.19.x,v1.20.x,v1.21.x 或 v1.22.x(实验性支持)。https://kubesphere.io/zh/docs/installing-on-kubernetes/introduction/prerequisites/
V3.3.xv1.19.x,v1.20.x,v1.21.x,v1.22.x 或 v1.23.x(实验性支持))。https://kubesphere.io/zh/docs/installing-on-kubernetes/introduction/prerequisites/

1.2 检查集群中是否有默认 StorageClass

默认 StorageClass 是安装 KubeSphere 的前提条件,如果没有安装,可以参考文章 K8S安装存储类 - StorageClass 进行安装

# 查看是否安装 StorageClass
kubectl get sc

在这里插入图片描述

二: 安装KubeSphere (最小化)

官网找到对应的版本,先进行最小化安装

2.1 最小化安装

cd /usr/local
# 先下载yaml文件
wget https://github.com/kubesphere/ks-installer/releases/download/v3.3.0/kubesphere-installer.yaml
wget https://github.com/kubesphere/ks-installer/releases/download/v3.3.0/cluster-configuration.yaml

kubectl apply -f kubesphere-installer.yaml
kubectl apply -f cluster-configuration.yaml

2.2 检查安装日志:

kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l 'app in (ks-install, ks-installer)' -o jsonpath='{.items[0].metadata.name}') -f
  • 安装成功
    在这里插入图片描述

2.3 查看相关的命名空间是否正常运行

使用 kubectl get pod --all-namespaces 查看所有 Pod 在 KubeSphere 相关的命名空间是否正常运行。如果是正常运行,请通过以下命令来检查控制台的端口(默认为 30880)

kubectl get svc/ks-console -n kubesphere-system

2.4 安装成功访问控制台

确保在安全组中打开了 30880 端口,通过 NodePort (IP:30880) 使用默认帐户和密码 (admin/P@88w0rd) 访问 Web 控制台。

在这里插入图片描述

三:启用相关插件

  • 平台管理–> 集群管理–> 定制资源定义–> 输入 cluster 进行搜索
    在这里插入图片描述

  • 选择 ClusterConfiguration
    在这里插入图片描述

  • 在ks-installer的配置项后面点击编辑。
    在这里插入图片描述

插件介绍

说明:从 2.1.0 版本开始,KubeSphere 解耦了一些核心功能组件。这些组件设计成了可插拔式,您可以在安装之前或之后启用它们。如果您不启用它们,KubeSphere 会默认以最小化进行安装部署。不同的可插拔组件部署在不同的命名空间中。

上面是官方解释为啥需要修改cluster-configuration集群配置。
其实修改cluster-configuration集群配置就是额外启用一些KubeSphere插件,比如:启用DevOps的相关插件,开启ectd的监控功能,开启告警功能…

在 cluster-configuration.yaml中指定我们需要开启的功能参照官网 启用可插拔组件

修改如下:我们重点是改动spec下的字段,遇见"false"改为"true",但是几个不用改动,如下说明:

apiVersion: installer.kubesphere.io/v1alpha1
kind: ClusterConfiguration
metadata:
  name: ks-installer
  namespace: kubesphere-system
  labels:
    version: v3.1.1
spec:
  persistence:
    storageClass: ""        #这里保持默认即可,因为我们有了默认的存储类
  authentication:
    jwtSecret: ""           # Keep the jwtSecret consistent with the Host Cluster. Retrieve the jwtSecret by executing "kubectl -n kubesphere-system get cm kubesphere-config -o yaml | grep -v "apiVersion" | grep jwtSecret" on the Host Cluster.
  local_registry: ""        # Add your private registry address if it is needed.
  etcd:
    monitoring: true       # 改为"true",表示开启etcd的监控功能
    endpointIps: 192.168.11.24  # 改为自己的master节点IP地址
    port: 2379              # etcd port.
    tlsEnable: true
  common:
    redis:
      enabled: true         #改为"true",开启redis功能
    openldap:
      enabled: true         #改为"true",开启轻量级目录协议
    minioVolumeSize: 20Gi # Minio PVC size.
    openldapVolumeSize: 2Gi   # openldap PVC size.
    redisVolumSize: 2Gi # Redis PVC size.
    monitoring:
      # type: external   # Whether to specify the external prometheus stack, and need to modify the endpoint at the next line.
      endpoint: http://prometheus-operated.kubesphere-monitoring-system.svc:9090 # Prometheus endpoint to get metrics data.
    es:   # Storage backend for logging, events and auditing.
      # elasticsearchMasterReplicas: 1   # The total number of master nodes. Even numbers are not allowed.
      # elasticsearchDataReplicas: 1     # The total number of data nodes.
      elasticsearchMasterVolumeSize: 4Gi   # The volume size of Elasticsearch master nodes.
      elasticsearchDataVolumeSize: 20Gi    # The volume size of Elasticsearch data nodes.
      logMaxAge: 7                     # Log retention time in built-in Elasticsearch. It is 7 days by default.
      elkPrefix: logstash              # The string making up index names. The index name will be formatted as ks-<elk_prefix>-log.
      basicAuth:
        enabled: false
        username: ""
        password: ""
      externalElasticsearchUrl: ""
      externalElasticsearchPort: ""
  console:
    enableMultiLogin: false# Enable or disable simultaneous logins. It allows different users to log in with the same account at the same time.
    port: 30880
  alerting:                # (CPU: 0.1 Core, Memory: 100 MiB) It enables users to customize alerting policies to send messages to receivers in time with different time intervals and alerting levels to choose from.
    enabled: false        # 改为"true",开启告警功能
    # thanosruler:
    #   replicas: 1
    #   resources: {}
  auditing:                # Provide a security-relevant chronological set of records,recording the sequence of activities happening on the platform, initiated by different tenants.
    enabled:false        #  改为"true",开启审计功能
  devops:                  # (CPU: 0.47 Core, Memory: 8.6 G) Provide an out-of-the-box CI/CD system based on Jenkins, and automated workflow tools including Source-to-Image & Binary-to-Image.
    enabled: true             # 改为"true",开启DevOps功能
    jenkinsMemoryLim: 2Gi      # Jenkins memory limit.
    jenkinsMemoryReq: 1500Mi   # Jenkins memory request.
    jenkinsVolumeSize: 8Gi     # Jenkins volume size.
    jenkinsJavaOpts_Xms: 512m  # The following three fields are JVM parameters.
    jenkinsJavaOpts_Xmx: 512m
    jenkinsJavaOpts_MaxRAM: 2g
  events:                  # Provide a graphical web console for Kubernetes Events exporting, filtering and alerting in multi-tenant Kubernetes clusters.
    enabled:false         # 改为"true",开启集群的事件功能
    ruler:
      enabled: false
      replicas: 2
  logging:                 # (CPU: 57 m, Memory: 2.76 G) Flexible logging functions are provided for log query, collection and management in a unified console. Additional log collectors can be added, such as Elasticsearch, Kafka and Fluentd.
    enabled: true        # 改为"true",开启日志功能
    logsidecar:
      enabled: true
      replicas: 2
  metrics_server:                    # (CPU: 56 m, Memory: 44.35 MiB) It enables HPA (Horizontal Pod Autoscaler).
    enabled: false                   # 这个不用修改,因为在上面我们已经安装过了,如果这里开启,镜像是官方的,会拉取镜像失败
  monitoring:
    storageClass: ""                 # If there is an independent StorageClass you need for Prometheus, you can specify it here. The default StorageClass is used by default.
    # prometheusReplicas: 1          # Prometheus replicas are responsible for monitoring different segments of data source and providing high availability.
    prometheusMemoryRequest: 400Mi   # Prometheus request memory.
    prometheusVolumeSize: 20Gi       # Prometheus PVC size.
    # alertmanagerReplicas: 1          # AlertManager Replicas.
  multicluster:
    clusterRole: none  # host | member | none  # You can install a solo cluster, or specify it as the Host or Member Cluster.
  network:
    networkpolicy: # Network policies allow network isolation within the same cluster, which means firewalls can be set up between certain instances (Pods).
      # Make sure that the CNI network plugin used by the cluster supports NetworkPolicy. There are a number of CNI network plugins that support NetworkPolicy, including Calico, Cilium, Kube-router, Romana and Weave Net.
      enabled: true # 改为"true",开启网络策略
    ippool: # Use Pod IP Pools to manage the Pod network address space. Pods to be created can be assigned IP addresses from a Pod IP Pool.
      type: none #如果你的网络插件是calico,需要修改为"calico",这里我是Flannel,保持默认。
    topology: # Use Service Topology to view Service-to-Service communication based on Weave Scope.
      type: none # Specify "weave-scope" for this field to enable Service Topology. "none" means that Service Topology is disabled.
  openpitrix: # An App Store that is accessible to all platform tenants. You can use it to manage apps across their entire lifecycle.
    store:
      enabled: true # 改为"true",开启应用商店
  servicemesh:         # (0.3 Core, 300 MiB) Provide fine-grained traffic management, observability and tracing, and visualized traffic topology.
    enabled: true     # 改为"true",开启微服务治理
  kubeedge:          # Add edge nodes to your cluster and deploy workloads on edge nodes.
    enabled: false   # 这个就不修改了,这个是边缘服务,我们也没有边缘的设备。
    cloudCore:
      nodeSelector: {"node-role.kubernetes.io/worker": ""}
      tolerations: []
      cloudhubPort: "10000"
      cloudhubQuicPort: "10001"
      cloudhubHttpsPort: "10002"
      cloudstreamPort: "10003"
      tunnelPort: "10004"
      cloudHub:
        advertiseAddress: # At least a public IP address or an IP address which can be accessed by edge nodes must be provided.
          - ""            # Note that once KubeEdge is enabled, CloudCore will malfunction if the address is not provided.
        nodeLimit: "100"
      service:
        cloudhubNodePort: "30000"
        cloudhubQuicNodePort: "30001"
        cloudhubHttpsNodePort: "30002"
        cloudstreamNodePort: "30003"
        tunnelNodePort: "30004"
    edgeWatcher:
      nodeSelector: {"node-role.kubernetes.io/worker": ""}
      tolerations: []
      edgeWatcherAgent:
        nodeSelector: {"node-role.kubernetes.io/worker": ""}
        tolerations: []

在这里插入图片描述

参考资料 & 致谢

相关文章:

  • docker部署服务初体验
  • 每日学一个设计模式23——解释器模式
  • C. Minimum Notation #823 div2
  • Python 教程之 Numpy(2)—— 数组
  • 【踩坑】在linux服务器上配置mysql并开放3306端口
  • JAVA基础(四十九)——自定义泛型
  • MySQL中的不等于
  • 【Redis】Redis高级:主从
  • 二进制方式安装k8s高可用集群(一)
  • Exception in thread main org.apache.ibatis.exceptions.PersistenceException:报错解决
  • mysql 数据库使用分享
  • @NoArgsConstructor和@AllArgsConstructor,@Builder
  • 比较Hive数据库与MySQL数据库
  • PMP每日一练 | 考试不迷路-9.26(包含敏捷+多选)
  • 【Linux修炼】1.常见指令(上)
  • [iOS]Core Data浅析一 -- 启用Core Data
  • [译]Python中的类属性与实例属性的区别
  • 11111111
  • axios请求、和返回数据拦截,统一请求报错提示_012
  • canvas 五子棋游戏
  • CSS选择器——伪元素选择器之处理父元素高度及外边距溢出
  • hadoop集群管理系统搭建规划说明
  • Vue--数据传输
  • Webpack入门之遇到的那些坑,系列示例Demo
  • 阿里中间件开源组件:Sentinel 0.2.0正式发布
  • 测试如何在敏捷团队中工作?
  • 从重复到重用
  • 分布式任务队列Celery
  • 基于web的全景—— Pannellum小试
  • 前端攻城师
  • 深入浏览器事件循环的本质
  • 手机app有了短信验证码还有没必要有图片验证码?
  • 思否第一天
  • 算法-插入排序
  • 线上 python http server profile 实践
  • 限制Java线程池运行线程以及等待线程数量的策略
  • 想晋级高级工程师只知道表面是不够的!Git内部原理介绍
  • 自动记录MySQL慢查询快照脚本
  • 智能情侣枕Pillow Talk,倾听彼此的心跳
  • (2)(2.4) TerraRanger Tower/Tower EVO(360度)
  • (C语言)字符分类函数
  • (附源码)springboot家庭装修管理系统 毕业设计 613205
  • (附源码)springboot青少年公共卫生教育平台 毕业设计 643214
  • (七)理解angular中的module和injector,即依赖注入
  • (三)模仿学习-Action数据的模仿
  • (十六)Flask之蓝图
  • (详细版)Vary: Scaling up the Vision Vocabulary for Large Vision-Language Models
  • (转)Oracle 9i 数据库设计指引全集(1)
  • .aanva
  • .net core 调用c dll_用C++生成一个简单的DLL文件VS2008
  • .NET高级面试指南专题十一【 设计模式介绍,为什么要用设计模式】
  • .NET开源项目介绍及资源推荐:数据持久层 (微软MVP写作)
  • .NET平台开源项目速览(15)文档数据库RavenDB-介绍与初体验
  • /var/log/cvslog 太大
  • [《百万宝贝》观后]To be or not to be?