KubeSphere介绍

官网地址:https://kubesphere.com.cn/
首先先看下官网的介绍
1、KubeSphere是打造一个以Kubernetes为内核的云原生分布式操作系统。它的架构可以非常方便地使第三方应用与云原生生态组件进行即插即用(plug-and-play)的集成,支持云原生应用在多云与多集群的统一分发和运维管理。

2、KubeSphere是个全栈的Kubernetes容器云PasS解决方案

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

我的个人理解:
1、KubeSphere是个容器云平台,即PaaS平台,而Kubernetes是个容器编排系统,二者不一样。而在DevOps时代,我们以Kubernetes为核心的技术展开,所以说KubeSphere是以Kubernetes为内核的,这就像Linux操作系统的内核一样,Linux操作系统依赖于内核,一样重要。但这并不能说明,KubeSphere只能基于Kubernetes去搭建,KubeSphere也能部署在裸机(虚拟机)中。

2、KubeSphere整体来说是一个能够灵活组合云原生应用的一个平台,在这个平台里,可以把其它云原生应用当成个插件来使用,比如:DevOps中的:Jenkins,也集成了Service mesh的应用,比如:Istio。这也就是所说的即插即用,这对于运维人员行。

3、KubeSphere可以简单的理解为是Kubernetes的dashboard,但是KubeSphere不仅仅只满足于dashboard功能,并且可以实现众多复杂的功能。

KubeSphere我也是粗略了解以下。
下面开始安装。

安装KubeSphere(v3.1.1)

安装KubeSphere最好的方法就是参考官方文档,而且官方文档是中文的。
官网地址:https://kubesphere.com.cn/

安装环境说明

Kubernetes:V1.20.9(1.17.x,1.18.x,1.19.x,1.20.x),注意:如果安装3.1.x版本,K8S不能大于1.20.x版本
Docker:20.10.7
服务器配置: 使用华为云ECS弹性云服务器
k8s-master 4VCPU+8G
node1 8VCPU+16G
node2 8VCPU+16G
我上面的配置是针对所有插件都选用了,也就是说如果你开启了DevOps,Service Mesh,警告…等所有功能,就需要如上配置。如果你就最小化安装KubeSphere应该每个节点2VCPU+2G即可。
CentOS7.9
前提:
具备好一个最基本Kubernetes平台。
注:如果没有安装kubernetes平台请参考文档:
https://blog.csdn.net/m0_57776598/article/details/124043624
如果使用v1.20.9版本的话,使用就参考雷神老师的文档和镜像仓库:
https://www.yuque.com/leifengyang/oncloud/gz1sls

安装并配置NFS存储

根据官方文档要求,在安装,KubeSphere之前,Kubernetes平台上需要有个默认的StorageClass类资源,也就是默认存储,提到StorageClass类资源,我们就要想到PV,PVC,这里的StorageClass类资源不再是传统的手动创建PV,PVC了,而是采用动态的方式绑定存储,比如:我写个PVC文件,底层会自动匹配相应的PV(如果没有对应的PV,则自动创建)。但是这一切的前提都需要有个存储,因此我们用NFS来实现。

这里以master节点为NFS服务器
1、安装nfs-server(所有节点的操作)

yum install -y nfs-utils

2、授权存储目录(master)

echo "/nfs/data/ *(insecure,rw,sync,no_root_squash)" > /etc/exports

3、执行以下命令,启动 nfs 服务;创建共享目录

mkdir -p /nfs/data

4、在master节点执行

systemctl enable rpcbind
systemctl enable nfs-server
systemctl start rpcbind
systemctl start nfs-server

5、# 使配置生效

exportfs -r

#检查配置是否生效

[root@k8s-master ~]# exportfs
/nfs/data       <world>

6、测试,在客户端

[root@node2 ~]# showmount -e 192.168.9.10
Export list for 192.168.9.10:
/nfs/data *

配置默认存储

