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集群的时候就不得不考虑存储的问 ...
随机推荐
- Python脱产8期 Day12 2019/4/26
一 函数默认值的细节 1.如果函数的默认参数的默认值为变量,在所属函数定义阶段一执行就被确定为当时变量存放的值 例: a = 100def fn(num=a): print(num) # 100a = ...
- Java多线程(六)——线程让步
一.yield()介绍 yield()的作用是让步.它能让当前线程由“运行状态”进入到“就绪状态”,从而让其它具有相同优先级的等待线程获取执行权:但是,并不能保证在当前线程调用yield()之后,其它 ...
- Intellij Idea 2017创建web项目及tomcat部署实战
相关软件:Intellij Idea2017.jdk16.tomcat7 Intellij Idea直接安装(可根据需要选择自己设置的安装目录),jdk使用1.6/1.7/1.8都可以,主要是配置好系 ...
- Apache Spark 2.2.0新特性介绍(转载)
这个版本是 Structured Streaming 的一个重要里程碑,因为其终于可以正式在生产环境中使用,实验标签(experimental tag)已经被移除.在流系统中支持对任意状态进行操作:A ...
- Java性能优化之编程技巧总结
程序的性能受代码质量的直接影响.在本文中,主要介绍一些代码编写的小技巧和惯例,这些技巧有助于在代码级别上提升系统性能. 1.慎用异常 在Java软件开发中,经常使用 try-catch 进行错误捕获, ...
- HBase篇(3)-架构详解
[每日五分钟搞定大数据]系列,HBase第三篇 聊完场景和数据模型我们来说下HBase的架构,在网上找了张比较清晰的图,我觉得这张图能说明很多问题,那这一篇我们就重点来解析下这张图 角色与职责 先介绍 ...
- 波音,自动驾驶bug未修复,致346人丧生!5个月内两次坠毁!其中,包括8名中国公民
一,波音737 MAX再次坠毁 继2018年10月29日,印尼波音737MAX飞机坠入爪哇海,导致178名乘客不幸遇难后,时隔不足5月,上周日,埃塞俄比亚航空公司一架波音737MAX客机在飞往肯尼亚途 ...
- 【Python入门只需20分钟】从安装到数据抓取、存储原来这么简单
基于大众对Python的大肆吹捧和赞赏,作为一名Java从业人员,我本着批判与好奇的心态买了本python方面的书<毫无障碍学Python>.仅仅看了书前面一小部分的我......决定做一 ...
- CSS Modules入门教程
为什么引入CSS Modules 或者可以这么说,CSS Modules为我们解决了什么痛点.针对以往我写网页样式的经验,具体来说可以归纳为以下几点: 全局样式冲突 过程是这样的:你现在有两个模块,分 ...
- 十四、怎么获取data-id中的值
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...