1. helm部署

本文介绍如何在Kubernetes上通过helm部署HENGSHI SENSE,以及部署后如何进行版本升级和数据备份。

1.1. 部署前准备

  1. 准备helm源
     helm repo add hengshi-charts https://hs-chart-repo.s3.cn-north-1.amazonaws.com.cn/charts/
    
  2. 安装helm s3 插件

     helm plugin install https://github.com/hypnoglow/helm-s3.git
    
  3. 更新helm源

     helm repo update 
     helm search repo hengshi-charts # -l 列出所有版本
    
  4. 导入离线镜像

     wget https://download.hengshi.com/releases/hengshi-sense-xxx.tar.gz
     docker load -i hengshi-sense-xxx.tar.gz
    

1.2. 集群部署

k8s/helm部署默认均为集群模式。

  1. 自定义配置文件

    • 根据license调整衡石实例数
      # 初次部署时 将hengshi副本数置为1. 即下文自定义配置文件参数中的hengshi_replicas: 1
      # 在拿到license文件并导入后,开始扩容pod数量 --replicas= 请与license的实例数限制保持一致
      kubectl -n [namespace] scale deployment/hengshi-sense --replicas=3
      
    • 部署所需要的必要参数

      hengshi_replicas: 3 # hengshi节点数默认3,请根据获取到的license数量限制保持一致
      gpdb_seg_replicas: 3
      gpdb_segments:
       - segment-0
       - segment-1
       - segment-2
      image: # 修改您的镜像tag
       hengshi: "registry.hengshi.org/hengshi-sense:4.0.4-dp-a3d11d"
       gpdb: "registry.hengshi.org/gpdb:6.18.2.0"
       zk: "registry.hengshi.org/google-containers/kubernetes-zookeeper:1.0-3.4.10"
      stroage_name:
       gpdb_master_size: 50Gi
       gpdb_segment_size: 50Gi  
       metadb_size: 50Gi  
       minio_size: 50Gi
       zk_size: 3Gi
       redis_size: 10Gi
       flink_size: 10Gi
       ClassName: longhorn # 修改为您本地的存储类, 云上架构请注意磁盘大小最小限制。 eg. 阿里云ssd磁盘最低20Gi
       accessModes: ['ReadWriteOnce']
      
       # 视情况是否部署ingress
       #ingress:
       #enabled: false
       #className: "nginx"
       #annotations:
       #  ingress.kubernetes.io/force-ssl-redirect: "false"
       #  nginx.ingress.kubernetes.io/proxy-connect-timeout: "600"
       #  nginx.ingress.kubernetes.io/proxy-send-timeout: "600"
       #  nginx.ingress.kubernetes.io/proxy-read-timeout: "600"
       #  nginx.ingress.kubernetes.io/proxy-body-size: "500M"
       #hosts:
       #  - host: helm-cluster.hengshi.org
       #    paths:
       #      - path: /
       #        pathType: Prefix
       #tls: []
       #  - secretName: ttt-hengshi-org-tls
       #    hosts:
       #      - ttt.hengshi.org
      
    • 替换衡石metadb/greenplum或其他组件

      # 以下任一组件将其置为false, 安装后则不会启动
      metadb_enabled: false
      gpdb_enabled: false
      redis_enabled: false
      minio_enabled: false
      flink_enabled: false
      
      # 示例:使用AnalyticDB MySQL替换hengshi内置greenplum引擎
       1. gpdb_enabled 参数在自定义配置文件中将其置为false
       2. 参考 安装与启动 > 系统配置 > 引擎高级配置 中的示例配置添加到 "配置项(configmap)"
       HS_ENGINE_TYPE: "mysql"
       IS_ENGINE_EMBEDDED: false
       SYSTEM_ENGINE_URL: "jdbc:mysql://192.168.211.4:3306/testdb?user=root&password=Test123@"
       INTERNAL_ENGINE_DATASET_PATH: "enginedb"
       INTERNAL_ENGINE_TMP_PATH: "enginetmp"
       INTERNAL_ENGINE_OUTPUT_PATH: "enginecommon"
      
       # 去掉默认的引擎变量
        HS_ENGINE_TYPE: greenplum
        HS_ENGINE_HOST: "master-0.gp-hs"
        HS_ENGINE_PORT: "15432"
        HS_ENGINE_DB: hengshi
        HS_ENGINE_USR: hengshi
        HS_ENGINE_PWD: hengshi202020
      # 示例:使用RDS PostgreSQL替换hengshi内置metadb
        1. metadb_enabled 参数在自定义配置文件中将其置为false                  
        2. 参考 安装与启动 > 系统配置 > 替代衡石metadb 中的示例配置添加到 "配置项(configmap)", 并在云上数据库创建相应的帐号和权限   
        HS_PG_HOST=xxx
        HS_PG_PORT=5432
        HS_PG_DB="hengshi"
        HS_PG_USR=hengshi
        HS_PG_PWD="hengshi"  
        INTERNAL_STORAGE_DB_NAME="hengshi_sense_internal_storage"
        HS_SYSLOG_HOST=xxxx    
        HS_SYSLOG_PORT=5432
        HS_SYSLOG_DB=syslog
        HS_SYSLOG_USR=syslog
        HS_SYSLOG_PWD=syslog
      
  2. 安装Charts

     # 获取当前chart最新版本 -l 参数查看所有版本
     helm search repo hengshi-charts
     NAME                            CHART VERSION    APP VERSION    DESCRIPTION  
     hengshi-charts/hengshi-sense    1.2.2            4.2            HENGSHI SENSE
    
     helm install -f hs-config.yaml hengshi-sense hengshi-charts/hengshi-sense --version [chart_version] -n [namespace] # chart_version 为helm search repo hengshi-charts 列出的可用版本
    
  3. 修改configmap (如需修改帐号密码等自定义配置,请执行此项,否则忽略)
     kubectl edit configmap [configmap_name] -n [namespace] # 可修改的configmap名称: hengshi-sense greenplum metadb
    
    配置内容参考
  4. 初始化engine(已替换hengshi内置引擎 此步可跳过无需初始化)

     kubectl -n [namespace] exec -it master-0 -- /entrypoint.sh -m initsystem
     kubectl -n [namespace] exec -it master-0 -- /entrypoint.sh -m startsystem
    
     # gpdb:6.2.1.1 及以前的版本, 在初始化执行以上命令后还要执行一下命令, 仅初始化执行一次即可.
     kubectl -n hengshi exec -it master-0 -- /bin/bash -c "source ~/.bashrc; /opt/hengshi/bin/engine.sh config"
     kubectl -n hengshi exec -it master-0 -- /bin/bash -c "source ~/.bashrc; psql -c \"ALTER USER \${GREENPLUM_USR} WITH SUPERUSER LOGIN PASSWORD '\${GREENPLUM_PWD}'\""
    

