基础组件s3容器化

2020-08-07  本文已影响0人  zhangzhifei

场景

由于公司在做Tob项目,s3对象存储的部署工作变得频繁,部署及后期运维都给运维同学带来一定压力。将s3容器化对于运维同学必然是福音。如果用的爽,之后idc内s3肯定也会走容器化道路。为了快速跑起来,一期s3容器化完全使用的k8s原有资源对象,二期会搞个s3-operator。

公司自研s3架构

s3架构

NebulasStore 架构

容器化部署

  1. s3 Gateway 对外提供s3接口;与master server通讯获取集群拓扑关系,将对象元数据存到pika。是无状态的,使用deployment部署,弹性扩缩容, nodeport对外暴露服务;
  2. Nebulas master server 类似于etcd的部署方式,需要知道集群的拓扑关系,也就是通过哪些节点加入到当前集群。第一期的部署方式是一个节点一个deployment的方式。
  3. Nebulas Volume server :
    关键点:
[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

最后

我们最后肯定会通过写operator来自动化部署s3,一期的目的尽快用起来。我们看到部署方案还是很拖沓的,但这已经让s3的运维同事感觉很自动化、很好用了。

上一篇 下一篇

猜你喜欢

热点阅读