您的位置:首页 > 其它

k8s数据持久化实验

2019-08-03 00:35 459 查看
原文链接:http://www.cnblogs.com/networking/p/11158639.html

Step 1:创建PV

============================================

apiVersion: v1
kind: PersistentVolume
metadata:
name: web
spec:
capacity:
storage: 50Gi
accessModes:
- ReadWriteMany
nfs:
path: /data
server: 192.168.188.110

Step 2:创建PVC

============================================

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: httpd
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi

Step 3:创建POD

============================================

[root@k8s-master yaml]# vi deployment.yaml 

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: httpd
spec:
template:
metadata:
labels:
app: httpd
spec:
containers:
- name: httpd
image: httpd
ports:
- name: httpd
containerPort: 80
volumeMounts:
- name: httpd
mountPath: /usr/local/apache2/htdocs
volumes:
- name: httpd-nfs
nfs:
server: 192.168.188.110
path: /data
- name: httpd
persistentVolumeClaim:
claimName: httpd

Step 4:泄漏服务IP

============================================

kubectl expose deployment httpd --port=80 --target-port=80 --external-ip=192.168.188.120

Step 5:访问测试

============================================

在外网进行访问

 

 

转载于:https://www.cnblogs.com/networking/p/11158639.html

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: