管理存储是管理计算的一个明显问题。该PersistentVolume子系统为用户和管理员提供了一个API,用于抽象如何根据消费方式提供存储的详细信息。为此,我们引入了两个新的API资源:PersistentVolumePersistentVolumeClaim

PersistentVolume(PV)是群集中由管理员配置的一块存储。它是集群中的资源,就像节点是集群资源一样。PV是容量插件,如Volumes,但其生命周期独立于使用PV的任何单个pod。此API对象捕获存储实现的详细信息,包括NFS,iSCSI或特定于云提供程序的存储系统。

注意 pv 不是一个namespace资源  pv是跨namespace的共享对象,pvc是有namespace特征的

PersistentVolumeClaim(PVC)是由用户进行存储的请求。它类似于一个吊舱。Pod消耗节点资源,PVC消耗PV资源。Pod可以请求特定级别的资源(CPU和内存)。声明可以请求特定的大小和访问模式(例如,可以mounted once read/write or many times read-only)。

虽然PersistentVolumeClaims允许用户使用抽象存储资源,但是PersistentVolumes对于不同的问题,用户通常需要具有不同属性(例如性能)。群集管理员需要能够提供各种PersistentVolumes不同的方式,而不仅仅是大小和访问模式,而不会让用户了解这些卷的实现方式。对于这些需求,有StorageClass 资源。

创建PV(使用nfs方式或者local)这里使用nfs方式 手动供给方式很low

安装配置nfs服务器
[root@nlp-node1 3]# yum install nfs-utils rpcbind -y
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.huaweicloud.com
软件包 1:nfs-utils-1.3.0-0.61.el7.x86_64 已安装并且是最新版本
软件包 rpcbind-0.2.0-47.el7.x86_64 已安装并且是最新版本
无须任何处理
---------------------------------------------------
[root@nlp-node1 3]# vim /etc/exports
[root@nlp-node1 3]# cat /etc/exports
/kube_pv *(rw,sync,all_squash)
[root@nlp-node1 3]# systemctl start nfs.service rpcbind.service
[root@nlp-node1 3]# mkdir -pv /kube_pv
mkdir: 已创建目录 "/kube_pv"
[root@nlp-node1 3]# chown nfsnobody /kube_pv -R 创建pv

[root@master pvc]# cat pv.ymal 
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-test
namespace: default
spec:
capacity:
storage: 5Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Recycle
storageClassName: slow
nfs:
path: /kube_pv
server: 10.24.2.125

[root@master pvc]# kubectl create -f pv.ymal

[root@master pvc]# kubectl describe pv 
Name: pv-test
Labels: <none>
Annotations: <none>
Finalizers: [kubernetes.io/pv-protection]
StorageClass: slow
Status: Available
Claim: 
Reclaim Policy: Recycle
Access Modes: RWO
VolumeMode: Filesystem
Capacity: 5Gi
Node Affinity: <none>
Message: 
Source:
Type: NFS (an NFS mount that lasts the lifetime of a pod)
Server: 10.24.2.125
Path: /kube_pv
ReadOnly: false
Events: <none>
[root@master pvc]# cat pv.ymal 
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-test
namespace: default
spec:
capacity:
storage: 5Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Recycle
storageClassName: slow
nfs:
path: /kube_pv
server: 10.24.2.125

创建pvc

[root@master pvc]# cat pvc.ymal 
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: myclaim
labels:
song: lele
spec:
accessModes:
- ReadWriteOnce
volumeMode: Filesystem
volumeName: pv-test
resources:
limits:
storage: 2Gi
requests:
storage: 2Gi
storageClassName: slow
selector:
matchLabels:
release: "stable"
matchExpressions:
- {key: environment, operator: In, values: [dev]}

configMap 一个特殊的数据卷,用来管理你的pod

命令行创建一个configMap
[root@master song]# kubectl create configmap nginx-config --from-literal=nginx_port= --from-literal=server_name=www.slele.com
configmap/nginx-config created
[root@master song]# kubectl get configmaps -o yaml
apiVersion: v1
items:
- apiVersion: v1
data:
nginx_port: ""
server_name: www.slele.com
kind: ConfigMap
metadata:
creationTimestamp: "2019-03-09T05:12:39Z"
name: nginx-config
namespace: default
resourceVersion: ""
selfLink: /api/v1/namespaces/default/configmaps/nginx-config
uid: f5832bc1--11e9-bc53-52540062b2ca
kind: List
metadata:
resourceVersion: ""
selfLink: ""

[root@master song]# kubectl describe configmaps nginx-config
Name: nginx-config
Namespace: default
Labels: <none>
Annotations: <none>


Data
====
nginx_port:
----
80
server_name:
----
www.slele.com
Events: <none>

将文件整体作为一个键值创建一个configmap

[root@master song]# kubectl create configmap nginx-file --from-file=/etc/nginx/nginx.conf
configmap/nginx-file created
[root@master song]# kubectl describe configmaps nginx-file
Name: nginx-file
Namespace: default
Labels: <none>
Annotations: <none> Data
====
nginx.conf:
----
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf; events {
worker_connections 1024;
} http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048; include /etc/nginx/mime.types;
default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf; server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html; # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf; location / {
} error_page 404 /404.html;
location = /40x.html {
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
} # Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# } } Events: <none>

