概述
Openshift的主要代码库是origin,它包含除了前端以外的所有东西,origin-web-console是前端的代码库,origin-web-catalog和origin-web-common是前端代码库的依赖库,origin-web-console-server是前端和origin交互的的代码库。
上一篇文章介绍了origin的二次开发流程,本文介绍在本地如何对origin-web-console3.9作二次开发,其他版本没有亲测,操作上可能会有一些区别。本地操作系统为Mac,若你是其他操作系统请做对应转换。
正文
安装 Nodejs 和 npm
安装 grunt-cli 和 bower
npm install -g grunt-cli bower
安装web-console的依赖包
cd origin-web-console
hack/install-deps.sh
启动web-console简单测试下
grunt serve
在浏览器打开https://localhost:9000/可以看到loading界面
修改代码,比如
origin-web-console/app/views/browse/secret.html
编译代码,变化在dist/目录下
grunt build
启动集群,测试代码修改是否成功
cd origin
export PATH="$( source hack/lib/init.sh; echo "${OS_OUTPUT_BINPATH}/$( os::build::host_platform )/" ):${PATH}"
oc cluster up --version="xxx"
grunt serve
在浏览器打开https://localhost:9000/,用户名输入developer, 密码随意
测试成功后停止集群
oc cluster down
把origin-web-console的前端代码用go-bindata工具生成bindata.go,然后拷贝到origin-web-console-server代码库中替换掉已经存在的
cd origin-web-console-server
hack/vendor-console.sh
生成web-console镜像
cd origin-web-console-server
OS_BUILD_ENV_PRESERVE=_output/local/bin hack/env make build-images
在本地启动集群测试
oc cluster up --version="71543b2"
上传镜像到docker hub
docker tag openshift/origin-web-console:71543b2 YOUR_USER_NAME/origin-web-console:v1.1
docker push YOUR_USER_NAME/origin-web-console:v1.1
打开浏览器进入web-console界面,进入openshift-web-console项目,进入application—>deployment—>action–→edit yaml,
把
image: 'docker.io/openshift/origin-web-console:v3.9.0
改成:
image: 'docker.io/YOUR_USER_NAME/origin-web-console:v1.2'
把
volumes:
- name: serving-cert
secret:
defaultMode: 400
secretName: webconsole-serving-cert
改成:
volumes:
- name: serving-cert
secret:
defaultMode: 440
secretName: webconsole-serving-cert