From 6d12c8524bc5ab6ad1ad0448aa413af5ee37bbc8 Mon Sep 17 00:00:00 2001 From: 70data <70data@gmail.com> Date: Tue, 14 Jan 2020 23:26:11 +0800 Subject: [PATCH 1/2] update init sql --- src/backend/cmd/apiserver/apiserver.go | 1 + src/backend/cmd/root.go | 5 ++--- src/backend/cmd/worker/worker.go | 2 +- src/backend/database/generatedata/main.go | 1 - src/backend/database/initial/data.go | 6 ++++++ src/backend/database/migrations/v1.1/ddl.sql | 3 +-- src/backend/database/migrations/v1.3/ddl.sql | 2 +- src/backend/initial/bus.go | 1 - src/backend/initial/rsa_key.go | 1 - src/backend/main.go | 1 - 10 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/backend/cmd/apiserver/apiserver.go b/src/backend/cmd/apiserver/apiserver.go index b045a12af..f085ea835 100644 --- a/src/backend/cmd/apiserver/apiserver.go +++ b/src/backend/cmd/apiserver/apiserver.go @@ -1,5 +1,6 @@ package apiserver +//noinspection ALL import ( "github.com/astaxie/beego" "github.com/spf13/cobra" diff --git a/src/backend/cmd/root.go b/src/backend/cmd/root.go index 6ea385f6f..7ddd00b4c 100644 --- a/src/backend/cmd/root.go +++ b/src/backend/cmd/root.go @@ -1,13 +1,13 @@ package cmd import ( + "github.com/astaxie/beego" + "github.com/Qihoo360/wayne/src/backend/initial" _ "github.com/Qihoo360/wayne/src/backend/routers" "github.com/Qihoo360/wayne/src/backend/workers/webhook" - "github.com/astaxie/beego" ) - func Run() { // MySQL @@ -32,7 +32,6 @@ func Run() { webhook.RegisterHookHandler() - // init kube labels initial.InitKubeLabel() diff --git a/src/backend/cmd/worker/worker.go b/src/backend/cmd/worker/worker.go index 8473fade8..a4231d1a0 100644 --- a/src/backend/cmd/worker/worker.go +++ b/src/backend/cmd/worker/worker.go @@ -1,5 +1,6 @@ package worker +//noinspection ALL import ( "errors" "fmt" @@ -137,5 +138,4 @@ func recoverableWorker(workerSet map[*workers.Worker]workers.Worker, workerType }() workerSet[&worker] = worker - } diff --git a/src/backend/database/generatedata/main.go b/src/backend/database/generatedata/main.go index 2cfcac626..61f31c2e9 100644 --- a/src/backend/database/generatedata/main.go +++ b/src/backend/database/generatedata/main.go @@ -11,5 +11,4 @@ func main() { for _, data := range initial.InitialData { fmt.Println(data) } - } diff --git a/src/backend/database/initial/data.go b/src/backend/database/initial/data.go index ba7ec56cf..3d6336fa4 100644 --- a/src/backend/database/initial/data.go +++ b/src/backend/database/initial/data.go @@ -528,4 +528,10 @@ var InitialData = []string{ `INSERT INTO group_permissions ( group_id, permission_id ) VALUES ('9', '97');`, // APIKEY `INSERT INTO group_permissions ( group_id, permission_id ) VALUES ('8', '100');`, + + // update 1.8.4 to 1.8.5 + `CREATE TABLE 'custom_link' ( 'id' int(64) NOT NULL AUTO_INCREMENT, 'namespace' varchar(255) NOT NULL DEFAULT '', 'link_type' varchar(255) NOT NULL DEFAULT '', 'url' varchar(255) NOT NULL DEFAULT '', 'add_param' tinyint(1) NOT NULL DEFAULT '0', 'deleted' tinyint(1) NOT NULL DEFAULT '0', 'status' tinyint(1) NOT NULL DEFAULT '1', 'params' varchar(255) DEFAULT NULL, PRIMARY KEY ('id'), FULLTEXT KEY 'namespace' ('namespace') ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8`, + `CREATE TABLE 'link_type' ( 'id' int(64) NOT NULL AUTO_INCREMENT, 'type_name' varchar(128) NOT NULL DEFAULT '', 'displayname' varchar(255) NOT NULL DEFAULT '', 'default_url' varchar(255) NOT NULL DEFAULT '', 'param_list' varchar(255) NOT NULL DEFAULT '', 'deleted' tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY ('id'), UNIQUE KEY 'typr_name' ('type_name') ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC`, + `ALTER TABLE cluster ADD 'displayname' varchar(512) DEFAULT ''`, + `ALTER TABLE app ADD 'migrated' tinyint(1) NOT NULL DEFAULT '0'`, } diff --git a/src/backend/database/migrations/v1.1/ddl.sql b/src/backend/database/migrations/v1.1/ddl.sql index 1eb6db07e..0ce8924f3 100644 --- a/src/backend/database/migrations/v1.1/ddl.sql +++ b/src/backend/database/migrations/v1.1/ddl.sql @@ -29,7 +29,6 @@ CREATE TABLE `ingress_template` `deleted` bool NOT NULL DEFAULT false ) ENGINE=InnoDB; - -- Indexes ALTER TABLE `ingress` @@ -37,4 +36,4 @@ ALTER TABLE `ingress` ALTER TABLE `ingress` ADD INDEX `ingress_order_id`(`order_id`); ALTER TABLE `ingress_template` - ADD INDEX `ingress_template_ingress_id`(`ingress_id`); \ No newline at end of file + ADD INDEX `ingress_template_ingress_id`(`ingress_id`); diff --git a/src/backend/database/migrations/v1.3/ddl.sql b/src/backend/database/migrations/v1.3/ddl.sql index cc820fc98..7141e54e4 100644 --- a/src/backend/database/migrations/v1.3/ddl.sql +++ b/src/backend/database/migrations/v1.3/ddl.sql @@ -24,4 +24,4 @@ CREATE TABLE IF NOT EXISTS `hpa_template` ( `user` varchar(128) NOT NULL DEFAULT '' , `deleted` bool NOT NULL DEFAULT false ) ENGINE=InnoDB; -CREATE INDEX `hpa_template_hpa_id` ON `hpa_template` (`hpa_id`); \ No newline at end of file +CREATE INDEX `hpa_template_hpa_id` ON `hpa_template` (`hpa_id`); diff --git a/src/backend/initial/bus.go b/src/backend/initial/bus.go index 15d647177..72eacbc8e 100644 --- a/src/backend/initial/bus.go +++ b/src/backend/initial/bus.go @@ -13,5 +13,4 @@ func InitBus() { panic(err) } } - } diff --git a/src/backend/initial/rsa_key.go b/src/backend/initial/rsa_key.go index c34c35be8..3658bfaea 100644 --- a/src/backend/initial/rsa_key.go +++ b/src/backend/initial/rsa_key.go @@ -22,7 +22,6 @@ func InitRsaKey() { panic(err) } apikey.RsaPublicKey = publicKey - } func readKey(key string) []byte { diff --git a/src/backend/main.go b/src/backend/main.go index 395cec1bc..88225cbb4 100644 --- a/src/backend/main.go +++ b/src/backend/main.go @@ -4,7 +4,6 @@ import ( "github.com/Qihoo360/wayne/src/backend/cmd" ) - func main() { cmd.Run() } From 80672c213972348d3e5c4b98beb353abcc49e56e Mon Sep 17 00:00:00 2001 From: yuchang Date: Thu, 16 Jan 2020 19:31:57 +0800 Subject: [PATCH 2/2] update to 1.8.6 --- Makefile | 1 - README-CN.md | 16 +++++++--------- README.md | 6 ++---- hack/build/backend/Dockerfile | 1 + hack/build/base/Dockerfile | 2 +- hack/build/ui/Dockerfile | 1 - hack/dev/webhook/echo.py | 2 +- hack/docker-compose/conf/app.conf | 5 ++--- hack/docker-compose/conf/config.js | 2 +- hack/docker-compose/docker-compose.yaml | 6 ++---- src/backend/database/initial/data.go | 6 ------ 11 files changed, 17 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index 1de3797a9..61b9ad01c 100644 --- a/Makefile +++ b/Makefile @@ -57,4 +57,3 @@ push-image: docker push $(REGISTRY_URI)/wayne-frontend:latest release: build-backend-image build-frontend-image push-image - diff --git a/README-CN.md b/README-CN.md index 55ac8ba9d..715a75fb5 100644 --- a/README-CN.md +++ b/README-CN.md @@ -23,7 +23,7 @@ Wayne已大规模服务于360搜索,承载了内部绝大部分业务,稳定 ## Features - 基于 RBAC(Role based access control)的权限管理:用户通过角色与部门和项目关联,拥有部门角色允许操作部门资源,拥有项目角色允许操作项目资源,更加适合多租户场景。 -- 简化 Kubernetes 对象创建:提供基础 Kubernetes 对象配置文件添加方式,同时支持高级模式直接编辑 Json/Yaml文件创建 Kubernetes 对象。 +- 简化 Kubernetes 对象创建:提供基础 Kubernetes 对象配置文件添加方式,同时支持高级模式直接编辑 Json/Yaml 文件创建 Kubernetes 对象。 - LDAP/OAuth 2.0/DB 多种登录模式支持:集成企业级 LDAP 登录及 DB 登录模式,同时还可以实现 OAuth2 登录。 - 支持多集群、多租户:可以同时管理多个 Kubernetes 集群,并针对性添加特定配置,更方便的多集群、多租户管理。 - 提供完整审计模块:每次操作都会有完整的审计功能,追踪用于操作历史,同时支持用户自定义 webhook。 @@ -35,7 +35,7 @@ Wayne已大规模服务于360搜索,承载了内部绝大部分业务,稳定 ## 架构设计 -整体采用前后端分离的方案,其中前端采用 Angular 框架进行数据交互和展示,使用Ace编辑器进行 Kubernetes 资源模版编辑。后端采用 Beego 框架做数据接口处理,使用 Client-go 与 Kubernetes 进行交互,数据使用 MySQL 存储。 +整体采用前后端分离的方案,其中前端采用 Angular 框架进行数据交互和展示,使用 Ace 编辑器进行 Kubernetes 资源模版编辑。后端采用 Beego 框架做数据接口处理,使用 Client-go 与 Kubernetes 进行交互,数据使用 MySQL 存储。 ![架构图](https://360yun.org/wayne/images/architecture.png) @@ -46,12 +46,11 @@ Wayne已大规模服务于360搜索,承载了内部绝大部分业务,稳定 ## 项目依赖 -- Golang 1.12+([installation manual](https://golang.org/dl/)) +- Golang 1.12+ ([installation manual](https://golang.org/dl/)) - Docker 17.05+ ([installation manual](https://docs.docker.com/install)) -- Bee ([installation manual](https://github.com/wilhelmguo/bee)) (请务必使用链接版本,不要使用 beego 官方版本,存在一些定制) -- Node.js 8+ and npm 5+ ([installation with nvm](https://github.com/creationix/nvm#usage)) -- MySQL 5.6+ (Wayne 主要数据都存在 MySQL 中) -- RabbitMQ (可选,如需扩展审计功能,例如操作审计和 Webhooks 等,则需部署) +- Bee ([installation manual](https://github.com/beego/bee)) +- Node.js v11+ 和 npm 6.5+ ([installation with nvm](https://github.com/creationix/nvm#usage)) +- MySQL 5.6+ (Wayne 主要数据都存在 MySQL 中) ## 快速启动 @@ -71,8 +70,7 @@ $ docker-compose -f ./hack/docker-compose/docker-compose.yaml up 通过上述命令,您可以从通过 http://127.0.0.1:4200 访问本地 Wayne, 默认管理员账号 admin:admin。 -> 注意:项目启动后还需要配置集群和Namespace等信息才可正常使用。详见 [集群配置](https://360yun.org/wayne/admin/cluster.html) - +> 注意:项目启动后还需要配置集群和 Namespace 等信息才可正常使用。详见 [集群配置](https://360yun.org/wayne/admin/cluster.html) ## 文档 diff --git a/README.md b/README.md index 9b437293c..0dd3eebc8 100644 --- a/README.md +++ b/README.md @@ -47,10 +47,9 @@ The whole system adopts the separation of front and back ends, in which the fron - Golang 1.12+ ([installation manual](https://golang.org/dl/)) - Docker 17.05+ ([installation manual](https://docs.docker.com/install)) -- Bee ([installation manual](https://github.com/wilhelmguo/bee)) (Be sure to use the link version, don't use the official version of beego, there are some customizations.) -- Node.js 8+ and npm 5+ ([installation with nvm](https://github.com/creationix/nvm#usage)) +- Bee ([installation manual](https://github.com/beego/bee)) +- Node.js v11+ and npm 6.5+ ([installation with nvm](https://github.com/creationix/nvm#usage)) - MySQL 5.6+ (Most of the data is in MySQL.) -- RabbitMQ (Optionally, you need to deploy if you need to extend auditing features such as operational auditing and Webhooks.) ## Quickly Start @@ -72,7 +71,6 @@ With the above command, you can access the local Wayne from http://127.0.0.1:420 > Note: After Wayne is started, you need to configure information such as cluster and Namespace for normal use. See details [Cluster Configuration](https://360yun.org/wayne/admin/cluster.html) - ## Document - Refer [Wiki](https://360yun.org/wayne/) diff --git a/hack/build/backend/Dockerfile b/hack/build/backend/Dockerfile index d7f2195b3..b90ef22b2 100644 --- a/hack/build/backend/Dockerfile +++ b/hack/build/backend/Dockerfile @@ -12,6 +12,7 @@ COPY go.sum /go/src/github.com/Qihoo360/wayne COPY src/backend /go/src/github.com/Qihoo360/wayne/src/backend RUN export GO111MODULE=on && \ + export GOPROXY=https://mirrors.aliyun.com/goproxy/ && \ cd /go/src/github.com/Qihoo360/wayne/src/backend && \ bee generate docs && \ bee pack -o /_build diff --git a/hack/build/base/Dockerfile b/hack/build/base/Dockerfile index fd3df87a5..8dcab83f4 100644 --- a/hack/build/base/Dockerfile +++ b/hack/build/base/Dockerfile @@ -2,4 +2,4 @@ FROM centos:7 ADD https://amazon-eks.s3-us-west-2.amazonaws.com/1.11.5/2018-12-06/bin/linux/amd64/aws-iam-authenticator /usr/bin/aws-iam-authenticator -RUN chmod +x /usr/bin/aws-iam-authenticator \ No newline at end of file +RUN chmod +x /usr/bin/aws-iam-authenticator diff --git a/hack/build/ui/Dockerfile b/hack/build/ui/Dockerfile index 6fa7b1017..fff0b7ed8 100644 --- a/hack/build/ui/Dockerfile +++ b/hack/build/ui/Dockerfile @@ -7,4 +7,3 @@ COPY src/frontend/package.json /workspace COPY src/frontend/package-lock.json /workspace RUN npm install --registry=https://registry.npm.taobao.org - diff --git a/hack/dev/webhook/echo.py b/hack/dev/webhook/echo.py index 2b9bab8f4..d0759650c 100644 --- a/hack/dev/webhook/echo.py +++ b/hack/dev/webhook/echo.py @@ -18,4 +18,4 @@ def do_POST(self): Handler = GetHandler httpd = SocketServer.TCPServer(("", PORT), Handler) -httpd.serve_forever() \ No newline at end of file +httpd.serve_forever() diff --git a/hack/docker-compose/conf/app.conf b/hack/docker-compose/conf/app.conf index 4ad923257..7a285a6d6 100644 --- a/hack/docker-compose/conf/app.conf +++ b/hack/docker-compose/conf/app.conf @@ -54,8 +54,8 @@ EnableRobin = false EnableApiKeys = true # Bus +EnableWebhook = true BusEnable = true -BusRabbitMQURL = "amqp://guest:guest@rabbitmq:5672" # Webhook EnableWebhook = true @@ -70,8 +70,8 @@ AppUrl = "" # oauth2 [auth.oauth2] -redirect_url = "https://www.wayne.cloud" enabled = false +redirect_url = "https://www.wayne.cloud" client_id = client client_secret = secret auth_url = https://example.com/oauth2/v1/authorize @@ -92,4 +92,3 @@ ldap_filter = ldap_uid = cn ldap_scope = 2 ldap_connection_timeout = 30 - diff --git a/hack/docker-compose/conf/config.js b/hack/docker-compose/conf/config.js index 665eed3ea..1e60b9b42 100644 --- a/hack/docker-compose/conf/config.js +++ b/hack/docker-compose/conf/config.js @@ -1,5 +1,5 @@ window.CONFIG = { - URL: 'http://localhostip:8080', + URL: 'http://yourip:8080', RAVEN: false, RAVEN_DSN: 'RAVEN_DSN' }; diff --git a/hack/docker-compose/docker-compose.yaml b/hack/docker-compose/docker-compose.yaml index 92f5a822f..b8307ac8d 100644 --- a/hack/docker-compose/docker-compose.yaml +++ b/hack/docker-compose/docker-compose.yaml @@ -14,7 +14,7 @@ services: - "3306:3306" wayne-backend: - image: 360cloud/wayne-backend:v1.8.4-16-gf3a7366 + image: 360cloud/wayne-backend:latest command: /opt/wayne/backend environment: GOPATH: "/go" @@ -29,7 +29,7 @@ services: - "8080:8080" wayne-frontend: - image: 360cloud/wayne-frontend:latest + image: 360cloud/wayne-backend:latest volumes: - ./conf/config.js:/usr/local/openresty/nginx/html/config.js depends_on: @@ -39,5 +39,3 @@ services: - default ports: - "4200:80" - - diff --git a/src/backend/database/initial/data.go b/src/backend/database/initial/data.go index 3d6336fa4..ba7ec56cf 100644 --- a/src/backend/database/initial/data.go +++ b/src/backend/database/initial/data.go @@ -528,10 +528,4 @@ var InitialData = []string{ `INSERT INTO group_permissions ( group_id, permission_id ) VALUES ('9', '97');`, // APIKEY `INSERT INTO group_permissions ( group_id, permission_id ) VALUES ('8', '100');`, - - // update 1.8.4 to 1.8.5 - `CREATE TABLE 'custom_link' ( 'id' int(64) NOT NULL AUTO_INCREMENT, 'namespace' varchar(255) NOT NULL DEFAULT '', 'link_type' varchar(255) NOT NULL DEFAULT '', 'url' varchar(255) NOT NULL DEFAULT '', 'add_param' tinyint(1) NOT NULL DEFAULT '0', 'deleted' tinyint(1) NOT NULL DEFAULT '0', 'status' tinyint(1) NOT NULL DEFAULT '1', 'params' varchar(255) DEFAULT NULL, PRIMARY KEY ('id'), FULLTEXT KEY 'namespace' ('namespace') ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8`, - `CREATE TABLE 'link_type' ( 'id' int(64) NOT NULL AUTO_INCREMENT, 'type_name' varchar(128) NOT NULL DEFAULT '', 'displayname' varchar(255) NOT NULL DEFAULT '', 'default_url' varchar(255) NOT NULL DEFAULT '', 'param_list' varchar(255) NOT NULL DEFAULT '', 'deleted' tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY ('id'), UNIQUE KEY 'typr_name' ('type_name') ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC`, - `ALTER TABLE cluster ADD 'displayname' varchar(512) DEFAULT ''`, - `ALTER TABLE app ADD 'migrated' tinyint(1) NOT NULL DEFAULT '0'`, }