Kubernetes PV/PVC使用实践
转载于https://www.cnblogs.com/ericnie/p/7733281.html
pv,pvc的概念不解释了,之前在registry中已经使用过PV和PVC,现在想把WebLogic Server中的日志给放到外部的存储中来,过程如下:
首先在需要放日志的目标节点上建立一个文件夹,比如/k8s/weblogic
在/etc/exports中加入一个nfs的mount点
[root@k8s-node-1 weblogic]# cat /etc/exports
/k8s/test *(insecure,rw,async,no_root_squash)
/k8s/weblogic *(insecure,rw,async,no_root_squash)
重新启动nfs
service nfs restart
nfs是否成功,可以通过下面命令来进行验证。
mount -t nfs -o rw 192.168.0.103:/k8s/weblogic /mnt/nfs
建立一个pv

[root@k8s-master pv]# cat pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv0003
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Recycle
nfs:
path: /k8s/weblogic
server: 192.168.0.103

再建立一个pvc

[root@k8s-master pv]# cat pvc.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: weblogiclogs
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi

通过get pv查看是否关联上

[root@k8s-master pv]# kubectl get pv
NAME CAPACITY ACCESSMODES RECLAIMPOLICY STATUS CLAIM REASON AGE
pv0003 5Gi RWO Recycle Bound default/weblogiclogs 41m
pv01 20Gi RWX Recycle Bound default/myclaim2 36d

这里遇到一个问题,开始建立的pv死活claim为空,查看pv以及pvc的配置发现并没有任何名称上的关联,继续研究,发现纯粹是通过storage大小进行匹配的,之前因为照抄书本,一个是5G,一个是8G所以就无法匹配了,修改后成功。
最后是weblogic的rc的配置。

[root@k8s-master pv]# cat rc.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: helloworld-service
spec:
replicas: 1
template:
metadata:
labels:
weblogic-app: "helloworld"
version: "0.1"
spec:
containers:
- name: weblogichelloworld
image: 1213-helloworld:v1
volumeMounts:
- mountPath: "/u01/oracle/user_projects/domains/base_domain/servers/AdminServer/logs"
name: mypd
ports:
- containerPort: 7001
volumes:
- name: mypd
persistentVolumeClaim:
claimName: weblogiclogs
---
apiVersion: v1
kind: Service
metadata:
name: helloworldsvc
labels:
weblogic-app: helloworld
spec:
type: NodePort
ports:
- port: 7001
protocol: TCP
targetPort: 7001
name: http
nodePort: 30005
selector:
weblogic-app: helloworld

这里又遇到一个问题,之前想法是把Servers/AdminServer下面所有的都放在pv中,后来发现pod死活不启动。修改成最后log的路径后,启动成功。
随后我们也在pv中看到满屏的日志了。


==========================================================================
值得探讨的是,这种PV/PVC模式并不是存放WebLogic日志的好的方式,因为如果RC扩展为多个WebLogic Pod,意味着多个AdminServer都需要去访问和读写同一个目录和同一个文件,因为他们都是AdminServer,所以必然造成文件的损坏,所以以上只是做一个验证,日志的收集还是通过官方推荐的EFK方式比较合适,一方面能够记录应用日志,另一方面也可以记录Pod name, 但PV/PVC最适合什么场景,还需要继续探讨。
Kubernetes PV/PVC使用实践的更多相关文章
- Kubernetes Pv & Pvc
Kubernetes PV & pvc 介绍 PersistentVolume(pv)和PersistentVolumeClaim(pvc)是k8s提供的两种API资源,用于抽象存储细节.管理 ...
- [Kubernetes]PV,PVC,StorageClass之间的关系详解
在Kubernetes中,容器化一个应用比较麻烦的地方莫过于对其"状态"的管理,而最常见的"状态",莫过于存储状态. 在[Kubernetes]深入理解Stat ...
- Kubernetes 学习13 kubernetes pv pvc configmap 和secret
一.概述 1.我们在pvc申请的时候未必就有现成的pv能正好符合这个pvc在申请中指定的条件,毕竟上一次的成功是我们有意设定了有一些满足有一些不满足的前提下我们成功创建了一个pvc并且被pod绑定所使 ...
- Kubernetes 存储卷管理 PV&PVC(十)
目录 一.emptyDir 二.hostPath 三.PV & PVC 1.NFS PersistentVolume 2.创建 PVC 3.创建 Pod 进行挂载 为了持久化保存容器的数据,可 ...
- kubernetes Value:将磁盘挂载到容器,PV,PVC
6.1.介绍卷 6.1.1.卷的类型 emptyDir-用于存储临时数据的简单空目录 hostPath-用于将目录从工作节点的文件系统挂载到pod nfs-挂载到pod中的NFS共享卷. 还有其他的如 ...
- Kubernetes PV与PVC的关系
Kubernetes PV与PVC的关系 PersistenVolume(PV):对存储资源创建和使用的抽象,使得存储作为集群中的资源管理,分为有静态与动态.PersistentVolumeClaim ...
- Serverless Kubernetes全面升级2.0架构:支持多命名空间、RBAC、CRD、PV/PVC等功能
Serverless Kubernetes概述: 阿里云Serverless Kubernetes容器服务最新开放香港.新加坡.悉尼区域,同时全面开放2.0架构,帮助用户更加便捷.轻松地步入“以应用为 ...
- Kubernetes 存储系统 Storage 介绍:PV,PVC,SC
要求:先了解数据docker容器中数据卷的挂载等知识 参考网址: https://www.cnblogs.com/sanduzxcvbnm/p/13176938.html https://www.cn ...
- k8s存储 pv pvc ,storageclass
1. pv pvc 现在测试 glusterfs nfs 可读可写, 多个pod绑定到同一个pvc上,可读可写. 2. storageclass 分成两种 (1) 建立pvc, 相当于多个 ...
随机推荐
- PowerDesgner的视图显示设置教程
一.简介 PowerDesgner是一款实用的数据库原型设计软件,但一些新手往往会觉得不好上手,应小伙伴需要,整理了一下PowerDesgner的视图显示设置教程: 首先,PowerDesgner的数 ...
- Scrum立会报告+燃尽图(十二月七日总第三十八次):功能测试
此作业要求参见:https://edu.cnblogs.com/campus/nenu/2018fall/homework/2284 项目地址:https://git.coding.net/zhang ...
- Beta阶段中间产物【欢迎来怼】
一.版本控制 ①Git地址:https://git.coding.net/tianjiping/Android-tianjiping.git ②check in次数:7次. ③成员代码贡献 因为阚博文 ...
- 剑指offer:替换空格
题目描述: 请实现一个函数,将一个字符串中的每个空格替换成“%20”.例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy. 思路: 一开始没理解,函数中 ...
- HDU 4026 Unlock the Cell Phone 状压dp(类似TSP)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4026 Unlock the Cell Phone Time Limit: 6000/3000 MS ...
- 约跑APP测试
项目名:约跑APP 用户需求规格说明书URL:http://www.cnblogs.com/liquan/p/6071804.html 组长博客URL:http://www.cnblogs.com/l ...
- 增加kms计数
@echo offset skms=10.15.68.62for %%i in (. . . . . . . . . . . . . . . . . . . . . . . . . .) do cal ...
- CentOS 6.5以上版本安装mysql 5.7 完整版教程(修订版)
转载自:https://codeday.me/collect/20170524/21861.html 1: 检测系统是否自带安装mysql # yum list installed | grep my ...
- 实现Java中的ArrayList
最近深受轮子哥影响,觉得造一些轮子应该会对自己的技术功底有一定的帮助,就决定先从简单的容器开始实现.废话不多说,就先实现一个Java中的ArrayList. ArrayList是我们在Java中使用非 ...
- 计算机网络【2】—— CSMA/CD协议
参考文献: https://blog.csdn.net/loveCC_orange/article/details/79177129 一.认识以太网 最早的以太网是将许多计算机都连接到一根总线上. 使 ...