1、上面说到我们是采用StorageClass抽象来动态创建PV,但是使用StorageClass有个前提,就是需要个存储分配器。StorageClass是通过存储分配器(provisioner)来分配PV的,但是Kubernetes官方内置的分配器并不支持NFS,所以需要额外安装NFS存储分配器。它以deployment运行。也就是说我们需要创建个deployment。

2、由于存储分配器在Kubernetes集群内部,存储分配器想要操控NFS分配空间,就需要和API Server交互,这属于集群内部Pod和API Server交互,因此我们还需要创建个ServiceAccount,然后在创建存储类(StorageClass),之后创建ClusterRole,ClusterRoleBinding,Role,RoleBinding等账号权限配置
以上就是我们配置默认存储所执行的步骤:创建StorageClass资源,创建ServiceAccount资源,创建deployment资源,创建ClusterRole,ClusterRoleBinding,Role,RoleBinding等权限资源。

3、执行如下yaml文件

vi sc.yaml

下面来逐行介绍:

## 创建了一个存储类
apiVersion: storage.k8s.io/v1
kind: StorageClass                  #存储类的资源名称
metadata:name: nfs-storage                 #存储类的名称,自定义annotations:storageclass.kubernetes.io/is-default-class: "true"          #注解,是否是默认的存储,注意:KubeSphere默认就需要个默认存储,因此这里注解要设置为“默认”的存储系统,表示为"true",代表默认。
provisioner: k8s-sigs.io/nfs-subdir-external-provisioner         #存储分配器的名字,自定义
parameters:archiveOnDelete: "true"  ## 删除pv的时候,pv的内容是否要备份---
apiVersion: apps/v1
kind: Deployment
metadata:name: nfs-client-provisionerlabels:app: nfs-client-provisioner# replace with namespace where provisioner is deployednamespace: default
spec:replicas: 1                 #只运行一个副本应用strategy:                   #描述了如何用新的POD替换现有的PODtype: Recreate            #Recreate表示重新创建Podselector:        #选择后端PodmatchLabels:app: nfs-client-provisionertemplate:metadata:labels:app: nfs-client-provisionerspec: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      #使用NFS存储分配器的镜像# resources:#    limits:#      cpu: 10m#    requests:#      cpu: 10mvolumeMounts:- name: nfs-client-root           #定义个存储卷,mountPath: /persistentvolumes   #表示挂载容器内部的路径env:- name: PROVISIONER_NAME          #定义存储分配器的名称value: k8s-sigs.io/nfs-subdir-external-provisioner         #需要和上面定义的保持名称一致- name: NFS_SERVER                                       #指定NFS服务器的地址,你需要改成你的NFS服务器的IP地址value: 192.168.9.10 ## 指定自己nfs服务器地址- name: NFS_PATH                                value: /nfs/data  ## nfs服务器共享的目录            #指定NFS服务器共享的目录volumes:- name: nfs-client-root           #存储卷的名称,和前面定义的保持一致nfs:server: 192.168.9.10            #NFS服务器的地址,和上面保持一致,这里需要改为你的IP地址path: /nfs/data               #NFS共享的存储目录,和上面保持一致
---
apiVersion: v1
kind: ServiceAccount                 #创建个SA账号
metadata:name: nfs-client-provisioner        #和上面的SA账号保持一致# replace with namespace where provisioner is deployednamespace: default
---
#以下就是ClusterRole,ClusterRoleBinding,Role,RoleBinding都是权限绑定配置,不在解释。直接复制即可。
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: ServiceAccountname: nfs-client-provisioner# replace with namespace where provisioner is deployednamespace: default
roleRef:kind: ClusterRolename: nfs-client-provisioner-runnerapiGroup: 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 deployednamespace: 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 deployednamespace: default
subjects:- kind: ServiceAccountname: nfs-client-provisioner# replace with namespace where provisioner is deployednamespace: default
roleRef:kind: Rolename: leader-locking-nfs-client-provisionerapiGroup: rbac.authorization.k8s.io

