使用StorageClass动态创建pv

rook-ceph安装部署到位后,就可以开始来尝试使用StorageClass来动态创建pv了。

有状态的中间件在kubernetes上落地基本上都会用到StorageClass来动态创建pv(对于云上应用没有那么多烦恼,云硬盘很好用,但是对于自己学习和练习来说还是Ceph更加靠谱),这里小试一试动态创建pv的威力,为后续用它来玩转redis、zookeeper、elasticsearch做准备。

1、创建 StorageClass和存储池

kubectl create -f rook/deploy/examples/csi/rbd/storageclass.yaml

查看创建的cephblockpool和StorageClass

kubectl get cephblockpool -n rook-ceph
kubectl get sc

结果如下:

rook/deploy/examples/csi/rbd/storageclass.yaml内容如下:

apiVersion: ceph.rook.io/v1
kind: CephBlockPool
metadata:name: replicapoolnamespace: rook-ceph # namespace:cluster
spec:failureDomain: hostreplicated:size: 2# Disallow setting pool with replica 1, this could lead to data loss without recovery.# Make sure you're *ABSOLUTELY CERTAIN* that is what you wantrequireSafeReplicaSize: true# gives a hint (%) to Ceph in terms of expected consumption of the total cluster capacity of a given pool# for more info: https://docs.ceph.com/docs/master/rados/operations/placement-groups/#specifying-expected-pool-size#targetSizeRatio: .5
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:name: rook-ceph-block
# Change "rook-ceph" provisioner prefix to match the operator namespace if needed
provisioner: rook-ceph.rbd.csi.ceph.com
parameters:# clusterID is the namespace where the rook cluster is running# If you change this namespace, also change the namespace below where the secret namespaces are definedclusterID: rook-ceph # namespace:cluster# If you want to use erasure coded pool with RBD, you need to create# two pools. one erasure coded and one replicated.# You need to specify the replicated pool here in the `pool` parameter, it is# used for the metadata of the images.# The erasure coded pool must be set as the `dataPool` parameter below.#dataPool: ec-data-poolpool: replicapool# (optional) mapOptions is a comma-separated list of map options.# For krbd options refer# https://docs.ceph.com/docs/master/man/8/rbd/#kernel-rbd-krbd-options# For nbd options refer# https://docs.ceph.com/docs/master/man/8/rbd-nbd/#options# mapOptions: lock_on_read,queue_depth=1024# (optional) unmapOptions is a comma-separated list of unmap options.# For krbd options refer# https://docs.ceph.com/docs/master/man/8/rbd/#kernel-rbd-krbd-options# For nbd options refer# https://docs.ceph.com/docs/master/man/8/rbd-nbd/#options# unmapOptions: force# (optional) Set it to true to encrypt each volume with encryption keys# from a key management system (KMS)# encrypted: "true"# (optional) Use external key management system (KMS) for encryption key by# specifying a unique ID matching a KMS ConfigMap. The ID is only used for# correlation to configmap entry.# encryptionKMSID: <kms-config-id># RBD image format. Defaults to "2".imageFormat: "2"# RBD image features# Available for imageFormat: "2". Older releases of CSI RBD# support only the `layering` feature. The Linux kernel (KRBD) supports the# full complement of features as of 5.4# `layering` alone corresponds to Ceph's bitfield value of "2" ;# `layering` + `fast-diff` + `object-map` + `deep-flatten` + `exclusive-lock` together# correspond to Ceph's OR'd bitfield value of "63". Here we use# a symbolic, comma-separated format:# For 5.4 or later kernels:#imageFeatures: layering,fast-diff,object-map,deep-flatten,exclusive-lock# For 5.3 or earlier kernels:imageFeatures: layering# The secrets contain Ceph admin credentials. These are generated automatically by the operator# in the same namespace as the cluster.csi.storage.k8s.io/provisioner-secret-name: rook-csi-rbd-provisionercsi.storage.k8s.io/provisioner-secret-namespace: rook-ceph # namespace:clustercsi.storage.k8s.io/controller-expand-secret-name: rook-csi-rbd-provisionercsi.storage.k8s.io/controller-expand-secret-namespace: rook-ceph # namespace:clustercsi.storage.k8s.io/node-stage-secret-name: rook-csi-rbd-nodecsi.storage.k8s.io/node-stage-secret-namespace: rook-ceph # namespace:cluster# Specify the filesystem type of the volume. If not specified, csi-provisioner# will set default as `ext4`. Note that `xfs` is not recommended due to potential deadlock# in hyperconverged settings where the volume is mounted on the same node as the osds.csi.storage.k8s.io/fstype: ext4
# uncomment the following to use rbd-nbd as mounter on supported nodes
# **IMPORTANT**: CephCSI v3.4.0 onwards a volume healer functionality is added to reattach
# the PVC to application pod if nodeplugin pod restart.
# Its still in Alpha support. Therefore, this option is not recommended for production use.
#mounter: rbd-nbd
allowVolumeExpansion: true
reclaimPolicy: Delete

2、创nginx的StatefulSet,通过storageclass来动态创建pv绑定到 /usr/share/nginx/html    有状态的Pod,每个Pod都要有自己的pv。    对于redis、zookeeper、elasticsearch来说都会使用到storageClass来动态创建pv。

 kubectl apply -f test_volumnClainTemplates.yaml 

  查看命令如下:

kubectl get po -l app=nginx
kubectl get pvc

   结果如下:

   test_volumnClainTemplates.yaml的内容如下:

