13.kubernetes之pv,pvc,configmap(带补充实例)
管理存储是管理计算的一个明显问题。该PersistentVolume
子系统为用户和管理员提供了一个API,用于抽象如何根据消费方式提供存储的详细信息。为此,我们引入了两个新的API资源:PersistentVolume
和PersistentVolumeClaim
。
A 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(带补充实例)的更多相关文章
- Kubernetes 学习13 kubernetes pv pvc configmap 和secret
一.概述 1.我们在pvc申请的时候未必就有现成的pv能正好符合这个pvc在申请中指定的条件,毕竟上一次的成功是我们有意设定了有一些满足有一些不满足的前提下我们成功创建了一个pvc并且被pod绑定所使 ...
- Kubernetes 存储系统 Storage 介绍:PV,PVC,SC
要求:先了解数据docker容器中数据卷的挂载等知识 参考网址: https://www.cnblogs.com/sanduzxcvbnm/p/13176938.html https://www.cn ...
- kubernetes Value:将磁盘挂载到容器,PV,PVC
6.1.介绍卷 6.1.1.卷的类型 emptyDir-用于存储临时数据的简单空目录 hostPath-用于将目录从工作节点的文件系统挂载到pod nfs-挂载到pod中的NFS共享卷. 还有其他的如 ...
- Kubernetes 存储卷管理 PV&PVC(十)
目录 一.emptyDir 二.hostPath 三.PV & PVC 1.NFS PersistentVolume 2.创建 PVC 3.创建 Pod 进行挂载 为了持久化保存容器的数据,可 ...
- 09 . Kubernetes之pv、pvc及使用nfs网络存储应用
PV,PVC概述 PV的全称是: PersistentVolume (持久化卷),是对底层的共享存储的一种抽象,PV由管理员进行创建和配置,它和具体的底层的共享存储技术的实现方式有关,比如Ceph.G ...
- Kubernetes Pv & Pvc
Kubernetes PV & pvc 介绍 PersistentVolume(pv)和PersistentVolumeClaim(pvc)是k8s提供的两种API资源,用于抽象存储细节.管理 ...
- Serverless Kubernetes全面升级2.0架构:支持多命名空间、RBAC、CRD、PV/PVC等功能
Serverless Kubernetes概述: 阿里云Serverless Kubernetes容器服务最新开放香港.新加坡.悉尼区域,同时全面开放2.0架构,帮助用户更加便捷.轻松地步入“以应用为 ...
- Kubernetes PV/PVC使用实践
转载于https://www.cnblogs.com/ericnie/p/7733281.html pv,pvc的概念不解释了,之前在registry中已经使用过PV和PVC,现在想把WebLog ...
- K8S系列第九篇(持久化存储,emptyDir、hostPath、PV/PVC)
更多k8s内容,请关注威信公众好:新猿技术生态圈 一.数据持久化 Pod是由容器组成的,而容器宕机或停止之后,数据就随之丢了,那么这也就意味着我们在做Kubernetes集群的时候就不得不考虑存储的问 ...
随机推荐
- AQS实现原理分析——ReentrantLock
在Java并发包java.util.concurrent中可以看到,不少源码是基于AbstractQueuedSynchronizer(以下简写AQS)这个抽象类,因为它是Java并发包的基础工具类, ...
- Ueditor使用以及遇到的问题
原来用的是Kindeditor这个编辑器,但很久没更新了,最新版是13年更新的.现在要换成百度的Ueditor, 在这里记录Ueditor的使用流程和遇到的问题. 一.下载 1.Ueditor官网 这 ...
- 使用docker Registry快速搭建私有镜像仓库
当我们执行docker pull xxx的时候,docker默认是从registry.docker.com这个地址上去查找我们所需要的镜像文件,然后执行下载操作.这类的镜像仓库就是docker默认的公 ...
- Node.js中读取文件后用Json.parse方法报错解决方案
今天,在调试一个node项目时,发现了一个很大的坑,在此分享给大家! 大家都知道,Json.parse()方法对格式要求是很严格的,格式不对极其容易报错,但是有时候格式看似是正确的也会报错. 比如这一 ...
- easyui datagrid 相关取数据总结
easyui 中datagrid$('#dg').datagrid('getSelected');返回第一个被选中的行或如果没有选中的行则返回null.$('#dg').datagrid('getSe ...
- H5 30-CSS元素的显示模式
30-CSS元素的显示模式 我是div 我是段落 我是标题 我是span 我是加粗 我是强调 <!DOCTYPE html><html lang="en"> ...
- Python—time模块介绍
time 模块 在平常的代码中,我们常常需要与时间打交道.在Python中,常用的与时间处理有关的模块就包括:time,datetime,下面来介绍time模块. 在开始之前,首先要说明几点: 一.在 ...
- 16-使用Selenium模拟浏览器抓取淘宝商品美食信息
淘宝由于含有很多请求参数和加密参数,如果直接分析ajax会非常繁琐,selenium自动化测试工具可以驱动浏览器自动完成一些操作,如模拟点击.输入.下拉等,这样我们只需要关心操作而不需要关心后台发生了 ...
- IOS 开发之-- textfield和textview,return键的改变,点击return键
IOS 开发之-- textfield和textview,return键的改变,点击return键 一,textfield的return键改变 方案1.改变键盘右下角的换行(enter)键为完成键,后 ...
- mysql_单表查询
单表查询 比较符 当在子句中使用 <. >. <=. >=. <>或 !=时,字段的名字不加引号.如果使用引号,则查询出的结果为空,并且不会报错. ; 等号 当在子 ...