K8S当中的本地卷(Local PV)的使用
Local PV是从kuberntes 1.10开始引入,本质目的是为了解决hostPath的缺陷。通过PV控制器与Scheduler的结合,会对local PV做针对性的逻辑处理,从而,让Pod在多次调度时,能够调度到同一个Node上。
这次,测试了一下将local PV挂载到一个httpd的应用上。
要注意,pvc是按namespace提供的。还有,matchExpressions作匹配的主机名规则。
一,local-pv.yaml
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: local-pv-sda
spec:
capacity:
storage: 100Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: local-storage
local:
path: /data/pv
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- spark-docker
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: local-pvc-sda
namespace: in-demo
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-storage
resources:
requests:
storage: 10Gi
二,httpd.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: httpd
namespace: in-demo
spec:
replicas: 2
revisionHistoryLimit: 5
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
app: httpd-dm
spec:
terminationGracePeriodSeconds: 60
restartPolicy: Always
containers:
- name: httpd
image: httpd:alpine
imagePullPolicy: IfNotPresent
volumeMounts:
- name: storage-localpv
mountPath: "/usr/local/apache2/htdocs"
volumes:
- name: storage-localpv
persistentVolumeClaim:
claimName: local-pvc-sda
---
apiVersion: v1
kind: Service
metadata:
name: httpd-svc
namespace: in-demo
spec:
ports:
- name: http-port
port: 80
targetPort: 80
selector:
app: httpd-dm
K8S当中的本地卷(Local PV)的使用的更多相关文章
- K8S 本地 配置 Local PV 实践
上面我们创建了后端是 hostPath 类型的 PV 资源对象,我们也提到了,使用 hostPath 有一个局限性就是,我们的 Pod 不能随便漂移,需要固定到一个节点上,因为一旦漂移到其他节点上去了 ...
- Kubernetes 1.14发布:对Windows节点的生产级支持、Kubectl更新与持久本地卷通用版本已全面到来
今天,我们高兴地宣布Kubernetes 1.14版本的正式亮相,这亦是我们在2019年当中进行的首次发布!Kubernetes 1.14版本由31项增强功能组成,具体包括:10项稳定版功能,12项b ...
- kubernetes(14):k8s基于NFS部署storageclass实现pv自动供给
k8s基于NFS部署storageclass实现pv自动供给 https://www.cnblogs.com/Smbands/p/11059843.html https://www.jianshu.c ...
- Hadoop部署方式-本地模式(Local (Standalone) Mode)
Hadoop部署方式-本地模式(Local (Standalone) Mode) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. Hadoop总共有三种运行方式.本地模式(Local ...
- HTML5本地存储(Local Storage) 的前世今生
长久以来本地存储能力一直是桌面应用区别于Web应用的一个主要优势.对于桌面应用(或者原生应用),操作系统一般都提供了一个抽象层用来帮助应用程序保存其本地数据 例如(用户配置信息或者运行时状态等). 常 ...
- iOS 远程通知(Remote Notification)和本地通知(Local Notification)
ios通知分为远程通知和本地通知,远程通知需要连接网络,本地通知是不需要的,不管用户是打开应用还是关闭应用,我们的通知都会发出,并被客户端收到 我们使用远程通知主要是随时更新最新的数据给用户,使用本地 ...
- K8s存储卷、pv和pvc的使用
emptyDIR 临时目录 hostPath :使用主机的路径 网络存储: 传统的设备存储:NAS,SAN 分布式存储:glusterfs,rbd,cephfs 云存储:EBS,Azure,阿里云的 ...
- Kubernetes 搭建 ES 集群(存储使用 local pv)
一.集群规划 由于当前环境中没有分布式存储,所以只能使用本地 PV 的方式来实现数据持久化. ES 集群的 master 节点至少需要三个,防止脑裂. 由于 master 在配置过程中需要保证主机名固 ...
- k8s实战之数据卷(volume)
一.概述 数据卷用于实现容器持久化数据,k8s对于数据卷重新定义,提供了丰富强大的功能:数据卷分为三类: 本地数据卷,网络数据卷和信息数据卷 二.
随机推荐
- [LeetCode] 9. Palindrome Number 验证回文数字
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same back ...
- Educational Codeforces Round 61 (Rated for Div. 2) E 多重背包优化
https://codeforces.com/contest/1132/problem/E 题意 有8种物品,重量是1~8,每种数量是\(cnt[i]\)(1e16),问容量为W(1e18)的背包最多 ...
- xBIM之二:构建墙和门窗
研究了两天,终于实现了利用xBIM自动输出墙和门窗 比较粗糙的源码如下: private void Form1_Load(object sender, EventArgs e) { //first c ...
- [LeetCode] 72. Edit Distance 编辑距离
Given two words word1 and word2, find the minimum number of operations required to convert word1 to ...
- tecplot——Fluent重叠网格解决方案
算例来源:http://blog.sina.com.cn/s/blog_af99efb50102xoh3.html 受上篇博文的启发,在tecplot当中也能采用类似的方法处理Fluent的重叠网格计 ...
- 首次体验MangoDB
Author:SimpleWu MongoDB官方网:https://www.mongodb.com/ MongoDB中文网:http://www.mongodb.org.cn/ 什么是MongoDB ...
- Java 性能调优小技巧
1.在知道必要之前不要优化系统 这可能是最重要的性能调整技巧之一.你应该遵循常见的最佳实践做法并尝试高效地实现用例.但是,这并不意味着在你证明必要之前,你应该更换任何标准库或构建复杂的优化. 在大多数 ...
- 深入理解C语言 - 指针使用的常见错误
在C语言中,指针的重要性不言而喻,但在很多时候指针又被认为是一把双刃剑.一方面,指针是构建数据结构和操作内存的精确而高效的工具.另一方面,它们又很容易误用,从而产生不可预知的软件bug.下面总结一下指 ...
- Kettle提高表输出写入速度(每秒万条记录)
重点: ETL 优化多数在于表输入和表输出. 转自: https://blog.csdn.net/qq_37124304 https://blog.csdn.net/qq_37124304/artic ...
- RBAC类在ThinkPHP中的四种使用方法
第一类:放在登陆控制器的登陆操作中 1.RBAC::authenticate(); 用于在用户表中查找表单提交的用户名的数据,实质上就是一条用户表查寻语句,=====> return M(mod ...