以上文件,只需要改动两个部分:就是把两处的IP地址,改为自己的NFS服务器的IP地址,即可。

4、apply此Yaml文件,创建默认存储

kubectl apply -f sc.yaml

5、查看SC

[root@master ~]# kubectl get sc
NAME                    PROVISIONER                                   RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
nfs-storage (default)   k8s-sigs.io/nfs-subdir-external-provisioner   Delete          Immediate           false                  10h

6、查看Pod,其否正常启动
等到两分钟,如果还是Running,那说明一切正常

[root@master ~]# kubectl get pods -A
NAMESPACE              NAME                                         READY   STATUS      RESTARTS        AGE
default                nfs-client-provisioner-65878c6456-hsxqf      1/1     Running     1 (35m ago)     10h

验证StorageClass存储类的效果

说明:上面说到采用StorageClass的方法,可以动态生成PV,上面我们已经创建好了StorageClass,下面我们在没有任何PV的情况下来创建个PVC,看看PVC是否能立即绑定到PV。如果能就说明成功自动创建了PV,并进行了绑定。

1、先查看是否有PV

[root@master ~]# kubectl get pv
No resources found

2、创建PVC

[root@master ~]# vi pvc.yaml
kind: PersistentVolumeClaim         #创建PVC资源
apiVersion: v1
metadata:name: nginx-pvc         #PVC的名称
spec:accessModes:            #定义对PV的访问模式,代表PV可以被多个PVC以读写模式挂载- ReadWriteManyresources:              #定义PVC资源的参数requests:             #设置具体资源需求storage: 200Mi      #表示申请200MI的空间资源storageClassName: nfs-storage          #指定存储类的名称,就指定上面创建的那个存储类。

3、apply此Yaml文件,并查看PVC的状态

[root@master ~]# kubectl apply -f pvc.yaml
persistentvolumeclaim/nginx-pvc created
[root@master ~]# kubectl get pvc
NAME        STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
nginx-pvc   Bound    pvc-33673033-f0e3-42f1-a0e7-69cbe0652e58   200Mi      RWX            nfs-storage    3s
#可以看到PVC成功显示Bound(绑定状态)

在查看下PV

[root@master ~]# kubectl get pv                #可以看到已经自动创建了PV,并且是200MI空间大小
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM               STORAGECLASS   REASON   AGE
pvc-33673033-f0e3-42f1-a0e7-69cbe0652e58   200Mi      RWX            Delete           Bound    default/nginx-pvc   nfs-storage             53s

安装Metrics-Server

Metrics-Server简介:它是集群指标监控组件,用于和API Server交互,获取(采集)Kubernetes集群中各项指标数据的。有了它我们可以查看各个Pod,Node等其他资源的CPU,Mem(内存)使用情况。
为什么需要它?
开头的时候说过,KubeSphere可以充当Kubernetes的dashboard(可视化面板)因此KubeSphere要想获取Kubernetes的各项数据,就需要某个组件去提供给想数据,这个数据采集功能由Metrics-Server实现。

1、修改每个 API Server 的 kube-apiserver.yaml 配置开启 Aggregator Routing

[root@master ~]# vi /etc/kubernetes/manifests/kube-apiserver.yaml
apiVersion: v1
kind: Pod
metadata:annotations:kubeadm.kubernetes.io/kube-apiserver.advertise-address.endpoint: 192.168.9.10:6443creationTimestamp: nulllabels:component: kube-apiservertier: control-planename: kube-apiservernamespace: kube-system
spec:containers:- command:- kube-apiserver- --advertise-address=192.168.9.10- --allow-privileged=true- --authorization-mode=Node,RBAC- --client-ca-file=/etc/kubernetes/pki/ca.crt- --enable-admission-plugins=NodeRestriction- --enable-bootstrap-token-auth=true- --enable-aggregator-routing=true         #添加此行,开启Aggregator Routing(聚合路由)- --etcd-cafile=/etc/kubernetes/pki/etcd/ca.crt...

