所有节点安装nfs

yum install nfs-utils rpcbind -y
mkdir -p /ifs/kubernetes
echo "/ifs/kubernetes 192.168.x.0/24(rw,sync,no_root_squash)" >> /etc/exports 仅在nfs服务器上 systemctl start rpcbind nfs
节点测试没问题即可

可以参考下以前写的:

http://blog.csdn.net/iiiiher/article/details/77865530

安装nfs作为存储

参考:

https://github.com/kubernetes-incubator/external-storage/tree/master/nfs-client/deploy

deployment这是一个nfs的client的,会挂载/ifs/kubernetes, 以后创建的目录,会在这个目录下创建各个子目录.

$ cat deployment.yaml
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
name: nfs-client-provisioner
spec:
replicas: 1
strategy:
type: Recreate
template:
metadata:
labels:
app: nfs-client-provisioner
spec:
containers:
- name: nfs-client-provisioner
image: quay.io/external_storage/nfs-client-provisioner:latest
volumeMounts:
- name: nfs-client-root
mountPath: /persistentvolumes
env:
- name: PROVISIONER_NAME
value: fuseim.pri/ifs
- name: NFS_SERVER
value: 192.168.x.135
- name: NFS_PATH
value: /ifs/kubernetes
volumes:
- name: nfs-client-root
nfs:
server: 192.168.x.135
path: /ifs/kubernetes
$ cat class.yaml
apiVersion: storage.k8s.io/v1beta1
kind: StorageClass
metadata:
name: managed-nfs-storage
provisioner: fuseim.pri/ifs # or choose another name, must match deployment's env PROVISIONER_NAME'
$ cat test-claim.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: test-claim
annotations:
volume.beta.kubernetes.io/storage-class: "managed-nfs-storage"
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Mi
$ cat test-pod.yaml
kind: Pod
apiVersion: v1
metadata:
name: test-pod
spec:
containers:
- name: test-pod
image: busybox
command:
- "/bin/sh"
args:
- "-c"
- "touch /mnt/SUCCESS && exit 0 || exit 1"
volumeMounts:
- name: nfs-pvc
mountPath: "/mnt"
restartPolicy: "Never"
volumes:
- name: nfs-pvc
persistentVolumeClaim:
claimName: test-claim



默认情况创建pvc,pv自动创建. pvc手动干掉后,nfs里面是archive状态.还没弄清楚在哪控制这东西

todo:

验证pvc的:

容量

读写

回收策略

实现下共享存储(左半部分)

$ cat nginx-pvc.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: nginx-claim
annotations:
volume.beta.kubernetes.io/storage-class: "managed-nfs-storage"
spec:
accessModes:
- ReadOnlyMany
resources:
requests:
storage: 1Mi
$ cat nginx-deployment.yaml
apiVersion: apps/v1beta1 # for versions before 1.8.0 use apps/v1beta1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
volumeMounts:
- name: nfs-pvc
mountPath: "/usr/share/nginx/html"
volumes:
- name: nfs-pvc
persistentVolumeClaim:
claimName: nginx-claim
$ cat nginx-svc.yaml
kind: Service
apiVersion: v1
metadata:
name: svc-nginx
spec:
selector:
app: nginx
type: NodePort
ports:
- protocol: TCP
targetPort: 80

右半部分参考

https://feisky.gitbooks.io/kubernetes/concepts/statefulset.html

todo:

我想验证左边模式ReadWriteOnce情况怎么破.

---
apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
app: nginx
spec:
ports:
- port: 80
name: web
clusterIP: None
selector:
app: nginx
---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: web
spec:
serviceName: "nginx"
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
name: web
volumeMounts:
- name: www
mountPath: /usr/share/nginx/html
volumeClaimTemplates:
- metadata:
name: www
annotations:
volume.beta.kubernetes.io/storage-class: "managed-nfs-storage"
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Mi

pvc通过storageClassName调用nfs存储(strorageclass)

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: spring-pvc
namespace: kube-public
spec:
storageClassName: "managed-nfs-storage"
accessModes:
- ReadOnlyMany
resources:
requests:
storage: 100Mi

gfs参考:

https://github.com/kubernetes-incubator/external-storage/tree/master/gluster/glusterfs

pv读写模式(1.9)

参考

ReadWriteOnce / ReadOnlyMany / ReadWriteMany

)

