首页 > 其他分享 >KubeSphere的三种部署方式

KubeSphere的三种部署方式

时间:2024-09-24 16:48:12浏览次数:3  
标签:name 部署 KubeSphere server metrics nfs 三种 k8s

KubeSphere

参考官方网站:什么是 KubeSphere

概述

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

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

KubeSphere 还开源了 KubeKey 帮助企业一键在公有云或数据中心快速搭建 Kubernetes 集群,提供单节点、多节点、集群插件安装,以及集群升级与运维。

开发运维友好

KubeSphere 为用户屏蔽了基础设施底层复杂的技术细节,帮助企业在各类基础设施之上无缝地部署、更新、迁移和管理现有的容器化应用。通过这种方式,KubeSphere 使开发人员能够专注于应用程序开发,使运维团队能够通过企业级可观测性功能和故障排除机制、统一监控和日志查询、存储和网络管理,以及易用的 CI/CD 流水线等来加快 DevOps 自动化工作流程和交付流程等。

支持在任意平台运行 KubeSphere

作为一个灵活的轻量级容器 PaaS 平台,KubeSphere 对不同云生态系统的支持非常友好,因为它对原生 Kubernetes 本身没有任何的侵入 (Hack)。换句话说,KubeSphere 可以部署并运行在任何基础架构以及所有版本兼容的 Kubernetes 集群之上,包括虚拟机、物理机、数据中心、公有云和混合云等。

您可以选择在公有云和托管 Kubernetes 集群(例如阿里云、AWS、青云QingCloud、腾讯云、华为云等)上安装 KubeSphere,还可以导入和纳管已有的 Kubernetes 集群

KubeSphere 可以在不修改用户当前的资源或资产、不影响其业务的情况下部署在现有的 Kubernetes 平台上。有关更多信息,请参见在 Linux 上安装在 Kubernetes 上安装

完全开源

借助开源的模式,KubeSphere 社区驱动着开发工作以开放的方式进行。KubeSphere 100% 开源免费,已大规模服务于社区用户,广泛地应用在以 Docker 和 Kubernetes 为中心的开发、测试及生产环境中,大量服务平稳地运行在 KubeSphere 之上。您可在 GitHub 上找到所有源代码、文档和讨论,所有主要的开源项目介绍可以在开源项目列表中找到。

云原生 Landscape

KubeSphere 是 CNCF 基金会成员并且通过了 Kubernetes 一致性认证,进一步丰富了 CNCF 云原生的生态

KubeSphere 生态工具

丰富的生态工具

KubeSphere 围绕 Kubernetes 集成了多个云原生生态主流的开源软件,同时支持对接大部分流行的第三方组件,从应用和应用生命周期管理到集群底层的运行时,将这些开源项目作为其后端组件,通过标准的 API 与 KubeSphere 控制台交互,最终在一个统一的控制台界面提供一致的用户体验,以降低对不同工具的学习成本和复杂性。

同时,KubeSphere 还具备了 Kubernetes 尚未提供的新功能,旨在解决 Kubernetes 本身存在的存储、网络、安全和易用性等痛点。KubeSphere 不仅允许开发人员和 DevOps 团队在统一的控制台中使用他们喜欢的工具,最重要的是,这些功能与平台松耦合,所有功能组件均支持可插拔安装。

平台功能概览

KubeSphere 作为开源的企业级全栈化容器平台,为用户提供了一个健壮、安全、功能丰富、具备极致体验的 Web 控制台。拥有企业级 Kubernetes 所需的最常见的功能,如工作负载管理,网络策略配置,微服务治理(基于 Istio),DevOps 项目 (CI/CD) ,安全管理,Source to Image/Binary to Image,多租户管理,多维度监控,日志查询和收集,告警通知,审计,应用程序管理和镜像管理、应用配置密钥管理等功能模块。

