Rancher二次开发指南
依赖环境
安装最新版的yarn, nodejs(8.x+ with NPM)
获取UI 项目
可使用我们提供的开发包Demo,也可以使用公网的Rancher-UI项目https://github.com/rancher/ui
架构分析
主要技术栈
基础web框架: Ember.js
构建脚手架: Ember CLI
ember-engines: http://ember-engines.com/
国际化: 读配置文件
打包工具: WebPack
dom操作: jquery
Nodejs框架: express生态+http-proxy
图表使用的: echarts 和 d3
样式: node-sass
没有使用大的组件库,只是使用了一些小插件如 jquery.jgrowl
命令执行使用的: xterm.js
模板引擎: hbs
网络层数据流转
本地开发时,接口请求的都是本地的,使用http-proxy 做代理
在server/proxies/api.js 里 可以看到
更新依赖
开发环境运行
生产环境布署
Build with ./scripts/build-static -l -c 'your-server.com'
Upload ./dist/static/latest2 so that it’s available at https://your-server.com/latest2
It must be available over HTTPS.
You can rename the “latest2” part with the -v flag
Change the value of http[s]://your-rancher:8080/v3/settings/ui-index to the same https://yourserver.com/latest2 URL
Known bugs
二次开发实例
后端api修改前端地址
登录rancher 后 访问
打开你rancher服务器的 /v3/settings/ui-index接口,
如https://rancher服务器/v3/settings/ui-index
并且修改 并将前端访问地址 填入value输入框 并保存上传即可
rancher自定义客户端开发实例
使用三方库gogf的net/ghttp模块,gogf地址:https://github.com/gogf/gf
编写客户端例子,调用gogf中的net/ghttp中的post函数来进行请求,post函数中传入的是网址和请求的json串,然后根据请求后的response获取请求后的数据
根据返回数据进行下一步的操作