重启kubelet

systemctl daemon-reload
systemctl restart kubelet

2、安装所需的Yaml文件

vi components.yaml
apiVersion: v1
kind: ServiceAccount
metadata:labels:k8s-app: metrics-servername: metrics-servernamespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:labels:k8s-app: metrics-serverrbac.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.ioresources:- pods- nodesverbs:- get- list- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:labels:k8s-app: metrics-servername: system:metrics-server
rules:
- apiGroups:- ""resources:- pods- nodes- nodes/stats- namespaces- configmapsverbs:- get- list- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:labels:k8s-app: metrics-servername: metrics-server-auth-readernamespace: kube-system
roleRef:apiGroup: rbac.authorization.k8s.iokind: Rolename: extension-apiserver-authentication-reader
subjects:
- kind: ServiceAccountname: metrics-servernamespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:labels:k8s-app: metrics-servername: metrics-server:system:auth-delegator
roleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: system:auth-delegator
subjects:
- kind: ServiceAccountname: metrics-servernamespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:labels:k8s-app: metrics-servername: system:metrics-server
roleRef:apiGroup: rbac.authorization.k8s.iokind: ClusterRolename: system:metrics-server
subjects:
- kind: ServiceAccountname: metrics-servernamespace: kube-system
---
apiVersion: v1
kind: Service
metadata:labels:k8s-app: metrics-servername: metrics-servernamespace: kube-system
spec:ports:- name: httpsport: 443protocol: TCPtargetPort: httpsselector:k8s-app: metrics-server
---
apiVersion: apps/v1
kind: Deployment
metadata:labels:k8s-app: metrics-servername: metrics-servernamespace: kube-system
spec:selector:matchLabels:k8s-app: metrics-serverstrategy:rollingUpdate:maxUnavailable: 0template:metadata:labels:k8s-app: metrics-serverspec:containers:- args:- --cert-dir=/tmp- --secure-port=4443- --kubelet-preferred-address-types=InternalIP       #删掉 ExternalIP,Hostname这两个,这里已经改好了- --kubelet-use-node-status-port- --kubelet-insecure-tls                             #加上该启动参数image: registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server:v0.4.1imagePullPolicy: IfNotPresentlivenessProbe:failureThreshold: 3httpGet:path: /livezport: httpsscheme: HTTPSperiodSeconds: 10name: metrics-serverports:- containerPort: 4443name: httpsprotocol: TCPreadinessProbe:failureThreshold: 3httpGet:path: /readyzport: httpsscheme: HTTPSperiodSeconds: 10securityContext:readOnlyRootFilesystem: truerunAsNonRoot: truerunAsUser: 1000volumeMounts:- mountPath: /tmpname: tmp-dirnodeSelector:kubernetes.io/os: linuxpriorityClassName: system-cluster-criticalserviceAccountName: metrics-servervolumes:- emptyDir: {}name: tmp-dir
---
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:labels:k8s-app: metrics-servername: v1beta1.metrics.k8s.io
spec:group: metrics.k8s.iogroupPriorityMinimum: 100insecureSkipTLSVerify: trueservice:name: metrics-servernamespace: kube-systemversion: v1beta1versionPriority: 100

3、拉取镜像

docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-server:v0.4.1

4、安装

kubectl apply -f components.yaml

5、查看Metrics Server服务状态

[root@master ~]# kubectl get pods -n kube-system
...
metrics-server-7d594964f5-5xzwd   1/1     Running   0          4h2m
...

6、执行以下命令,检查节点占用性能情况。

[root@master ~]# kubectl top nodes
NAME     CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%
master   198m         4%     1253Mi          34%
node1    123m         6%     1005Mi          58%
node2    81m          4%     947Mi           55%
#说明Metrics-Server正常运行

安装KubeSphere

1、下载核心文件

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