它还支持各种开源存储和网络解决方案以及云存储服务。例如,KubeSphere 为用户提供了功能强大的云原生工具负载均衡器插件 OpenELB,这是为 Kubernetes 集群开发的 CNCF 认证的负载均衡插件。

有了易于使用的图形化 Web 控制台,KubeSphere 简化了用户的学习曲线并推动了更多的企业使用 Kubernetes 。

Linux 单节点部署KubeSphere

对于刚接触 KubeSphere 并想快速上手该容器平台的用户,All-in-One 安装模式是最佳的选择,它能够帮助您零配置快速部署 KubeSphere 和 Kubernetes。

以v3.4版本为例

准备 Linux 机器

硬件推荐配置

操作系统最低配置
Ubuntu 16.04, 18.04, 20.04, 22.042 核 CPU,4 GB 内存,40 GB 磁盘空间
Debian Buster, Stretch2 核 CPU,4 GB 内存,40 GB 磁盘空间
CentOS 7.x2 核 CPU,4 GB 内存,40 GB 磁盘空间
Red Hat Enterprise Linux 72 核 CPU,4 GB 内存,40 GB 磁盘空间
SUSE Linux Enterprise Server 15/openSUSE Leap 15.22 核 CPU,4 GB 内存,40 GB 磁盘空间

节点要求

  • 节点必须能够通过 SSH 连接。

  • 节点上可以使用 sudo/curl/openssl/tar 命令。

# 指定主机名
hostnamectl set-hostname node1

安装

下载 KubeKey

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

使用KubeKey引导安装集群

#可能需要下面命令
yum install -y conntrack socat
​
./kk create cluster --with-kubernetes v1.23.10 --with-kubesphere v3.4.1

验证安装结果

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

安装后开启功能

进入编写yaml,开启指定功能。

Kubernetes上安装KubeSphere

准备工作

  • 您的 Kubernetes 版本必须为:v1.20.x、v1.21.x、v1.22.x、v1.23.x、* v1.24.x、* v1.25.x 和 * v1.26.x。带星号的版本可能出现边缘节点部分功能不可用的情况。因此,如需使用边缘节点,推荐安装 v1.23.x。

  • 确保您的机器满足最低硬件要求:CPU > 1 核,内存 > 2 GB。

  • 在安装之前,需要配置 Kubernetes 集群中的默认存储类型。

nfs文件系统

安装nfs-server

# 在每个机器
yum install -y nfs-utils
​
# 在master 执行以下命令 
echo "/nfs/data/ *(insecure,rw,sync,no_root_squash)" > /etc/exports
​
# 执行以下命令,启动 nfs 服务;创建共享目录
mkdir -p /nfs/data
​
# 在master执行
systemctl enable rpcbind
systemctl enable nfs-server
systemctl start rpcbind
systemctl start nfs-server
​
# 使配置生效
exportfs -r
​
#检查配置是否生效
exportfs

配置nfs-client(选做)

showmount -e 172.31.0.4
​
mkdir -p /nfs/data
​
mount -t nfs 172.31.0.4:/nfs/data /nfs/data #可将其配置为永久挂载

配置默认存储

## 创建了一个存储类
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: nfs-storage
  annotations:
    storageclass.kubernetes.io/is-default-class: "true"
provisioner: k8s-sigs.io/nfs-subdir-external-provisioner
parameters:
  archiveOnDelete: "true"  ## 删除pv的时候,pv的内容是否要备份
