参考文章:

https://kubernetes.io/docs/concepts/storage/volumes/

https://www.cnblogs.com/styshoo/p/6731425.html

容器中的磁盘文件是短暂的,这为在容器中运行重要的应用程序带来了一些问题。

第一 当容器崩溃时,Kubelet将会重启容器,这时候数据文件就会丢失。

第二 在同一个Pod中的容器通常需要共享数据。

Kubernetes使用Volume抽象解决了这两个问题。  

Kubernetes supports several types of Volumes:

  • awsElasticBlockStore
  • azureDisk
  • azureFile
  • cephfs
  • configMap
  • csi
  • downwardAPI
  • emptyDir
  • fc (fibre channel)
  • flocker
  • gcePersistentDisk
  • gitRepo
  • glusterfs
  • hostPath
  • iscsi
  • local
  • nfs
  • persistentVolumeClaim
  • projected
  • portworxVolume
  • quobyte
  • rbd
  • scaleIO
  • secret
  • storageos
  • vsphereVolume

NFS PersistentVolume

前提条件:搭建NFS服务器,K8s node安装nfs客户端

pv-yaml

apiVersion: v1
kind: PersistentVolume
metadata:
name: nginx-data
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteMany
nfs:
path: /nfs-data
server: 172.16.65.200
persistentVolumeReclaimPolicy: Recycle

pvc-yaml

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nginx-data
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi

deployment-yaml

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-web
spec:
replicas: 3
selector:
matchLabels:
name: nginx-web
template:
metadata:
labels:
name: nginx-web
spec:
containers:
- name: nginx-web
image: nginx
volumeMounts:
- mountPath: /usr/share/nginx/html
name: nginx-data
ports:
- containerPort: 80
volumes:
- name: nginx-data
persistentVolumeClaim:
claimName: nginx-data

service-yaml

apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
name: nginx-web
type: NodePort
ports:
- port: 80
protocol: TCP
targetPort: 80
name: http
nodePort: 30080

Kubernetes Storage的更多相关文章

  1. Kubernetes Storage Persistent Volumes

    链接:https://kubernetes.io/docs/concepts/storage/persistent-volumes/ 支持的参数,比如mountOptions在这里可以找到 删除正在被 ...

  2. Kubernetes 存储系统 Storage 介绍

    本文环境为Kubernetes V1.11,操作系统版本为 CentOs 7.3,Kubernetes集群安装可以参考 kubeadm安装kubernetes V1.11.1 集群 容器中的存储都是临 ...

  3. kubernetes 实战3_命令_Configure Pods and Containers

    Configure a Pod to Use a PersistentVolume for Storage how to configure a Pod to use a PersistentVolu ...

  4. Stateful Kubernetes Applications Made Easier: PSO and FlashBlade

    转自:https://medium.com/@joshua_robinson/stateful-kubernetes-applications-made-easier-pso-and-flashbla ...

  5. 云原生入门 第五章:kubernetes学习实践

    1. 简介 在本章中,我们将学习不同的Kubernetes对象,它们的用途以及如何与它们交互. 在设置集群或使用现有集群之后,我们可以开始部署一些工作负载.Kubernetes中最小的计算单元不是一个 ...

  6. Kubernetes:存储管理

    Blog:博客园 个人 参考:Volumes | Kubernetes.Persistent Volumes | Kubernetes.Kubernetes 基础入门实战 简单来说,存储卷是定义在Po ...

  7. Longhorn,企业级云原生容器分布式存储 - 备份与恢复

    内容来源于官方 Longhorn 1.1.2 英文技术手册. 系列 Longhorn 是什么? Longhorn 企业级云原生容器分布式存储解决方案设计架构和概念 Longhorn 企业级云原生容器分 ...

  8. Kubernetes 存储系统 Storage 介绍:PV,PVC,SC

    要求:先了解数据docker容器中数据卷的挂载等知识 参考网址: https://www.cnblogs.com/sanduzxcvbnm/p/13176938.html https://www.cn ...

  9. (转帖)开源容器集群管理系统Kubernetes架构及组件介绍

    最近在搞Docker还有她的管理工具,选型Kuberetes后,被她的术语和概念搞得晕头转向...看了一篇文章还不错,放到这里分享出来. 地址:http://www.linuxidc.com/Linu ...

随机推荐

  1. servlet部署到tomcat中

    引用:http://blog.csdn.net/shuidao/article/details/1738059 配置,部署 servlet: 1. 在tomcat的安装目录下 找到webapps 文件 ...

  2. 2015年天勤考研机试模拟赛 A 推断三角形

    [思路]:採用atoi转换长度.两边仅仅和大于第三边,两边之差小于第三边. [AC代码]: #include <iostream> #include <algorithm> # ...

  3. idea Plugin "Maven Integration Extension" was not loaded: required plugin "Maven Integration" is disabled

    由于自己运行了eclipse maven及idea maven 同时操作,可能产生了以上错误.既: idea  Plugin "Maven Integration Extension&quo ...

  4. HTML5新增的语义标签和IE版本低的兼容性问题

    <!DOCTYPE html><html> <head> <!-- HTML5中浏览器兼容(较低版本的IE浏览器不支持H5的布局):需要在<head&g ...

  5. Web开发之容器

    Web开发之容器 主题 Servlet容器.Web容器.应用服务器 参考资料   Servlet容器.Web容器.应用服务器         Servlet容器的主要任务是管理Servlet的生命周期 ...

  6. iOS KVO详解

    一.KVO 是什么? KVO 是 Objective-C 对观察者设计模式的一种实现.[另外一种是:通知机制(notification),详情参考:iOS 趣谈设计模式——通知]: KVO 提供一种机 ...

  7. 通过margin负值去除padding

    .pay-type { // 图片布局前通过margin负值去除padding margin: 0 -@page-padding-horizontal; display: inline-flex; } ...

  8. JS续

    JS中的事件 [JS中的事件分类] * 1.鼠标事件: * click/dbclick/mouseover/mouseout/mousemove/mousedown/mouseup * * 2.键盘事 ...

  9. MFC重绘原理的关键理解

    // ====================Windows重绘消息与函数========================== 得到桌面窗口的句柄,然后再绘图HWND GetDesktopWindow ...

  10. 前端基础 & 初识CSS

    CSS介绍 CSS(Cascading Style Sheet,层叠样式表)定义如何显示HTML元素.l 当浏览器读到一个样式表,它就会按照这个样式表来对文档进行格式化(渲染). CSS语法 每个CS ...