kubernetes 数据持久化之Glusterfs
1、GlusterFS 部署过程请参考上篇文章
2、配置endpoints
[root@manager ~]# cat glusterfs-endpoints.json
{
"kind": "Endpoints",
"apiVersion": "v1",
"metadata": {
"name": "glusterfs-cluster"
},
"subsets": [
{
"addresses": [
{
"ip": "192.168.10.223"
}
],
"ports": [
{
"port":
}
]
},
{
"addresses": [
{
"ip": "192.168.10.224"
}
],
"ports": [
{
"port":
}
]
},
{
"addresses": [
{
"ip": "192.168.10.225"
}
],
"ports": [
{
"port":
}
]
}
]
}
[root@manager ~]# kubectl create -f glusterfs-endpoints.json
endpoints "glusterfs-cluster" created
[root@manager ~]#
[root@manager ~]# kubectl get ep
NAME ENDPOINTS AGE
glusterfs-cluster 192.168.10.223:1,192.168.10.224:1,192.168.10.225:1 6s
kubernetes 192.168.10.220:6443 5d

3、创建service
[root@manager ~]# cat glusterfs-service.yaml
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "glusterfs-cluster"
},
"spec": {
"ports": [
{"port": }
]
}
}
[root@manager ~]#
[root@manager ~]#
[root@manager ~]# kubectl create -f glusterfs-service.yaml
service "glusterfs-cluster" created
[root@manager ~]#
[root@manager ~]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
glusterfs-cluster ClusterIP 10.10.10.194 <none> /TCP 7s
kubernetes ClusterIP 10.10.10.1 <none> /TCP 5d