1.3. 单机部署

  1. 自定义配置文件
    • 部署所需要的必要参数
      cluster_enable: false
      image: # 修改您的镜像tag
      hengshi: "registry.hengshi.org/hengshi-sense:4.0.4-dp-a3d11d"
      gpdb: "registry.hengshi.org/gpdb:6.18.2.0"
      stroage_name:
      gpdb_master_size: 50Gi
      gpdb_segment_size: 50Gi
      metadb_size: 50Gi
      minio_size: 50Gi
      redis_size: 10Gi
      flink_size: 10Gi
      ClassName: longhorn # 修改为您本地的存储类
      accessModes: ['ReadWriteOnce']
      
    • 替换衡石metadb/greenplum或其他组件(参考集群部署替换)
      # 以下任一组件将其置为false, 安装后则不会启动
      metadb_enabled: false
      gpdb_enabled: false
      redis_enabled: false
      minio_enabled: false
      flink_enabled: false
      
  2. 安装Charts

     # 获取当前chart最新版本 -l 参数查看所有版本
     helm search repo hengshi-charts
     NAME                            CHART VERSION    APP VERSION    DESCRIPTION  
     hengshi-charts/hengshi-sense    1.2.2            4.2            HENGSHI SENSE
    
     helm install -f hs-config.yaml hengshi-sense hengshi-charts/hengshi-sense --version 1.1.2 -n [namespace] # 使用自定义配置安装一个:"HengshiSense" 的指定版本应用
    
  3. 修改configmap (如需修改帐号密码等自定义配置,请执行此项,否则忽略)
       kubectl edit configmap [configmap_name] -n [namespace] # 可修改的configmap名称: hengshi-sense greenplum metadb
    
    配置内容参考
  4. 初始化engine

       kubectl -n [namespace] exec -it master-0 -- /entrypoint.sh -m initsystem
       kubectl -n [namespace] exec -it master-0 -- /entrypoint.sh -m startsystem
    
       # gpdb:6.2.1.1 及以前的版本, 在初始化执行以上命令后还要执行一下命令, 仅初始化执行一次即可.
       kubectl -n hengshi exec -it master-0 -- /bin/bash -c "source ~/.bashrc; /opt/hengshi/bin/engine.sh config"
       kubectl -n hengshi exec -it master-0 -- /bin/bash -c "source ~/.bashrc; psql -c \"ALTER USER \${GREENPLUM_USR} WITH SUPERUSER LOGIN PASSWORD '\${GREENPLUM_PWD}'\""
    

