Skip to content

Commit c4ff8d9

Browse files
committed
fix: 完善项目
1 parent 6b4ad83 commit c4ff8d9

File tree

12 files changed

+201
-73
lines changed

12 files changed

+201
-73
lines changed

README.md

+26-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,36 @@
22

33
### 项目思路与设计
44
![](https://github.com/googs1025/proxy-operator/blob/main/image/%E6%B5%81%E7%A8%8B%E5%9B%BE.jpg?raw=true)
5-
设计背景:集群的网关通常都是采用nginx-controller部署的方式,对自用小集群难免存在部署步骤复杂等问题。
6-
本项目在此问题上,基于k8s的扩展功能,实现proxy的自定义资源,做出一个有反向代理功能的controller应用。调用方可在cluster中部署与启动相关配置即可使用。
7-
思路:当应用启动后,会启动一个controller与proxy反向代理服务,controller会监听crd资源,并执行相应的业务逻辑。
5+
设计背景:集群的网关通常都是采用 nginx-controller 部署的方式,对自用小集群难免存在部署步骤复杂等问题。
6+
本项目在此问题上,基于 k8s 的扩展功能,实现 proxy 的自定义资源,做出一个有反向代理功能的 controller 应用。调用方可在 cluster 中部署与启动相关配置即可使用。
7+
8+
思路:当应用启动后,会启动一个 **controller****proxy** 反向代理服务,controller 会监听 crd 资源,并执行相应的业务逻辑。
89

910
### 项目功能
10-
1. 支持多个service服务的配置,实现集群的网关功能。
11+
1. 支持多个 service 服务的配置,实现集群的网关功能。
1112
2. 实现中间件框架,可以自定义中间件。
12-
3. 提供ip限流、query限流功能。
13-
### 本地调适
13+
3. 提供 ip 限流、query 限流功能。
1414

15+
- cr 资源对象如下所示:
16+
```yaml
17+
apiVersion: api.practice.com/v1alpha1
18+
kind: Proxy
19+
metadata:
20+
name: myproxy
21+
spec:
22+
server: # 反向代理 server ip:port
23+
ip: localhost
24+
port: 10086
25+
rules: # 后端路由列表
26+
- path:
27+
backend: # 后端
28+
prefix: /service1 # 自定义前缀
29+
url: http://localhost:8899 # 真正要访问的服务
30+
- path:
31+
backend:
32+
prefix: /service2
33+
url: http://localhost:8800
34+
```
1535
1636
### 项目部署
1737

app.yaml

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
Rules:
22
- Path:
33
Backend:
4-
Prefix: /test1
4+
Prefix: /service1
55
Url: http://localhost:8899
66
- Path:
77
Backend:
8-
Prefix: /tttt
9-
Url: https://github.com
10-
- Path:
11-
Backend:
12-
Prefix: /aaaa
13-
Url: http://localhost:8081
8+
Prefix: /service2
9+
Url: http://localhost:8800
1410
Server:
1511
Ip: localhost
1612
Params: name,user,aaaa

go.mod

+24-7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/myoperator/proxyoperator
33
go 1.18
44

55
require (
6+
github.com/gin-gonic/gin v1.9.1
67
k8s.io/apimachinery v0.26.2
78
k8s.io/client-go v0.26.2
89
k8s.io/code-generator v0.26.1
@@ -13,17 +14,25 @@ require (
1314

1415
require (
1516
github.com/beorn7/perks v1.0.1 // indirect
17+
github.com/bytedance/sonic v1.9.1 // indirect
1618
github.com/cespare/xxhash/v2 v2.1.2 // indirect
19+
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
1720
github.com/davecgh/go-spew v1.1.1 // indirect
1821
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
1922
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
2023
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
2124
github.com/fsnotify/fsnotify v1.6.0 // indirect
25+
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
26+
github.com/gin-contrib/sse v0.1.0 // indirect
2227
github.com/go-logr/logr v1.2.3 // indirect
2328
github.com/go-logr/zapr v1.2.3 // indirect
2429
github.com/go-openapi/jsonpointer v0.19.5 // indirect
2530
github.com/go-openapi/jsonreference v0.20.0 // indirect
2631
github.com/go-openapi/swag v0.19.14 // indirect
32+
github.com/go-playground/locales v0.14.1 // indirect
33+
github.com/go-playground/universal-translator v0.18.1 // indirect
34+
github.com/go-playground/validator/v10 v10.14.0 // indirect
35+
github.com/goccy/go-json v0.10.2 // indirect
2736
github.com/gogo/protobuf v1.3.2 // indirect
2837
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
2938
github.com/golang/protobuf v1.5.2 // indirect
@@ -34,31 +43,39 @@ require (
3443
github.com/imdario/mergo v0.3.6 // indirect
3544
github.com/josharian/intern v1.0.0 // indirect
3645
github.com/json-iterator/go v1.1.12 // indirect
46+
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
47+
github.com/leodido/go-urn v1.2.4 // indirect
3748
github.com/mailru/easyjson v0.7.6 // indirect
49+
github.com/mattn/go-isatty v0.0.19 // indirect
3850
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
3951
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
4052
github.com/modern-go/reflect2 v1.0.2 // indirect
4153
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
54+
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
4255
github.com/pkg/errors v0.9.1 // indirect
4356
github.com/prometheus/client_golang v1.14.0 // indirect
4457
github.com/prometheus/client_model v0.3.0 // indirect
4558
github.com/prometheus/common v0.37.0 // indirect
4659
github.com/prometheus/procfs v0.8.0 // indirect
4760
github.com/spf13/pflag v1.0.5 // indirect
61+
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
62+
github.com/ugorji/go/codec v1.2.11 // indirect
4863
go.uber.org/atomic v1.7.0 // indirect
4964
go.uber.org/multierr v1.6.0 // indirect
5065
go.uber.org/zap v1.24.0 // indirect
51-
golang.org/x/mod v0.6.0 // indirect
52-
golang.org/x/net v0.7.0 // indirect
66+
golang.org/x/arch v0.3.0 // indirect
67+
golang.org/x/crypto v0.9.0 // indirect
68+
golang.org/x/mod v0.8.0 // indirect
69+
golang.org/x/net v0.10.0 // indirect
5370
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
54-
golang.org/x/sys v0.5.0 // indirect
55-
golang.org/x/term v0.5.0 // indirect
56-
golang.org/x/text v0.7.0 // indirect
71+
golang.org/x/sys v0.8.0 // indirect
72+
golang.org/x/term v0.8.0 // indirect
73+
golang.org/x/text v0.9.0 // indirect
5774
golang.org/x/time v0.3.0 // indirect
58-
golang.org/x/tools v0.2.0 // indirect
75+
golang.org/x/tools v0.6.0 // indirect
5976
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
6077
google.golang.org/appengine v1.6.7 // indirect
61-
google.golang.org/protobuf v1.28.1 // indirect
78+
google.golang.org/protobuf v1.30.0 // indirect
6279
gopkg.in/inf.v0 v0.9.1 // indirect
6380
gopkg.in/yaml.v2 v2.4.0 // indirect
6481
gopkg.in/yaml.v3 v3.0.1 // indirect

0 commit comments

Comments
 (0)