13.kubernetes之pv,pvc,configmap(带补充实例)的更多相关文章

  1. Kubernetes 学习13 kubernetes pv pvc configmap 和secret

    一.概述 1.我们在pvc申请的时候未必就有现成的pv能正好符合这个pvc在申请中指定的条件,毕竟上一次的成功是我们有意设定了有一些满足有一些不满足的前提下我们成功创建了一个pvc并且被pod绑定所使 ...

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

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

  3. kubernetes Value:将磁盘挂载到容器,PV,PVC

    6.1.介绍卷 6.1.1.卷的类型 emptyDir-用于存储临时数据的简单空目录 hostPath-用于将目录从工作节点的文件系统挂载到pod nfs-挂载到pod中的NFS共享卷. 还有其他的如 ...

  4. Kubernetes 存储卷管理 PV&PVC(十)

    目录 一.emptyDir 二.hostPath 三.PV & PVC 1.NFS PersistentVolume 2.创建 PVC 3.创建 Pod 进行挂载 为了持久化保存容器的数据,可 ...

  5. 09 . Kubernetes之pv、pvc及使用nfs网络存储应用

    PV,PVC概述 PV的全称是: PersistentVolume (持久化卷),是对底层的共享存储的一种抽象,PV由管理员进行创建和配置,它和具体的底层的共享存储技术的实现方式有关,比如Ceph.G ...

  6. Kubernetes Pv & Pvc

    Kubernetes PV & pvc 介绍 PersistentVolume(pv)和PersistentVolumeClaim(pvc)是k8s提供的两种API资源,用于抽象存储细节.管理 ...

  7. Serverless Kubernetes全面升级2.0架构:支持多命名空间、RBAC、CRD、PV/PVC等功能

    Serverless Kubernetes概述: 阿里云Serverless Kubernetes容器服务最新开放香港.新加坡.悉尼区域,同时全面开放2.0架构,帮助用户更加便捷.轻松地步入“以应用为 ...

  8. Kubernetes PV/PVC使用实践

    转载于https://www.cnblogs.com/ericnie/p/7733281.html   pv,pvc的概念不解释了,之前在registry中已经使用过PV和PVC,现在想把WebLog ...

  9. K8S系列第九篇(持久化存储,emptyDir、hostPath、PV/PVC)

    更多k8s内容,请关注威信公众好:新猿技术生态圈 一.数据持久化 Pod是由容器组成的,而容器宕机或停止之后,数据就随之丢了,那么这也就意味着我们在做Kubernetes集群的时候就不得不考虑存储的问 ...

随机推荐

  1. 深入理解 Node.js 中 EventEmitter源码分析(3.0.0版本)

    events模块对外提供了一个 EventEmitter 对象,即:events.EventEmitter. EventEmitter 是NodeJS的核心模块events中的类,用于对NodeJS中 ...

  2. Python排序算法——快速排序

    有趣的事,Python永远不会缺席! 如需转发,请注明出处:小婷儿的python https://www.cnblogs.com/xxtalhr/p/10768593.html 排序算法(Sortin ...

  3. C# System.Guid.NewGuid() 格式化

    概念 GUID: 即Globally Unique Identifier(全球唯一标识符) 也称作 UUID(Universally Unique IDentifier) . GUID是一个通过特定算 ...

  4. Makefile有三个非常有用的变量。分别是$@,$^,$

    原文地址:https://blog.csdn.net/u013774102/article/details/79043559 假设我们有下面这样的一个程序,源代码如下: /* main.c */ #i ...

  5. B. School Marks(典型贪心)

    链接 [https://codeforces.com/contest/540/problem/B] 题意 某个人有n门成绩,k门已知,剩下的他可以个瞎改,但有个要求,最后分数和不超过x,且每门成绩不超 ...

  6. Mysql数据库触发器调用脚本

    一.数据库触发器 mysql触发器trigger 实例详解 对数据库触发器new和old的理解 示例 二.UDF mySql的UDF是什么 三.安装执行命令UDF mysql触发器调用外部脚本(安装) ...

  7. 容器化 — 基于Docker技术容器云

    导读:本文介绍了基于Docker技术的企业级应用容器平台,从云的定义.云服务分类,到用友云PaaS基础平台.平台总体架构.架构预览.部署架构.平台核心价值和核心竞争力,阐述PaaS基础平台成为广大传统 ...

  8. 现代程序设计 homework-06

    写代码爽还是读代码爽? 当然是写代码爽好吧... 读代码明显是读+写两倍的工作量好么... 本次作业要求: 1) 把程序编译通过, 跑起来. 读懂程序,在你觉得比较难懂的地方加上一些注释,这样大家就能 ...

  9. 设置永久环境变量linux

    ========================================================================== http://www.cnblogs.com/Bi ...

  10. yolo buffer is too small for requested array

    yolo.cfg 与 yolo.weights 版本一定要对应, darknet链接 https://github.com/pjreddie/darknet 下载后在cfg文件夹下找到yolov2的配 ...