apiVersion: v1
kind: Service
metadata:name: nginxlabels:app: nginx
spec:ports:- port: 80name: webclusterIP: Noneselector:app: nginx
---
apiVersion: apps/v1
kind: StatefulSet
metadata:name: web
spec:selector:matchLabels:app: nginxserviceName: "nginx"replicas: 2  template:metadata: labels:app: nginxspec:terminationGracePeriodSeconds: 10 containers:- name: nginx image: nginx ports:- containerPort: 80 name: webvolumeMounts:- name: wwwmountPath: /usr/share/nginx/htmlvolumeClaimTemplates:- metadata:name: www spec:accessModes: [ "ReadWriteOnce" ] storageClassName: "rook-ceph-block"resources:requests:storage: 200M

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

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

kubernetes--技术文档-真--集群搭建-三台服务器一主二从(非高可用)-三服务器位于同交换机中

在使用k8s之前如果不太熟悉k8s的可以先看这个文章&#xff1a; kubernetes--技术文档--基本概念--《10分钟快速了解》_一单成的博客-CSDN博客 三节点相同安装操作&#xff1a; 1、设置hosts解析 根据角色在三个服务器中运行&#xff0c;设置自己的hostname。 标识&#xf…

Linux:编写编译脚本Makefile文件

一、生成可执行文件 1、一个源文件编译 本例子主要区别.c及.cpp文件及编译该文件时使用的编译链。 1).c文件 // testadd.c #include <stdio.h> int main() {int a 1;int b 2;int sum a b;printf("sum %d\n", sum);return 0; }// Makefie GXX g CC gcc…

无涯教程-PHP - XML GET

XML Get已用于从xml文件获取节点值。以下示例显示了如何从xml获取数据。 Note.xml 是xml文件&#xff0c;可以通过php文件访问。 <SUBJECT><COURSE>Android</COURSE><COUNTRY>India</COUNTRY><COMPANY>LearnFk</COMPANY><PRICE…

Android开发之性能优化:过渡绘制解决方案

1. 过渡绘制 屏幕上某一像素点在一帧中被重复绘制多次&#xff0c;就是过渡绘制。 下图中多个卡片跌在一起&#xff0c;但是只有第一个卡片是完全可见的。背后的卡片只有部分可见。但是Android系统在绘制时会将下层的卡片进行绘制&#xff0c;接着再将上层的卡片进行绘制。但其…

线上问诊:业务数据采集

系列文章目录 线上问诊&#xff1a;业务数据采集 文章目录 系列文章目录前言一、环境准备1.Hadoop2.Zookeeper3.Kafka4.Flume5.Mysql6.Maxwell 二、业务数据采集1.数据模拟2.采集通道 总结 前言 暑假躺了两个月&#xff0c;也没咋写博客&#xff0c;准备在开学前再做个项目找…

byte-budddy: Unexpected type reference on method: 19

使用byte-buddy版本为1.10.1 在使用agent时&#xff0c;启动应用&#xff0c;报错如下 造成报错的相关代码 Data public class CloudAccountUpdateReq implements Serializable {private List<Valid CloudAccountDiscountDTO> discountList;}已修复 issue: https://gi…

Arduino程序设计(四)按键消抖+按键计数

按键消抖按键计数 前言一、按键消抖二、按键计数1、示例代码2、按键计数实验 参考资料 前言 本文主要介绍两种按键控制LED实验&#xff1a;第一种是采用软件消抖的方法检测按键按下的效果&#xff1b;第二种是根据按键按下次数&#xff0c;四个LED灯呈现不同的流水灯效果。 一…

面试题(二)

目录 一.集合 (1) LinkedHashMap(JDK 1.8) (2) ArrayList (3) HashMap (4) ConcurrentHashMap 二. IO流 (1) 分类 (2) 应用 三.多线程 (1) 线程状态 (2) 死锁 (3) 应用 (4) 要点 (5) 线程池 返回 ThreadPoolExecutor 类分析 线程池原理分析 四. 数据库 (1) …

0基础学习VR全景平台篇 第89篇:智慧眼-安放热点

一、功能说明 安放热点&#xff0c;是智慧眼成员们正式进入城市化管理的第一步&#xff0c;即发现问题后以安放热点的形式进行标记&#xff0c;再由其他的角色成员对该热点内容作出如核实、处理、确认完结等操作&#xff08;具体流程根据项目实际情况而定&#xff09;。 二、…

geacon_pro配合catcs4.5上线Mac、Linux

我的个人博客: xzajyjs.cn 一些链接 Try师傅的catcs4.5项目: https://github.com/TryGOTry/CobaltStrike_Cat_4.5&#xff0c;最新版解压密码见&#xff1a;https://www.nctry.com/2708.html geacon_pro: https://github.com/testxxxzzz/geacon_pro BeaconTool.jar: https:/…

BERT、ERNIE、Grover、XLNet、GPT、MASS、UniLM、ELECTRA、RoBERTa、T5、C4

BERT、ERNIE、Grover、XLNet、GPT、MASS、UniLM、ELECTRA、RoBERTa、T5、C4 ELMOBERTERNIE![在这里插入图片描述](https://img-blog.csdnimg.cn/274e31d0f8274c748d05abe2ec65fc73.png)GroverXLNetGPTMASSUniLMELECTRARoBERTaT5C4ELMO BERT

干货分享:可证明安全的隐私计算

“隐语”是开源的可信隐私计算框架&#xff0c;内置 MPC、TEE、同态等多种密态计算虚拟设备供灵活选择&#xff0c;提供丰富的联邦学习算法和差分隐私机制 开源项目&#xff1a;github.com/secretflowgitee.com/secretflow 以下文章来源于DataFunTalk &#xff0c;作者洪澄 D…