参考文章:

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. go生成xml

    package main import ( "encoding/xml" "fmt" // "os" ) type Servers stru ...

  2. 服务器之ipmitool

    一般命令 raw #发送一个原始的IPMI请求,并且打印回复信息. Lan #配置网络(lan)信道(channel) chassis #查看底盘的状态和设置电源 event #向BMC发送一个已经定 ...

  3. UTI 唯一类型标识

    本文转载至 http://blog.csdn.net/zaitianaoxiang/article/details/6657231   applicationdocumentationtypessys ...

  4. Android开发:《Gradle Recipes for Android》阅读笔记(翻译)4.1——编写自己的任务

    问题: 你想用自己的任务定制gradle的构建过程. 解决方案: 在gradle的build文件里面增加task元素.用Android插件支持的extra属性使得开发更容易. 讨论: Gradle的D ...

  5. Android Studio中debug和release模式默认的参数配置

    The possible properties and their default values are: debuggable:表示是否可以在手机上调试程序. 在Eclipse中,只有android ...

  6. linux下不错的小软件

    1.Shutter截图软件 可以完成基本截图功能,而且还有图片编辑功能,可以涂鸦添加水印等. 以下的截图全部归功于shutter软件. 2.VLC media player 媒体播放器 3.Termi ...

  7. water mark

    图片水印 https://www.oschina.net/p/watermarkjs?nocache=1542795300822 https://www.cnblogs.com/pengjunhao/ ...

  8. C 和 C++ 的标准库分别有自己的 locale 操作方法,C 标准库的 locale 设定函数是 setlocale(),而 C++ 标准库有 locale 类和流对象的 imbue() 方法(gcc使用zh_CN.GBK,或者zh_CN.UTF-8,VC++使用Chinese_People's Republic of China.936或者65001.)

    转自:http://zyxhome.org/wp/cc-prog-lang/c-stdlib-setlocale-usage-note/ [在此向原文作者说声谢谢!若有读者看到文章转载时请写该转载地址 ...

  9. 虚拟研讨会:如何设计好的RESTful API(转)

    原文:虚拟研讨会:如何设计好的RESTful API? REST架构风格最初由Roy T. Fielding(HTTP/1.1协议专家组负责人)在其2000年的博士学位论文中提出.HTTP就是该架构风 ...

  10. ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'localhost'

    安装ranger时MySQL报错,查看MySQL数据库,发现host=localhost这一列被删除了,插入这一列就好了,具体操作如下: 解决办法: 进入MySQL数据库 use mysql: &qu ...