2、修改cluster-configuration集群配置
说明:从 2.1.0 版本开始,KubeSphere 解耦了一些核心功能组件。这些组件设计成了可插拔式,您可以在安装之前或之后启用它们。如果您不启用它们,KubeSphere 会默认以最小化进行安装部署。不同的可插拔组件部署在不同的命名空间中。
上面是官方解释为啥需要修改cluster-configuration集群配置。
其实修改cluster-configuration集群配置就是额外启用一些KubeSphere插件,比如:启用DevOps的相关插件,开启ectd的监控功能,开启告警功能…

在 cluster-configuration.yaml中指定我们需要开启的功能
参照官网“启用可插拔组件”
https://kubesphere.com.cn/docs/pluggable-components/overview/

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

vi cluster-configuration.yaml
[root@master ~]# cat cluster-configuration.yaml
---
apiVersion: installer.kubesphere.io/v1alpha1
kind: ClusterConfiguration
metadata:name: ks-installernamespace: kubesphere-systemlabels: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.9.10  # 改为自己的master节点IP地址port: 2379              # etcd port.tlsEnable: truecommon: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          #此处的"false"不用改为"true",这个标识在开启监控功能之后是否要连接ElasticSearch的账户和密码,此处不用username: ""password: ""externalElasticsearchUrl: ""externalElasticsearchPort: ""console:enableMultiLogin: true  # Enable or disable simultaneous logins. It allows different users to log in with the same account at the same time.port: 30880alerting:                # (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: true         # 改为"true",开启告警功能# thanosruler:#   replicas: 1#   resources: {}auditing:                enabled: true         #  改为"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: 512mjenkinsJavaOpts_MaxRAM: 2gevents:                  # Provide a graphical web console for Kubernetes Events exporting, filtering and alerting in multi-tenant Kubernetes clusters.enabled: true         # 改为"true",开启集群的事件功能ruler:enabled: truereplicas: 2logging:                 # (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: truereplicas: 2metrics_server:                    # (CPU: 56 m, Memory: 44.35 MiB) It enables HPA (Horizontal Pod Autoscaler).enabled: false                   # 这个不用修改,因为在上卖弄我们已经安装过了,如果这里开启,镜像是官方的,会拉取镜像失败monitoring:storageClass: ""                 # 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: []

3、安装kubesphere并配置kubesphere(注意运行顺序)

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

4、查看KubeSphere的状态

[root@master ~]# kubectl get pods -A
...
kubesphere-system            ks-installer-54c6bcf76b-br9vq                   1/1     Running             0          41m
...

5、检查安装日志:
使用如下命令可以查看kubesphere安装的日志,

[root@k8s-master ~]# kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f#显示结果:
PLAY RECAP *********************************************************************
localhost                  : ok=31   changed=25   unreachable=0    failed=0    skipped=15   rescued=0    ignored=0 #注意查看failed=0,失败=0即可。
#下面就等待估计20min
Start installing monitoring
Start installing multicluster
Start installing openpitrix
Start installing network
Start installing alerting
Start installing auditing
Start installing devops
Start installing events
Start installing kubeedge
Start installing logging
Start installing servicemesh
**************************************************
Waiting for all tasks to be completed ...
task multicluster status is successful  (1/11)
task network status is successful  (2/11)
task alerting status is successful  (3/11)
task openpitrix status is successful  (4/11)
task auditing status is successful  (5/11)
task logging status is successful  (6/11)
task events status is successful  (7/11)
task kubeedge status is successful  (8/11)
task devops status is successful  (9/11)
task monitoring status is successful  (10/11)
task servicemesh status is successful  (11/11)
**************************************************
Collecting installation results ...
#####################################################
###              Welcome to KubeSphere!           ###
#####################################################Console: http://192.168.0.206:30880
Account: admin
Password: P@88w0rdNOTES:1. After you log into the console, please check themonitoring status of service components in"Cluster Management". If any service is notready, please wait patiently until all components are up and running.2. Please change the default password after login.#####################################################
https://kubesphere.io             2022-04-08 17:14:52
#####################################################
#出现如上信息表示安装KubeSphere行