稍等片刻查看hengshi-sense服务启动完成,即可通过k8s任意节点NODE_IP:PORT访问, 如需自行配置Nginx转发可查看当前Service8080端口暴露的NodePort端口转发即可

kubectl -n [namespace] get svc
NAME            TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)                                                         AGE
hengshi-sense   NodePort    10.0.0.146   <none>        8080:31204/TCP,54320:30524/TCP,15432:31062/TCP,5005:32465/TCP   286d

1.4. 自定义配置文件完整示例

```
cluster_enable: true
hengshi_replicas: 3 # hengshi节点数默认3,请根据获取到的license数量限制保持一致
node_selector:
  ns_enable: false
  node_selector_kv: "diskType: ssd"


# metadb configmap
metadb_enabled: true
metadb_slave_enabled: false

# gpdb configmap
gpdb_enabled: true
gpdb_seg_replicas: 1
gpdb_master: master-0
gpdb_segments: 
  - segment-0
# redis configmap
redis_enabled: true

# minio configmap
minio_enabled: true

# flink configmap
flink_enabled: true

# service
service:
  web_port: 8080
  apm_port: 5005
  other_port: 11111
  metadb_port: 54320
  metadb_slave_port: 54321
  greenplum_port: 15432
  minio_port: 9001
  flink_rest_port: 8082
  flink_job_rpc_port: 6123

# storage
stroage_name:
  gpdb_master_size: 50Gi
  gpdb_segment_size: 50Gi
  metadb_size: 50Gi
  metadb_slave_size: 50Gi
  minio_size: 50Gi
  zk_size: 3Gi
  redis_size: 10Gi
  flink_size: 10Gi
  ClassName: longhorn
  accessModes: ['ReadWriteOnce']

# image
image:
  hengshi: "registry.hengshi.org/hengshi-sense:4.0.4-dp-a3d11d"
  pullPolicy: Always
  dnsPolicy: ClusterFirst
  # Overrides the image tag whose default is the chart appVersion.
  gpdb: "registry.hengshi.org/gpdb:6.18.2.0"
  zk: "registry.hengshi.org/google-containers/kubernetes-zookeeper:1.0-3.4.10"
  secret: false
  secret_name: secret-name

# ingress 默认未启用
ingress:
  enabled: false
  className: "nginx"
  annotations:
    ingress.kubernetes.io/force-ssl-redirect: "false"
    nginx.ingress.kubernetes.io/proxy-connect-timeout: "600"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "600"
    nginx.ingress.kubernetes.io/proxy-read-timeout: "600"
    nginx.ingress.kubernetes.io/proxy-body-size: "500M"
  hosts:
    - host: helm.hengshi.org
      paths:
        - path: /
          pathType: Prefix
  tls: []
  #  - secretName: hengshi-org-tls
  #    hosts:
  #      - helm.hengshi.org


# 建议保持奇数
zk_replicas: 3
zk_single_node: false
zk_resources:
  requests:
    memory: "512M"
    cpu: "0.5"
```

1.5. 升级/备份

  1. 容器部署升级

  2. k8s环境备份与恢复

results matching ""

    No results matching ""

    k8s部署 离线环境依赖包安装