​
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nfs-client-provisioner
  labels:
    app: nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: default
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: nfs-client-provisioner
  template:
    metadata:
      labels:
        app: nfs-client-provisioner
    spec:
      serviceAccountName: nfs-client-provisioner
      containers:
        - name: nfs-client-provisioner
          image: registry.cn-hangzhou.aliyuncs.com/lfy_k8s_images/nfs-subdir-external-provisioner:v4.0.2
          # resources:
          #    limits:
          #      cpu: 10m
          #    requests:
          #      cpu: 10m
          volumeMounts:
            - name: nfs-client-root
              mountPath: /persistentvolumes
          env:
            - name: PROVISIONER_NAME
              value: k8s-sigs.io/nfs-subdir-external-provisioner
            - name: NFS_SERVER
              value: 10.45.25.100 ## 指定自己nfs服务器地址
            - name: NFS_PATH  
              value: /nfs/data  ## nfs服务器共享的目录
      volumes:
        - name: nfs-client-root
          nfs:
            server: 10.45.25.100
            path: /nfs/data
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: default
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: nfs-client-provisioner-runner
rules:
  - apiGroups: [""]
    resources: ["nodes"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["persistentvolumes"]
    verbs: ["get", "list", "watch", "create", "delete"]
  - apiGroups: [""]
    resources: ["persistentvolumeclaims"]
    verbs: ["get", "list", "watch", "update"]
  - apiGroups: ["storage.k8s.io"]
    resources: ["storageclasses"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["events"]
    verbs: ["create", "update", "patch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: run-nfs-client-provisioner
subjects:
  - kind: ServiceAccount
    name: nfs-client-provisioner
    # replace with namespace where provisioner is deployed
    namespace: default
roleRef:
  kind: ClusterRole
  name: nfs-client-provisioner-runner
  apiGroup: rbac.authorization.k8s.io
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: leader-locking-nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: default
rules:
  - apiGroups: [""]
    resources: ["endpoints"]
    verbs: ["get", "list", "watch", "create", "update", "patch"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: leader-locking-nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: default
subjects:
  - kind: ServiceAccount
    name: nfs-client-provisioner
    # replace with namespace where provisioner is deployed
    namespace: default
roleRef:
  kind: Role
  name: leader-locking-nfs-client-provisioner
  apiGroup: rbac.authorization.k8s.io
#确认配置是否生效
kubectl get sc

metrics-server

集群指标监控组件

apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  labels:
    k8s-app: metrics-server
    rbac.authorization.k8s.io/aggregate-to-admin: "true"
    rbac.authorization.k8s.io/aggregate-to-edit: "true"
    rbac.authorization.k8s.io/aggregate-to-view: "true"
  name: system:aggregated-metrics-reader
rules:
- apiGroups:
  - metrics.k8s.io
  resources:
  - pods
  - nodes
  verbs:
  - get
  - list
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  labels:
    k8s-app: metrics-server
  name: system:metrics-server
rules:
- apiGroups:
  - ""
  resources:
  - pods
  - nodes
  - nodes/stats
  - namespaces
  - configmaps
  verbs:
  - get
  - list
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server-auth-reader
  namespace: kube-system
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: extension-apiserver-authentication-reader
subjects:
- kind: ServiceAccount
  name: metrics-server
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server:system:auth-delegator
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: system:auth-delegator
subjects:
- kind: ServiceAccount
  name: metrics-server
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  labels:
    k8s-app: metrics-server
  name: system:metrics-server
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: system:metrics-server
subjects:
- kind: ServiceAccount
  name: metrics-server
  namespace: kube-system
---
apiVersion: v1
kind: Service
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server
  namespace: kube-system
spec:
  ports:
  - name: https
    port: 443
    protocol: TCP
    targetPort: https
  selector:
    k8s-app: metrics-server
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    k8s-app: metrics-server
  name: metrics-server
  namespace: kube-system
spec:
  selector:
    matchLabels:
      k8s-app: metrics-server
  strategy:
    rollingUpdate:
      maxUnavailable: 0
  template:
    metadata:
      labels:
        k8s-app: metrics-server
    spec:
      containers:
      - args:
        - --cert-dir=/tmp
        - --kubelet-insecure-tls
        - --secure-port=4443
        - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
        - --kubelet-use-node-status-port
        image: registry.cn-hangzhou.aliyuncs.com/lfy_k8s_images/metrics-server:v0.4.3
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /livez
            port: https
            scheme: HTTPS
          periodSeconds: 10
        name: metrics-server
        ports:
        - containerPort: 4443
          name: https
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /readyz
            port: https
            scheme: HTTPS
          periodSeconds: 10
        securityContext:
          readOnlyRootFilesystem: true
          runAsNonRoot: true
          runAsUser: 1000
        volumeMounts:
        - mountPath: /tmp
          name: tmp-dir
      nodeSelector:
        kubernetes.io/os: linux
      priorityClassName: system-cluster-critical
      serviceAccountName: metrics-server
      volumes:
      - emptyDir: {}
        name: tmp-dir
---
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
  labels:
    k8s-app: metrics-server
  name: v1beta1.metrics.k8s.io
spec:
  group: metrics.k8s.io
  groupPriorityMinimum: 100
  insecureSkipTLSVerify: true
  service:
    name: metrics-server
    namespace: kube-system
  version: v1beta1
  versionPriority: 100

安装KubeSphere

下载核心文件
# 下载对应版本的yaml
wget https://github.com/kubesphere/ks-installer/releases/download/v3.1.1/kubesphere-installer.yaml

wget https://github.com/kubesphere/ks-installer/releases/download/v3.1.1/cluster-configuration.yaml
修改cluster-configuration

在 cluster-configuration.yaml中指定我们需要开启的功能

参照官网“启用可插拔组件”

https://kubesphere.com.cn/docs/pluggable-components/overview/

执行安装
kubectl apply -f kubesphere-installer.yaml

kubectl apply -f cluster-configuration.yaml
查看安装进度
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f

访问任意机器的 30880端口

账号 : admin

密码 : P@88w0rd

解决etcd监控证书找不到问题

kubectl -n kubesphere-monitoring-system create secret generic kube-etcd-client-certs  --from-file=etcd-client-ca.crt=/etc/kubernetes/pki/etcd/ca.crt  --from-file=etcd-client.crt=/etc/kubernetes/pki/apiserver-etcd-client.crt  --from-file=etcd-client.key=/etc/kubernetes/pki/apiserver-etcd-client.key

Linux多节点部署KubeSphere

下载 KubeKey

export KKZONE=cn

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

chmod +x kk

创建集群配置文件

./kk create config --with-kubernetes v1.23.10 --with-kubesphere v3.4.1

#修改集群配置文件,仅展示了部分需要修改的地方
vim config-sample.yaml
....
spec:
  hosts:
  - {name: master, address: 10.45.25.100, internalAddress: 10.45.25.100, user: root, password: "000000"}
  - {name: node1, address: 10.45.25.101, internalAddress: 10.45.25.101, user: root, password: "000000"}
  - {name: node2, address: 10.45.25.102, internalAddress: 10.45.25.102, user: root, password: "000000"}
  roleGroups:
    etcd:
    - master
    control-plane:
    - master
    worker:
    - node1
    - node2
....

创建集群

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

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

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

Console: http://10.45.25.100:30880
Account: admin
Password: P@88w0rd
NOTES:
  1. After you log into the console, please check the
     monitoring status of service components in
     "Cluster Management". If any service is not
     ready, please wait patiently until all components 
     are up and running.
  2. Please change the default password after login.

#####################################################
https://kubesphere.io             2024-08-25 05:40:29
#####################################################
05:40:30 EDT success: [master]
05:40:30 EDT Pipeline[CreateClusterPipeline] execute successfully
Installation is complete.

Please check the result using the command:

        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

[root@master ~]#

启用 kubectl 自动补全

# Install bash-completion
yum install bash-completion

# Source the completion script in your ~/.bashrc file
echo 'source <(kubectl completion bash)' >>~/.bashrc

# Add the completion script to the /etc/bash_completion.d directory
kubectl completion bash >/etc/bash_completion.d/kubectl

标签:name,部署,KubeSphere,server,metrics,nfs,三种,k8s
From: https://blog.csdn.net/weixin_52377412/article/details/142377107

相关文章

  • springboot项目打包部署到linux运行经验:
    打包:1.mvn:clean2.mvn:package 生成的snapshop-jar包在target下。部署(采用idea自带的ftp) 1.idea的tools-deployment中配置虚拟机的连接,包括用户名,密码,端口 2.配置idea的mapping文件目录映射(随便写),就可以打开虚拟机目录了 3.将idea的target下生产的jar包直接拖动到虚......
  • 阿里云函数计算自定义域名的SSL证书免费全自动申请及部署
    ####(本人现在只做了证书部署,自动任务可以执行但是所生成的记录值没办法自动在阿里云的域名解析列表中更新,因此查到这篇文章,但发现太麻烦……又感觉以后一定会用到,所以先转载保存记录一下,原文地址:https://developer.aliyun.com/article/1475347)阿里云函数计算大大简化了开发部......
  • Centos7.9部署kubernetes(一主两从)(版本1.17.4)
    部署kubernetes1、环境准备IP系统配置角色192.168.8.180centos7.92H4Gmaster192.168.8.181centos7.92H4Gnode1192.168.8.178centos7.92H4Gnode22、在所有节点上关闭swap分区masternode#临时关闭swap分区swapoff-asysctl-wvm.s......
  • 15.10 在k8s部署grafana-deployment并导入k8s大盘
    本节重点介绍:grafanadeployment部署k8s大盘导入准备yaml部署工作1.修改yaml中的节点选择器标签k8s-node01改为你自己的节点2.在节点上创建数据目录mkdir-pv/data/grafana3.部署grafana#部署kubectlapply-fdeployment.yaml#检查[root@prome-master01grafana]#ku......
  • 15.8 在k8s部署prometheus statefulset
    本节重点介绍:检查,kube-systemns[root@prome-master01prometheus]#kubectlgetpod-nkube-systemNAMEREADYSTATUSRESTARTSAGEcoredns-7d75679df-7f7tx1/1Running088mcoredns-7d75679df-qmzbg1/1Running088metcd-prome-master011/1Running088mkube-apise......
  • 聚类分析 | FCM模糊c均值聚类,三种优化算法(SSA、PSO、GA)对FCM初始中心点寻优
    聚类分析|FCM模糊c均值聚类,三种优化算法(SSA、PSO、GA)对FCM初始中心点寻优目录聚类分析|FCM模糊c均值聚类,三种优化算法(SSA、PSO、GA)对FCM初始中心点寻优效果一览基本介绍程序设计参考资料效果一览基本介绍聚类分析|FCM模糊c均值聚类,三种优化算法(SSA、PSO、GA)对FCM初始中心点......
  • 华为 Flexus 云服务器部署 RustDesk Server,打造自己的远程桌面服务器
    ......
  • OpenStack基础平台部署案例
    OpenStack基础平台部署案例案例描述本案例是讲述如何使用云主机搭建OpenStack云平台。包括两种搭建的方式,一种是直接执行脚本安装,另一种是使用Ansible安装。使用这种方式,不需要重复安装系统去搭建平台,只需要创建云主机去构建OpenStack云平台,使用云主机去练习相应的操作。案......
  • 代码管理系统简介与部署git、gitHub、gitLab
            在开发一个项目时,如果只有几十行代码或几百行代码时维护还算简单,但是当代码数量达到一定程度或两三个人共同开发一个项目时,就很容易会出现代码混乱、冲突、排错难等问题。当代码编写完成以后发现整个项目运行不了时,提交的代码也无法确认到责任人,导致维护项目时......
  • 爬虫案例2-爬取视频的三种方式之一:DrissionPage篇(3)
    @目录前言DrissionPage介绍源码共勉博客前言继requests篇和selenium篇,我们今天用DrissionPage来进行图片的爬取。DrissionPage介绍DrissionPage和selenium相似,都是基于python的网页自动化工具。不过Drission库的结合了requests和Selenium的优势,既能控制浏览器交互,又能高效地收......