首页 > 其他分享 >KubeSphere平台安装

KubeSphere平台安装

时间:2023-06-25 19:01:57浏览次数:45  
标签:name KubeSphere 平台 server metrics nfs io k8s 安装

一、安装KubeSphere前置环境

1、 nfs文件系统

  1. 安装nfs-server
# 每一台机器都要安装
[root@master01 ~]#yum install -y nfs-utils

# 在master 执行以下命令 
[root@master01 ~]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
  1. 配置nfs-client
showmount -e 172.31.0.4

mkdir -p /nfs/data

mount -t nfs 172.31.0.4:/nfs/data /nfs/data
  1. 配置默认存储
  • 配置动态供应的默认存储类
## 创建了一个存储类
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: 172.16.0.11 ## 指定自己nfs服务器地址
            - name: NFS_PATH  
              value: /nfs/data  ## nfs服务器共享的目录
      volumes:
        - name: nfs-client-root
          nfs:
            server: 172.16.0.11
            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

检查配置是否生效

# 1. 检查默认存储信息
[root@master01 ~]# kubectl get sc
NAME                    PROVISIONER                                   RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
nfs-storage (default)   k8s-sigs.io/nfs-subdir-external-provisioner   Delete          Immediate           false                  49s

# 2. 我们创建一个pvc,注意,不要配置默认存储
[root@master01 ~]# vim pvc-test01.yaml

[root@master01 ~]# kubectl apply -f pvc-test01.yaml
The PersistentVolumeClaim "nginx-pvc" is invalid: spec: Forbidden: spec is immutable after creation except resources.requests for bound claims
  core.PersistentVolumeClaimSpec{
        ... // 2 identical fields
        Resources:        {Requests: {s"storage": {i: {...}, Format: "BinarySI"}}},
        VolumeName:       "pv02-1gi",
-       StorageClassName: nil,
+       StorageClassName: &"nfs",
        VolumeMode:       &"Filesystem",
        DataSource:       nil,
  }
# 3. 这个报错主要是因为名称重复了,改个名字即可
[root@master01 ~]# vim pvc-test01.yaml
[root@master01 ~]# kubectl get pvc
NAME        STATUS   VOLUME     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
nginx-pvc   Bound    pv02-1gi   1Gi        RWX            nfs            23d
[root@master01 ~]# vim pvc-test01.yaml
[root@master01 ~]# kubectl apply -f pvc-test01.yaml
persistentvolumeclaim/nginx-pvc1 created

# 4. t@master01 ~]# kubectl get pvc
NAME         STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE
nginx-pvc    Bound    pv02-1gi                                   1Gi        RWX            nfs            23d
nginx-pvc1   Bound    pvc-9310f71e-248e-4de0-893a-5df7230421ab   200Mi      RWX            nfs-storage    6s

# 5. 我们可以看到,我们没有配置pv,但是默认给我们自动创建了一个pvc申请大小的pv
[root@master01 ~]# kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS      CLAIM                STORAGECLASS   REASON   AGE
pv01-10m                                   10M        RWX            Retain           Available                        nfs                     23d
pv02-1gi                                   1Gi        RWX            Retain           Bound       default/nginx-pvc    nfs                     23d
pv03-3gi                                   3Gi        RWX            Retain           Available                        nfs                     23d
pvc-9310f71e-248e-4de0-893a-5df7230421ab   200Mi      RWX            Delete           Bound       default/nginx-pvc1   nfs-storage             33s
[root@master01 ~]#

2、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

安装完成后,我们就可以看到集群机器的资源信息了

[root@master01 ~]# kubectl get pods -A| grep "metri"
kube-system            metrics-server-6497cc6c5f-p59sh              1/1     Running     8          44d
kubernetes-dashboard   dashboard-metrics-scraper-79c5968bdc-nmfr7   1/1     Running     3          42d
[root@master01 ~]# kubectl top nodes
NAME       CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%
master01   200m         5%     1540Mi          41%
node01     98m          2%     912Mi           11%
node02     100m         2%     1090Mi          14%
[root@master01 ~]#

3、安装KubeSphere

官网地址:https://kubesphere.com.cn/

  1. 下载安装及配置yaml文件(我这里下载的是比较新的版本)
kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.3.2/kubesphere-installer.yaml

kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.3.2/cluster-configuration.yaml
  1. 修改cluster-configuration
  1. 在 cluster-configuration.yaml中指定我们需要开启的功能
  2. 参照官网“启用可插拔组件” https://kubesphere.com.cn/docs/pluggable-components/overview/
  1. 安装
kubectl apply -f kubesphere-installer.yaml

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