4、创建测试pod
[root@manager ~]# cat glusterfs-pod.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas:
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
volumeMounts:
- name: glusterfsvol
mountPath: /usr/share/nginx/html
ports:
- containerPort:
volumes:
- name: glusterfsvol
glusterfs:
endpoints: glusterfs-cluster
path: gv0
readOnly: false --- apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
- name: http
port:
protocol: TCP
targetPort:
type: NodePort
[root@manager ~]# kubectl create -f glusterfs-pod.yaml
deployment "nginx-deployment" created
service "nginx-service" created
[root@manager ~]# kubectl describe pod nginx-deployment-6f6f9646c4-84bbr
Name: nginx-deployment-6f6f9646c4-84bbr
Namespace: default
Node: 192.168.10.221/192.168.10.221
Start Time: Mon, 05 Feb 2018 14:31:54 +0800
Labels: app=nginx
pod-template-hash=2929520270
Annotations: kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicaSet","namespace":"default","name":"nginx-deployment-6f6f9646c4","uid":"41758808-0a3e-11e8-af8c-5254...
Status: Running
IP: 10.0.91.5
Created By: ReplicaSet/nginx-deployment-6f6f9646c4
Controlled By: ReplicaSet/nginx-deployment-6f6f9646c4
Containers:
nginx:
Container ID: docker://d7714c067d2c1ac115336715eb66235ee9153632eab2019c174b0384c0b04e8f
Image: nginx
Image ID: docker-pullable://nginx@sha256:285b49d42c703fdf257d1e2422765c4ba9d3e37768d6ea83d7fe2043dad6e63d
Port: 80/TCP
State: Running
Started: Mon, 05 Feb 2018 14:32:34 +0800
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/usr/share/nginx/html from glusterfsvol (rw)
Conditions:
Type Status
Initialized True
Ready True
PodScheduled True
Volumes:
glusterfsvol:
Type: Glusterfs (a Glusterfs mount on the host that shares a pod's lifetime)
EndpointsName: glusterfs-cluster
Path: gv0
ReadOnly: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 42s default-scheduler Successfully assigned nginx-deployment-6f6f9646c4-84bbr to 192.168.10.221
Normal SuccessfulMountVolume 41s kubelet, 192.168.10.221 MountVolume.SetUp succeeded for volume "glusterfsvol"
Normal Pulling 40s kubelet, 192.168.10.221 pulling image "nginx"
Normal Pulled 2s kubelet, 192.168.10.221 Successfully pulled image "nginx"
Normal Created 2s kubelet, 192.168.10.221 Created container
Normal Started 2s kubelet, 192.168.10.221 Started container
[root@manager ~]# kubectl exec nginx-deployment-6f6f9646c4-84bbr mount|grep gluster
192.168.10.223:gv0 on /usr/share/nginx/html type fuse.glusterfs (rw,relatime,user_id=0,group_id=0,default_permissions,allow_other,max_read=131072)



root@nginx-deployment-6f6f9646c4-84bbr:/usr/share/nginx/html# echo abc > 2.txt
[root@glusterfs1 brick1]# cat 2.txt
abc
[root@glusterfs1 brick1]# echo 33333 > 3.txt

5、注意事项:
5.1、k8s集群配置glusterfs集群主机名接卸

5.2、k8s集群配置glusterfs 客户端挂载工具
[root@node1 ~]# yum install centos-release-gluster -y
[root@node1 ~]# yum install glusterfs-fuse -y
kubernetes 数据持久化之Glusterfs的更多相关文章
- K8S学习笔记之Kubernetes数据持久化方案
在开始介绍k8s持久化存储前,我们有必要了解一下k8s的emptydir和hostpath.configmap以及secret的机制和用途. 0x00 Emptydir EmptyDir是一个空目录, ...
- kubernetes 数据持久化
pod本身是无状态,所以很多有状态的应用,就需要将数据进行持久化. 1:将数据挂在到宿主机.但是pod重启之后有可能到另外一个节点,这样数据虽然不会丢但是还是有可能会找不到 apiVersion: v ...
- kubernetes的应用数据持久化
1.无状态应用与有状态应用 应用的有状态和无状态是根据应用是否有持久化保存数据的需求而言的,即持久化保存数据的应用为有状态的应用,反之则为无状态的应用.常见的系统往往是有状态的应用,比如对于微博和微信 ...
- openshift 容器云从入门到崩溃之七《数据持久化》
数据持久化常用的有两种: hostPath 挂载容器宿主机的本地文件夹,直接修改pod的配置 volumes: - hostPath: path: /data/logging-es type: '' ...
- Kubernetes 学习(十)Kubernetes 容器持久化存储
0. 前言 最近在学习张磊老师的 深入剖析Kubernetes 系列课程,最近学到了 Kubernetes 容器持久化存储部分 现对这一部分的相关学习和体会做一下整理,内容参考 深入剖析Kuberne ...
- k8s集群,使用pvc方式实现数据持久化存储
环境: 系统 华为openEulerOS(CentOS7) k8s版本 1.17.3 master 192.168.1.244 node1 192.168.1.245 介绍: 在Kubernetes中 ...
- k8s部署mysql数据持久化
在这里我部署mysql的目的是为了后面将上一篇博客docker打包的el-admin镜像部署到k8s上,所以本文主要是部署mysql并实现持久化. 1.将我们的应用都部署到 el-admin 这个命名 ...
- Redis学习总结(1)——数据持久化
以前研究Redis的时候,很多东西都不太明白,理解得也不太深,现在有时间重新拾起来看看,将一些心得记录下来,希望和大家一起探讨. 一.简介 Redis是一个单线程高可用的Key-Value存储系统,和 ...
- iOS之数据持久化方案
概论 所谓的持久化,就是将数据保存到硬盘中,使得在应用程序或机器重启后可以继续访问之前保存的数据.在iOS开发中,有很多数据持久化的方案,接下来我将尝试着介绍一下5种方案: plist文件(属性列表) ...
随机推荐
- 垂直居中一个img
{ display:table-cell; text-align:center; vertical-align:middle; }
- A1043 Is It a Binary Search Tree (25 分)
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following propertie ...
- 爬虫学习(九)——登录获取cookie爬取
import urllib.requestimport urllib.parseimport http.cookiejar # http.cookiejar 该包是专门对网页的cookie只进行获取的 ...
- 【原创】数据处理中判断空值的方法(np.isnan、is np.nan和pd.isna)比较
转载请注明出处:https://www.cnblogs.com/oceanicstar/p/10869725.html 1.np.isnan(只有数组数值运算时可使用) 注意:numpy模块的i ...
- git bush的一些基础命令
git bush的一些基础命令(不区分大小写) 通过命令创建本地仓库 首先自己需要手动建一个文件夹用于本地仓库 进行如下输入,使用cd跳转到刚刚创建的文件夹中 之后再输入 git init 即可创建 ...
- js禁止微信浏览器下拉显示黑底查看网址
// 首先禁止body document.body.ontouchmove = function (e) { e.preventDefault(); }; // 然后取得触摸点的坐标 var star ...
- 15.VUE学习之-表单中使用key唯一令牌解决表单值混乱问题
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...
- SpringBoot-Security-用户权限分配-项目搭建
SpringBoot原则是约定优于配置,简化spring应用开发,去繁从简,产品级别的应用. SpringBoot有哪些优点1.快速创建独立运行的spring项目与主流框架集成 2.使用嵌入式的ser ...
- web开发框架Flask学习二
jinja2模板规范 在当前项目中创建一个文件为templates的文件夹,将其设置为模板文件夹,新建的html为模板页面, 在视图函数中使用render_template(".html的文 ...
- python-PIL模块的使用
PIL基本功能介绍 from PIL import Image from PIL import ImageEnhance img = Image.open(r'E:\img\f1.png') img. ...