[k8s]k8s配置nfs做后端存储&配置多nginx共享存储&&statefulset配置的更多相关文章

  1. [k8s]k8s内容索引

    我会陆陆续续小结下. dns相关 dns策略 1.集群内 2.指定内网 subdomain 3.访问互联网 resovel.conf kube-dns架构图解及策略 nginx-ingress: DN ...

  2. 转: ubuntu配置NFS,挂载开发板

    ====================================== 命令: 1. $sudo apt-get install nfs-kernel-server           (安装N ...

  3. NFS共享存储服务部署

    第1章 NFS介绍 1.1 NFS基本概述 NFS(Network File System)网络文件系统 主要功能是通过局域网络让不同的主机系统之间可以共享文件或目录. NFS系统和Windows网络 ...

  4. Linux架构之NFS共享存储1

    第35章 NFS共享存储 35.1 NFS基本概述 NFS是Network File System的缩写及网络文件系统.NFS主要功能是通过局域网络让不同的主机系统之间可以共享文件或目录. 常见的文件 ...

  5. 二十五 存储技术与应用 iSCSI技术应用 、 udev配置 NFS网络文件系统 、 Multipath多路径 、 NFS网络文件系统 、 udev配置

    1.配置iSCSI服务 服务器上要额外配置一块硬盘 服务端(proxy)安装target,并将新加的硬盘配置为iSCSI 的共享磁盘 在客户端(client)上安装initiator,挂载服务器iSC ...

  6. k8s 使用nfs做provisioner

    官方的nfs provisoner,serviceAccount RABC相关 请在这里下载https://raw.githubusercontent.com/kubernetes-incubator ...

  7. Linux之nginx反向代理+三台web+nfs共享存储实现集群配置

    作业四:nginx反向代理+三台web+nfs共享存储实现集群配置 在各个web服务器上挂载nfs [root@localhost nginx]# mount -t nfs 192.168.152.1 ...

  8. k8s入坑之路(15)kubernetes共享存储与StatefulSet有状态

    共享存储 docker默认是无状态,当有状态服务时需要用到共享存储 为什么需要共享存储: 1.最常见有状态服务,本地存储有些程序会把文件保存在服务器目录中,如果容器重新启停则会丢失. 2.如果使用vo ...

  9. Openstack使用NFS作为后端存储

    续:Openstack块存储cinder安装配置 接上使用ISCSI作为后端存储,使用NFS作为后端存储配置 参考官方文档:https://wiki.openstack.org/wiki/How_to ...

随机推荐

  1. unity 之 no cameras rendering

    相机被隐藏或删除了 应该是你的代码摧毁了全部的东西,包括摄像机,所以就会提示你没有摄像机了. 或者说你将  OnClose(); 这段代码的脚本赋给了摄像机

  2. phpunit

    教程及文档: https://www.jianshu.com/p/abcca5aa3ad6 http://www.phpunit.cn/manual/current/zh_cn/phpunit-boo ...

  3. python获取公网ip,本地ip及所在国家城市等相关信息收藏

    python获取公网ip的几种方式       from urllib2 import urlopen   my_ip = urlopen('http://ip.42.pl/raw').read() ...

  4. Android系统下用js自定义gesture事件(仿ios实现移动端事件一致)

    .katex { display: inline-block; text-align: initial; } .katex { font-family: Consolas, Inconsolata, ...

  5. 阿里云服务器配置免费https服务

    过程总述 购买服务器,购买域名,备案 申请ssl证书 DNS验证 上传证书,配置nginx 很关键,打开端口!!!阿里云的443端口默认是不打开的 1.购买服务器,域名,备案 服务器我是买的阿里云的, ...

  6. (python数据分析)第03章 Python的数据结构、函数和文件

    本章讨论Python的内置功能,这些功能本书会用到很多.虽然扩展库,比如pandas和Numpy,使处理大数据集很方便,但它们是和Python的内置数据处理工具一同使用的. 我们会从Python最基础 ...

  7. 深入一下Django的用户认证和cache

    深入一下Django的用户认证和cache 用户认证 首先明白一个概念,http协议是无状态的,也就是每一次交互都是独立的,那如何让服务器和客户端进行有状态的交互呢,现在较为常见的方法就是让客户端在发 ...

  8. C++学习笔记41:进程调度

    进程调度策略:先进先出,时间片轮转,普通调度,批调度,高优先级抢先 子进程与父进程的调度没有固定的顺序:不能假设子进程一定会在父进程之后执行,也不能假设子进程一定会在父进程之前执行: 僵尸进程 子进程 ...

  9. VirtualBox 扩展包卸载或安装失败(VERR_ALREADY_EXISTS)(转)

    文章出处:http://blog.csdn.net/leshami/article/details/9232229 最近在卸载VirtualBox出现了无法卸载的错误.提示为Failed to ins ...

  10. strip_tags、htmlentities、htmlspecialchars的区别

    一.strip_tags() 函数剥去字符串中的 HTML.XML 以及 PHP 的标签. strip_tags(string,allow) 注释:可通过allow设置允许的标签.这些标签不会被删除. ...