安装完成后,访问集群中任意机器的30880端口即可使用

http://172.16.0.11: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


标签:name,KubeSphere,平台,server,metrics,nfs,io,k8s,安装
From: https://blog.51cto.com/u_5147178/6547850

相关文章

  • kubesphere多租户实战
    一、说明目前kubesphere3.3.2做了一些改变,将角色分为三级,分别是平台角色、空间角色、项目角色二、平台角色platform-self-provisioner:创建企业空间,并成为所创建的企业空间的管理员(企业空间管理员)platform-regular:被邀请加入企业空间之前无法访问任何资源(普通用户)platform-admin:管......
  • "Setuperr"是一个Windows系统安装过程中生成的错误日志文件
    "Setuperr"是一个Windows系统安装过程中生成的错误日志文件。它记录了安装过程中发生的错误和问题,以便帮助诊断和解决安装失败或出现问题的情况。通常,"Setuperr"日志文件位于以下目录中:C:$WINDOWS.~BT\Sources\Panther\setuperr.log要查看"Setuperr"日志文件,请按照以下步骤进行......
  • 小米手机安装证书
    一.使用QQ浏览器下载证书,证书格式未pem,无法直接打开,可以查看“详情”,在QQ浏览器里找到该文件,并移动到一个自己能记住的目录。 现在的小米、华为等设备,安装证书的正确步骤是:1.chls.pro/ssl下载证书2.进入到设置-wifi,点击高级,安装证书二.按照路径找到刚刚移动的pem文件,起一个文......
  • centos7-datax和datax-web安装以及安装中问题的解决
    一、下载这些软件(见) 系统变量设置(安装maven和jdk略)vi /etc/profileJAVA_HOME=/usr/local/jdk1.8.0_40CLASSPATH=$JAVA_HOME/lib/PATH=$PATH:$JAVA_HOME/binDATAX_HOME=/usr/local/dataxPATH=$PATH:$DATAX_HOME/bin exportMAVEN_HOME=/usr/local/apache-maven-3......
  • 3DCAT实时云渲染助力上海市乡村振兴可视化平台,展现数字乡村的魅力
    乡村振兴是党的十九大提出的重大战略,是实现中华民族伟大复兴的重要基础。上海作为超大城市,如何推进乡村振兴,让乡村成为城市发展的重要支撑和生态屏障,是一项重大课题。为了全面展示上海市乡村振兴的成果和规划,惟亚(上海)数字科技有限公司(下文简称“惟亚科技”)打造了上海市乡村振兴......
  • TomCat快速安装使用
    下载这就不多说了,直接官网下载https://tomcat.apache.org/直接解压配置环境变量(提前安装好java,配置好java的环境变量)配置Tomcat环境变量前一定要配置好java的环境变量,尤其是JAVA_HOME新建CATALINA_HOME环境变量,变量:CATALINA_HOME值:D:\DevelopmentTool\apache-tomcat-9......
  • Postgresql 9.2安装配置教程(Windows)
    1、安装Postgresql9.2 https://blog.csdn.net/LY1201A/article/details/1064287332、安装postgishttps://www.codenong.com/cs107080664/3、配置连接https://www.cnblogs.com/xysgis/articles/16513814.html4、PostgreSQL安装,出现Failedtoloadsqlmodulesintothedat......
  • 配置vnc远程连接Linux和unix服务器图形界面安装Oracle
    1、配置并开启vnc服务[oracle@localhost~]$vncserverYouwillrequireapasswordtoaccessyourdesktops.Password:---这里要求输入vnc客户端登录的密码并重复Verify:New'localhost.localdomain:2(oracle)'desktopislocalhost.localdo......
  • RTSP/Onvif协议安防平台EasyNVR调用接口录像会被自动删除的原因排查与解决
    EasyNVR安防视频云服务是基于RTSP/Onvif协议接入的视频平台,可支持将接入的视频流进行全平台、全终端的分发,分发的视频流包括RTSP、RTMP、HTTP-FLV、WS-FLV、HLS、WebRTC等。平台丰富灵活的视频能力,可应用在智慧校园、智慧工厂、智慧水利等场景中。有用户反馈,在使用EasyNVR接入设备......
  • 【已解决】【Tensorflow2.12.0版本以后合并CPU和GPU版】Tensorflow-gpu==2.12.0 安装
    !https://zhuanlan.zhihu.com/p/639416152解决方式:直接上解决方式,需要知道原因的看后文。直接安装tensroflow,从2022年12月起tensorflow-gpu已经合并到tensorflow包中了pipinstalltensorflow==2.12.0-ihttps://pypi.tuna.tsinghua.edu.cn/simple这里使用清华源......