k8s下部署数据持久化tomcat
1、部署tomcat对应的yaml文件cat pv.yaml---apiVersion: v1kind: PersistentVolumemetadata:name: tomcat-dataspec:capacity:storage: 5GiaccessModes:- ReadWriteManynfs:path: /app/to...
·
1、部署pv对应的yaml文件
cat pv.yaml
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: tomcat-data
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
nfs:
path: /app/tomcat_data
server: 192.168.1.88
persistentVolumeReclaimPolicy: Recycle
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: tomcat-data
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
2、创建pv
kubectl create -f pv.yaml
3、创建deployment的yaml文件
cat deploy.yml
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: tomcat-dev
spec:
replicas: 1
template:
metadata:
labels:
name: tomcat-dev
spec:
containers:
- name: tomcat-dev
image: tomcat:latest
imagePullPolicy: IfNotPresent
ports:
- name: web
containerPort: 8080
volumeMounts:
- mountPath: /usr/local/tomcat/webapps
name: tomcat-data
volumes:
- name: tomcat-data
persistentVolumeClaim:
claimName: tomcat-data
---
apiVersion: v1
kind: Service
metadata:
name: tomcat-dev
spec:
type: NodePort
ports:
- port: 8080
targetPort: 8080
nodePort: 30001
selector:
name: tomcat-dev
4、创建deploy
kubectl create -f deploy.yml
更多推荐
已为社区贡献45条内容
所有评论(0)