ChaosXu / nerv

A new wheel for build PaaS
Apache License 2.0
5 stars 6 forks source link
paas

Nerv Build Status

概述

神经元为物理机、私有云、公有云、容器及混合云环境提供PaaS服务,支持应用和服务的部署、运维。

user_flow

从源码构建

环境

构建

go get github.com/ChaosXu/nerv

cd $GOPATH/src/github.com/ChaosXu/nerv/cmd/webui/console
console$ npm install

cd $GOPATH/src/github.com/ChaosXu/nerv
nerv$ make build pkg-service pkg-webui pkg-all -e ENV=debug

nerv$ cd release
release$ ls
nerv            nerv.tar.gz

快速启动(单机版)

部署Nerv

在单台主机上部署Nerv

配置数据库

创建一个MySQL数据库 nerv 打开 release/nerv/nerv-cli/config/config.json,配置数据库连接

{
  "db": {
    "user": "root",
    "password": "root",
    "url": "/nerv?charset=utf8&parseTime=True&loc=Local"
  },
  "agent": {
    "port": "3334"
  }
}

安装与启动

部署并启动Nerv的所有服务

#Use the topolgoy to install system
cd release/nerv/nerv-cli/bin
bin$ ./nerv-cli nerv create -t ../../resources/templates/nerv/server_core.json -o nerv -n nerv_inputs.json
Create topology success. id=1

#Install softwares that used by the topology to the host
bin$ ./nerv-cli nerv install -i 1
Install topology success. id=1
#Setup configurations of nodes in the topology
bin$ ./nerv-cli nerv setup -i 1
Setup topology success. id=1
#Start system by the topology
bin$ ./nerv-cli nerv start -i 1
file: started, pid=30992
agent: started, pid=30988
server: started, pid=31038
webui: started, pid=33065
Start topology success. id=1

nerv_inputs.json为模板所需实参

{
  "name": "/nerv/server_core",
  "version": 1,
  "environment": "standalone",
  "inputs": [
    {
      "name": "os",
      "type": "string"
    },
    ...
  ],
  ...
}
{
  "os": "linux-x86_64" //darwin-x86_64 macOS
}

添加工作集群

添加集群并在其中安装Agent,以便后续在集群中部署应用或服务。Nerv不负责部署、启动或者管理其中的主机,它们由基础设施管理平台管理。

#Add credential for worker cluster
bin$ ./nerv-cli credential create -D worker_credential.json

#Add worker cluster
bin$ ./nerv-cli topo create -t ../../resources/templates/nerv/worker.json -o worker-cluster-1 -n worker_inputs.json

#Install agents in hosts of cluster
bin$ ./nerv-cli topo install -i 2
#Start agents in hosts of cluster
bin$ ./nerv-cli topo start -i 2

work_credential.json为工作节点访问凭据,当前仅支持SSH密码登录

{
  "Type": "ssh",      //类型
  "Name": "centos7",  //名称
  "User": "XXXX",
  "Password": "XXXX"
}

worker.json工作节点模板

{
  "name": "/nerv/worker",
  "version": 1,
  "environment": "ssh",
  "inputs": [
    {
      "name": "host_ip_list", //部署节点的主机列表
      "type": "string[]"
    },
    {
      "name": "host_credential",  //主机访问凭据
      "type": "string"
    },
    {
      "name": "os",             //主机系统类型
      "type": "string"
    },
    ...
  ],
  ...
}

worker_inputs.json

{
  "host_ip_list": [
    "XXX",
    "XXX",
    ...
  ],
  "host_credential": "ssh,{凭据名称}",
  "os":"linux-x86_64"
}

部署应用

在集群中部署一个示例应用

工作机制

concept

部署与配置

TBD