解决Prometheus监控etcd找不到Secret的问题

1、安装好了KubeSphere之后查看相关Pod,会发现有两个Prometheus(监控服务)一直处于ContainerCreating,那这时我们就需要排查一下错误了,首先describe

[root@k8s-master ~]# kubectl get pods -A
kubesphere-monitoring-system   prometheus-k8s-0                                   0/3     ContainerCreating   0          9m39s
kubesphere-monitoring-system   prometheus-k8s-1                                   0/3     ContainerCreating   0          9m39s

2、describe查看原因

[root@k8s-master ~]# kubectl describe pods -n kubesphere-monitoring-system   prometheus-k8s-0
Warning  FailedMount       8m6s                   kubelet            Unable to attach or mount volumes: unmounted volumes=[secret-kube-etcd-client-certs], unattached volumes=[prometheus-k8s-db prometheus-k8s-rulefiles-0 secret-kube-etcd-client-certs prometheus-k8s-token-nzqs8 config config-out tls-assets]: timed out waiting for the conditionWarning  FailedMount       3m34s (x2 over 5m51s)  kubelet            Unable to attach or mount volumes: unmounted volumes=[secret-kube-etcd-client-certs], unattached volumes=[config config-out tls-assets prometheus-k8s-db prometheus-k8s-rulefiles-0 secret-kube-etcd-client-certs prometheus-k8s-token-nzqs8]: timed out waiting for the conditionWarning  FailedMount       115s (x12 over 10m)    kubelet            MountVolume.SetUp failed for volume "secret-kube-etcd-client-certs" : secret "kube-etcd-client-certs" not foundWarning  FailedMount       80s                    kubelet            Unable to attach or mount volumes: unmounted volumes=[secret-kube-etcd-client-certs], unattached volumes=[tls-assets prometheus-k8s-db prometheus-k8s-rulefiles-0 secret-kube-etcd-client-certs prometheus-k8s-token-nzqs8 config config-out]: timed out waiting for the condition

说明:由于我们在cluster-configuration.yaml文件中开启了监控功能,但是Prometheus无法获取到etcd的证书,因为我们知道etcd是整个Kubernetes的核心,存放着重要的数据,因此需要有它的证书允许才能进行监控。

因此我们创建secret里面放证书即可:

[root@k8s-master ~]# 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

大概等个5分钟左右,再次查看,就Running了。

访问KubeSphere

在确保KubeSphere的相关插件都Running后,我们就能访问KubeSphere了(KubeSphere默认监听30880端口,如果是公有云环境需要注意安全组开放30880端口):IP:30880
用户:admin
初始密码:P@88w0rd

更改密码

进入KubeSphere主界面

至此,安装KubeSphere(v3.1.1)end

