场景
由于公司在做Tob项目,s3对象存储的部署工作变得频繁,部署及后期运维都给运维同学带来一定压力。将s3容器化对于运维同学必然是福音。如果用的爽,之后idc内s3肯定也会走容器化道路。为了快速跑起来,一期s3容器化完全使用的k8s原有资源对象,二期会搞个s3-operator。
公司自研s3架构
- 负载均衡用的公司4层LB,目前ToB使用nodeport方式
- s3 Gateway 是公司根据aws s3 协议自研的
- metadate 存储用的pika
- data 存储用的公司自研的NebulasStore
![](https://img.haomeiwen.com/i14774548/1cb212047bc41965.png)
NebulasStore 架构
- Nebulas master server (负责元数据存储,任务调度,集群管理,内部使用raft强一致性算法进行数据同步及选主)
-
Nebulas Volume server (数据存储)
NebulasStore 架构
容器化部署
- s3 Gateway 对外提供s3接口;与master server通讯获取集群拓扑关系,将对象元数据存到pika。是无状态的,使用deployment部署,弹性扩缩容, nodeport对外暴露服务;
- Nebulas master server 类似于etcd的部署方式,需要知道集群的拓扑关系,也就是通过哪些节点加入到当前集群。第一期的部署方式是一个节点一个deployment的方式。
- Nebulas Volume server :
关键点:
- 使用statefulset部署,主要目的是使用其为每个pod提供一个pvc的能里
- 持久化使用的local pv storage,使用社区的sig-storage-local-static-provisioner来动态创建pv,这样扩容时运维人员只需要将盘挂载到物理机我们预定好的位置。然后更改statefulset 的副本数,扩容就完成了。
- Nebulas Volume server需要给Nebulas master server 发送心跳,上报自己的状态,所以pod启动时需要上报自己的ip。这里我们做法是,使用initContainer 动态修改配置文件,将configmap挂载到initContainer 容器中,动态修改ip,修改故障域级别标识(宿主机ip)。然后通过emptyDir共享给主容器。
- 下面给出Nebulas Volume server 的关键配置
configmap:
[root@rg1-ceph101 /home/zhangzhifei/s3/nebulasfs-volume]# cat nebulasfs-volume-conf.yaml
apiVersion: v1
data:
config: |
# ip address to bind to
ip.bind: 0.0.0.0
# admin port for internal transport
adminPort: 9001
ip: exposeIp # initContainer 动态将exposeIp pod ip 用于之后向master上报自己的ip
# http listen port for user requests
port: 8001
# the master address
mserver: 10.205.52.118:9666
# directories to store volumes, [dir1,dir2...]
dir: [/data/nebulasfs/]
# maximum numbers of volumes, [count1,count2...]
max: [256]
# current volume server's data center name
dataCenter:
# current volume server's rack name
rack:
# current volume server's row name
row: hostIP # initContainer 动态将hostIP 替换为宿主机ip ,作为“机柜级别的故障域”
......
kind: ConfigMap
metadata:
name: nebulasfs-volume-conf
namespace: infra-s3
[root@rg1-ceph101 /home/zhangzhifei/s3/nebulasfs-volume]#
statefulset:
1、将宿主机ip和pod ip打到initContainers中
initContainers:
- env:
- name: SYS_HOST_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.hostIP
- name: SYS_POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
2、通过initContainers动态修改配置文件
image: busybox:latest
command:
- sh
- "-c"
- |
set -ex
# Copy configuration file
if [[ -f "/mnt/conf/volume_server.yaml" ]]; then
cp /mnt/conf/volume_server.yaml /usr/local/s3_data/conf/
fi
# replace ip
sed -i "s/exposeIp/$SYS_POD_IP/g" /usr/local/s3_data/conf/volume_server.yaml
sed -i "s/hostIP/$SYS_HOST_IP/g" /usr/local/s3_data/conf/volume_server.yaml
3、pvc、configmap、emptydir
imagePullSecrets:
- name: regcred
volumes:
- name: nebulasfs-volume-conf
configMap:
defaultMode: 420
items:
- key: config
path: volume_server.yaml
name: nebulasfs-volume-conf
- name: conf
emptyDir: {}
volumeClaimTemplates:
- metadata:
name: nebulasfs-persistent-storage
spec:
accessModes:
- ReadWriteOnce
storageClassName: "local-pv-sc"
resources:
requests:
storage: 600Gi
- 最后sig-storage-local-static-provisioner及storageClass的安装请参考官网sig-storage-local-static-provisioner部署
最后
我们最后肯定会通过写operator来自动化部署s3,一期的目的尽快用起来。我们看到部署方案还是很拖沓的,但这已经让s3的运维同事感觉很自动化、很好用了。
网友评论