kubesphare 学习尚硅谷

视频地址:https://www.bilibili.com/video/BV13Q4y1C7hS
文档地址:https://www.yuque.com/leifengyang/oncloud/gz1sls基于 kubernetes 构建的分布式、多租户、多集群、企业级开源容器平台,具有强大且完善的网络与存储能力,并通过极简的人机交互提供多集群管理、CI/CD、微服务治理、应用集群管理等功能。

命令

kubectl get storageclass|sc:查看存储类,动态的 pv 功能

kubectl top nodes:查看节点资源使用情况
kubectl top pods:查看 pod 资源使用情况

安装

k8s 安装

安装完 kubernetes 后,先需安装 kubesphere 前置环境
安装 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 (nfs 机器ip)mkdir -p /nfs/datamount -t nfs 172.31.0.4(nfs 机器ip):/nfs/data /nfs/data

配置默认存储,需要改配置中的 nfs 机器 ip 地址,就是使用动态 PV

## 创建了一个存储类
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:name: nfs-storageannotations: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-provisionerlabels:app: nfs-client-provisioner# replace with namespace where provisioner is deployednamespace: default
spec:replicas: 1strategy:type: Recreateselector:matchLabels:app: nfs-client-provisionertemplate:metadata:labels:app: nfs-client-provisionerspec:serviceAccountName: nfs-client-provisionercontainers:- name: nfs-client-provisionerimage: registry.cn-hangzhou.aliyuncs.com/lfy_k8s_images/nfs-subdir-external-provisioner:v4.0.2# resources:#    limits:#      cpu: 10m#    requests:#      cpu: 10mvolumeMounts:- name: nfs-client-rootmountPath: /persistentvolumesenv:- name: PROVISIONER_NAMEvalue: k8s-sigs.io/nfs-subdir-external-provisioner- name: NFS_SERVERvalue: 172.31.0.4 ## 指定自己nfs服务器地址- name: NFS_PATH  value: /nfs/data  ## nfs服务器共享的目录volumes:- name: nfs-client-rootnfs:server: 172.31.0.4 ## 指定自己nfs服务器地址path: /nfs/data
---
apiVersion: v1
kind: ServiceAccount
metadata:name: nfs-client-provisioner# replace with namespace where provisioner is deployednamespace: 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: 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

运行该 yaml

通过 kubectl get storageclass|sc 可查看配置是否生效(上方的文件系统)

安装 metrics

集群指标监控组件
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- --kubelet-insecure-tls- --secure-port=4443- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname- --kubelet-use-node-status-portimage: registry.cn-hangzhou.aliyuncs.com/lfy_k8s_images/metrics-server:v0.4.3imagePullPolicy: 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-criticalhostNetwork: true  #监控安装失败可加上这句serviceAccountName: 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

安装后可通过命令 kubectl top nodes 查看节点资源占用情况
kubectl top pods 查看 pod 资源占用情况

安装 kubesphere
下载核心文件

# 安装器
wget https://github.com/kubesphere/ks-installer/releases/download/v3.1.1/kubesphere-installer.yaml
# 集群配置,需要把文件中的所有 false 改成true,开启可插拔功能
wget https://github.com/kubesphere/ks-installer/releases/download/v3.1.1/cluster-configuration.yaml
cluster-configuration 需改动 etcd 的ip
etcd.monitoring
common.redis.enabled
common.openldap.enabled
alerting.enable
auditing.enabled
devops.enabled
events.enabled
logging.enabled
network.networkpolicy.enabled
network.ippool.type 改为 calico
openpitrix.store.enabled
servicemesh.enabled
kubeedge.enabled 
以上都改为true,开启一些功能

查看集群安装进度

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
等所有 pod 运行成功再登录

解决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单节点部署

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.xdnf.cn/news/1536156.html

如若内容造成侵权/违法违规/事实不符,请联系一条长河网进行投诉反馈,一经查实,立即删除!

相关文章

数据库事务中的四大问题:脏读、脏写、不可重复读与幻读详解

数据库事务中的四大问题:脏读、脏写、不可重复读与幻读详解 什么是脏读 定义 事务B读取数据时,读取到的是事务A更新之后,但还未提交的数据。 事务A修改了一条数据,但是还没有提交时,事务B查询到了这条未提交的数据…

AI基础 L22 Uncertainty over Time I 时间的不确定性

Time and Uncertainty 1 Time and Uncertainty States and Observations • discrete-time models: we view the world as a series of snapshots or time slices • the time interval ∆ between slices, we assume to be the same for every interval • Xt: denotes the se…

【初阶数据结构】排序

目录 一、排序的概念及其运用 1.1排序的概念 1.2常见的排序算法 二、常见排序算法的实现 2 .1插入排序 2 .1.1基本思想: 2.1.2直接插入排序: 算法复杂度: 最坏情况: 最好的情况: 直接插入排序的特性总结&…

Unity实战案例全解析:PVZ 植物放置分析

前篇:Unity实战案例全解析:PVZ 植物卡片状态分析-CSDN博客 植物应该如何从卡牌状态转为实物? 其实就只需要考虑两个步骤加一个后续处理: 1.点击卡牌后就实例化 需要一个植物状态枚举,因为卡牌分为拿在手上和种植下…

大众点评代发收录

大众点评代发收录 大众点评的代运营到底靠谱不靠谱?擦亮你的眼睛,别再被割韭菜了。#代运营 #永善 #干货分享 #大众点评运营 #美团运营 你的网站被百度搜录了吗?普京说过,给我 20 年,还你一个强大的俄罗斯。那么狂潮老…