KubeSphere(v3.1.1)学习---KubeSphere介绍和基于K8S的安装相关推荐

  1. 在线学习FTRL介绍及基于Flink实现在线学习流程

    背景 目前互联网已经进入了AI驱动业务发展的阶段,传统的机器学习开发流程基本是以下步骤: 数据收集->特征工程->训练模型->评估模型效果->保存模型,并在线上使用训练的有效模 ...

  2. [基础服务] [kubernetes] KubeSphere 基于 Kubernetes (K8S)的安装

    简介 KubeSphere是个全栈的Kubernetes容器云PasS解决方案 1.KubeSphere是个容器云平台,即PaaS平台,而Kubernetes是个容器编排系统,二者不一样.而在DevO ...

  3. 使用KubeKey 离线环境部署 KubeSphere v3.0.0

    使用KubeKey 离线环境部署 KubeSphere v3.0.0 环境准备 以三台centos 7.7 64bit 为例: name ip role node1 192.168.6.17 etcd ...

  4. 使用 Sealos + Longhorn 部署 KubeSphere v3.0.0

    使用 Sealos + Longhorn 部署 KubeSphere v3.0.0 本文来自 KubeSphere 社区用户 Will,演示如何使用 Sealos + Longhorn 部署一个带有持 ...

  5. kubesphere v3.1.0 离线集群部署

    目录 一.简介 二.部署环境 2.1.系统要求 2.2.镜像仓库 三.安装部署 3.1.安装包下载: 3.2.安装步骤: 3.2.1.上传解压: 3.2.3.初始化环境: 3.2.4.导入镜像: 3. ...

  6. YOLO系列(v1~v3)的学习及YOLO-Fastest在海思平台的部署(中)

    YOLO系列(v1~v3)的学习及YOLO-Fastest在海思平台的部署(上) YOLO系列(v1~v3)的学习及YOLO-Fastest在海思平台的部署(中) YOLO系列(v1~v3)的学习及Y ...

  7. YOLO系列(v1~v3)的学习及YOLO-Fastest在海思平台的部署(上)

    YOLO系列(v1~v3)的学习及YOLO-Fastest在海思平台的部署(上) YOLO系列(v1~v3)的学习及YOLO-Fastest在海思平台的部署(中) YOLO系列(v1~v3)的学习及Y ...

  8. oracle入门学习(3) 所用的学习环境介绍与设置

    oracle入门学习(3) 原文见我的QQ空间:http://user.qzone.qq.com/284648964?ptlang=2052 由于原文是写在我的QQ空间,文章转过来的过程中造图片丢失, ...

  9. DL之DeepLabv3:DeepLab v3和DeepLab v3+算法的简介(论文介绍)、架构详解、案例应用等配图集合之详细攻略

    DL之DeepLabv3:DeepLab v3和DeepLab v3+算法的简介(论文介绍).架构详解.案例应用等配图集合之详细攻略 目录 DeepLab v3和DeepLab v3+算法的简介(论文 ...

最新文章

  1. 图解Transformer(完整版)!
  2. oracle sequrnce_OracleSql语句学习(五)
  3. 幽默感七个技巧_如何通过三招,让自己成为一个有幽默感的说话高手?
  4. ELK日志管理之——elasticsearch部署
  5. PHP校验ISBN码的函数
  6. 肖仰华 | 知识图谱研究的回顾与展望
  7. 5分钟了解VMware vSAN的分布式RAID
  8. microsoft符合服务器加载符号的解决方案
  9. linux 7 network fail,CentOs7 网卡出现问题Job for network.service failed
  10. 米思齐_米思齐公益培训之交互式图形设计与数据分析圆满落幕
  11. android 多线程 加锁,android 多线程 — 从一个小例子再次品位多线程
  12. Microsoft Visual Studio Web 创作组件安装失败的解决方法
  13. 游戏筑基开发之结构体(数组、指针)、枚举、共用体、typdef(C语言)
  14. Netty-Pipeline组件
  15. Multisim 版本针对3D元件库说明
  16. 2022年最新的百度云盘在线倍速播放实践可用
  17. 儿童时间管理表,让孩子学会善待时间
  18. MATLAB将.mat矩阵写成.tif图片
  19. 基于GL Pipeline与光线追踪技术的融合实现的台球模拟器
  20. android开启wifi热点命令,Android便携式热点的开启状态检测和SSID的获取方法

热门文章

  1. 去重java_JAVA去重 - osc_ngi4bcdo的个人空间 - OSCHINA - 中文开源技术交流社区
  2. mint-ui 的地址选择 外部套了vant ui的 弹出popup
  3. 机器学习:学习k-近邻(KNN)模型建立、使用和评价
  4. linux内存水印,Linux批量打水印
  5. 斯巴拓压力测力传感器的特色称重模块基本选型要求
  6. 最新异次元发卡系统源码荔枝发卡V3.0版
  7. 信使 Messenger
  8. C++树状数组模板题 敌兵布阵解题报告
  9. 3D游戏建模就是那么简单!
  10. 最新一线大厂Redis使用21条军规及详细解读