SAP HCM HR_ABS_ATT_TIMES_AT_ENTRY 跨夜班不生效问题

导读 跨夜班标准函数不生效:今天客户提出一个问题,计算请假时长不生效的问题(微信小程序调用SAP接口),但是在PA30中能正确计算,所以问题肯定就是在调用标准函数的时候,参数设置问题&#xff0c…

20Kg载重30分钟续航多旋翼无人机技术详解

一、机架与结构设计 1. 材料选择:为了确保无人机能够承载20Kg的负载,同时实现30分钟的续航,其机架材料需选用轻质高强度的材料,如碳纤维或铝合金。这些材料不仅具有良好的承重能力,还能有效减轻无人机的整体重量&…

【linux基础】linux中的开发工具(4)--调试器gdb的使用

目录 前言一,背景二,gdb的使用1. 启动 gdb 调试器:2. 罗列代码信息3. 运行程序4. 有关断点的操作(1) 打断点(2) 查看断点(3) 删除断点(4) 在一次调试中,断点是递增的(5) 关闭断点(6) 开启断点(7) 逐过程调试,相当于 F1…

Redis模拟消息队列实现异步秒杀

目录 一、消息队列含义 二、Redis实现消息队列 1、基于List的结构模拟实现消息队列 2、基于PubSub的消息队列 3、基于Stream的消息队列 4、基于Stream的消息队列- 消费者组 一、消息队列含义 消息队列(Message Queue),字面意思就是存放…

MyBatis中一对多关系的两种处理方法

目录 1.多表联查(通过collection标签的ofType属性) 1)mapper 2)mapper.xml 3)测试代码 4)测试结果 2.分布查询(通过collection标签的select属性) 1)mapper 2)mapper.xml 3&#xff0…

优化算法(三)—模拟退火算法(附MATLAB程序)

模拟退火算法(Simulated Annealing, SA)是一种基于概率的优化算法,旨在寻找全局最优解。该算法模拟金属退火过程中的物质冷却过程,逐渐降低系统的“温度”以达到全局优化的效果。它特别适用于解决复杂的组合优化问题。 一、模拟退…

[产品管理-21]:NPDP新产品开发 - 19 - 产品设计与开发工具 - 详细设计与规格定义

目录 前言: 一、详细设计与规格定义概述 1、产品详细设计 2、规格定义 3、详细设计与规格定义的关系 4、实际应用中的注意事项 二、详细设计与规格定义主要工具 2.1 质量功能展开QFD - 需求跟踪矩阵 1、QFD的基本原理 2、QFD的实施步骤 3、QFD的优势与应…

人工智能开发实战matplotlib库应用基础

内容导读 matplotlib简介绘制直方图绘制撒点图 一、matplotlib简介 matplotlib是一个Python 2D绘图库,它以多种硬拷贝格式和跨平台的交互式环境生成高质量的图形。 matplotlib 尝试使容易的事情变得更容易,使困难的事情变得可能。 我们只需几行代码…

解锁全球机遇:澳大利亚服务器租用市场的独特魅力

在浩瀚的全球数字版图中,澳大利亚以其独特的地理位置、丰富的资源禀赋、以及日益增长的数字经济活力,成为了众多互联网企业竞相布局的重要市场。特别是当谈及服务器租用这一关键环节时,澳大利亚以其稳定的网络环境、先进的基础设施和开放的市…

[数据集][目标检测]智慧交通铁路异物入侵检测数据集VOC+YOLO格式802张7类别

数据集格式:Pascal VOC格式YOLO格式(不包含分割路径的txt文件,仅仅包含jpg图片以及对应的VOC格式xml文件和yolo格式txt文件) 图片数量(jpg文件个数):802 标注数量(xml文件个数):802 标注数量(txt文件个数):802 标注类别…

知识竞赛活动舞台搭建要多少钱

每次举办活动,舞台搭建总是让人头疼的一部分,尤其是费用问题。今天就来揭开活动舞台搭建费用的神秘面纱。 活动舞台搭建的费用主要包括舞台结构、设备、音响、灯光、舞美装饰等各方面的成本。具体来说: 1.舞台结构:包括舞台平台…

5.TensorBoard的使用(二)--add_image()

TensorBoard的使用(二) 1.使用add_image()给添加图片 首先导入Tensorboard包 from torch.utils.tensorboard import SummaryWriter创建一个SummaryWriter类的实例,并将所有的事件文件保存在logs文件夹中 writer SummaryWriter(logs)使用add…

完整版订单超时自动取消功能

前几天对实习还是继续学习技术产生了抉择,问了一个前辈,他抛给我一个问题,怎么做15分钟订单自动取消,我说然后到时间之后,自动执行这个订单关闭业务,比如把锁了的库存给解开等等操作,然后在数据…

【算法篇】哈希类(笔记)

目录 一、常见的三种哈希结构 二、LeetCode 练习 1. 有效的字母异位词 2. 两个数组的交集 3. 快乐数 4. 两数之和 5. 四数相加II 6. 赎金信 7. 三数之和 8. 四数之和 一、常见的三种哈希结构 当想使用哈希法来解决问题的时候,一般会选择如下三种数据…

4.接口测试基础(Jmter工具/场景二:一个项目由多个人负责接口测试,我只负责其中三个模块,协同)

一、场景二:一个项目由多个人负责接口测试,我只负责其中三个模块,协同 1.什么是测试片段? 1)就相当于只是项目的一部分用例,不能单独运行,必须要和控制器(include,模块)一…