|
1 |
| -# kube-combo |
| 1 | +# Kube-Combo |
2 | 2 |
|
3 |
| -该项目用于在 kube-ovn-cni 的一个**补充**,用于实现一些 kube-ovn-cni 中属于间接关联的一些网络应用。直接关联的网络功能应直接在 kube-ovn 中实现。 |
4 |
| -为了保持该项目的定位的清晰和轻量: |
| 3 | +Kube-Combo 是一款基于 POD 来提供各种各样网元能力的编排系统,提供丰富的功能以及良好的可运维性。 |
5 | 4 |
|
6 |
| -- 该项目最多会对 kube-ovn crd 的存在与否做一些 get 校验,目前不会 CRUD kube-ovn crd 资源。 |
7 |
| -- 该项目只会实现 kube-ovn 中所不直接具备的 crd,不会提供关于某个用户场景的需求的多个 CRD 的再次封装为一个新的业务网络功能的 CRD。 |
8 |
| -- 在使用上,业务需求方负责对基础 CRD API 接口进行编排,需直接对接 kube-ovn 的 crd,或者,该项目提供的 crd。 |
| 5 | +丰富的功能: |
9 | 6 |
|
10 |
| -## 1. Code init |
| 7 | +如果你发现在 K8S 集群中无法直接使用一些高级的网络功能,比如 IPsec vpn GW,SSL vpn GW,Haproxy,Nginx 等,那么 Kube-Combo 将是你的最佳选择。 |
| 8 | +借助 K8S CNI 提供的底层能力,可以通过多 POD 负载结合各种各样的成熟的应用,提供高可用且丰富的网元能力。 |
11 | 9 |
|
12 |
| -``` bash |
| 10 | +良好的可运维性: |
13 | 11 |
|
14 |
| -operator-sdk init --domain kube-combo.com --repo github.com/bobz965/kube-combo --plugins=go/v4-alpha |
15 |
| - |
16 |
| -# we'll use a domain of kube-combo.com |
17 |
| -# so all API groups will be <group>.kube-combo.com |
18 |
| - |
19 |
| -# --plugins=go/v4-alpha mac arm 芯片需要指定 |
20 |
| - |
21 |
| -# 该步骤后可创建 api |
22 |
| -# operator-sdk create api |
23 |
| -operator-sdk create api --group vpn-gw --version v1 --kind VpnGw --resource --controller |
24 |
| -operator-sdk create api --group vpn-gw --version v1 --kind IpsecConn --resource --controller |
25 |
| - |
26 |
| - |
27 |
| -# make generate 生成controller 相关的 informer clientset 等代码 |
28 |
| - |
29 |
| -## 下一步就是编写crd |
30 |
| -## 重新生成代码 |
31 |
| -## 编写 reconcile 逻辑 |
32 |
| - |
33 |
| -### 最后就是生成部署文件 |
34 |
| -make manifests |
35 |
| - |
36 |
| -``` |
37 |
| - |
38 |
| -## 2. 设计 |
39 |
| - |
40 |
| -公网访问方式 |
41 |
| - |
42 |
| -- fip |
43 |
| -- router lb (后续的 ha 方案) |
44 |
| - |
45 |
| -### 2.1 ssl vpn |
46 |
| - |
47 |
| -该功能基于 openvpn 实现,可以通过公网 ip,在个人 电脑,手机客户端直接访问 kube-ovn 自定义 vpc subnet 内部的 pod 以及 switch lb 对应是的 svc endpoint。 |
48 |
| - |
49 |
| -### 2.2 ipsec vpn |
50 |
| - |
51 |
| -该功能基于 strongSwan 实现,[用于 Site-to-Site 场景](https://github.com/strongswan/strongswan#site-to-site-case) ,推荐使用 IKEv2, IKEv1 安全性较低 |
52 |
| - |
53 |
| -strongSwan 的主要包括两个配置 |
54 |
| - |
55 |
| -- /etc/swanctl/swanctl.conf |
56 |
| -- /etc/hosts |
57 |
| - |
58 |
| -swanctl 配置中的 connection 中的域名解析 在 /etc/hosts 中管理,这两个配置都基于[j2](https://github.com/kolypto/j2cli) 来生成,基于 pod exec 将 vpn gw 依赖的 ipsec connection crd 中的信息保存在 connection.yaml 中。 |
59 |
| - |
60 |
| -``` bash |
61 |
| - |
62 |
| -j2 swanctl.conf.j2 data.yaml |
63 |
| -j2 hosts.j2 data.yaml |
64 |
| - |
65 |
| -# mv swanctl.conf /etc/swanctl/swanctl.conf |
66 |
| -# mv hosts /etc/hosts |
67 |
| -``` |
68 |
| - |
69 |
| -## 3. 维护 |
70 |
| - |
71 |
| -基于 operator 生命周期管理器(olm)来维护, 可以对接到应用商店 kubeapp。 |
72 |
| - |
73 |
| -### 3.1 项目打包 |
74 |
| - |
75 |
| -Docker |
76 |
| - |
77 |
| -``` bash |
78 |
| -make docker-build docker-push |
79 |
| - |
80 |
| -# make docker-build |
81 |
| -# make docker-push |
82 |
| - |
83 |
| - |
84 |
| -# build openvpn image |
85 |
| - |
86 |
| -make docker-build-ssl-vpn docker-push-ssl-vpn |
87 |
| - |
88 |
| -make docker-build-ipsec-vpn docker-push-ipsec-vpn |
89 |
| - |
90 |
| -``` |
91 |
| - |
92 |
| -OLM |
93 |
| - |
94 |
| -``` bash |
95 |
| -make bundle bundle-build bundle-push |
96 |
| - |
97 |
| -# make bundle |
98 |
| -# make bundle-build |
99 |
| -# make bundle-push |
100 |
| - |
101 |
| - |
102 |
| -## 目前不支持直接测试,必须要先把bundle 传到 registry,有issue记录: https://github.com/operator-framework/operator-sdk/issues/6432 |
103 |
| - |
104 |
| - |
105 |
| -``` |
106 |
| - |
107 |
| -### 3.2 部署 |
108 |
| - |
109 |
| -目前认为 olm 本身不够成熟,基于 `make deploy` 来部署 |
110 |
| - |
111 |
| -``` bash |
112 |
| - |
113 |
| -cd config/manager && /root/kube-combo/bin/kustomize edit set image controller=registry.cn-hangzhou.aliyuncs.com/bobz/kube-combo:latest |
114 |
| -/root/kube-combo/bin/kustomize build config/default | kubectl apply -f - |
115 |
| - |
116 |
| - |
117 |
| -``` |
118 |
| - |
119 |
| -[operator-sdk 二进制安装方式](https://sdk.operatorframework.io/docs/installation/) |
120 |
| - |
121 |
| -```bash |
122 |
| -# 在 k8s集群安装该项目 |
123 |
| -operator-sdk olm install |
124 |
| - |
125 |
| -## ref https://github.com/operator-framework/operator-lifecycle-manager/releases/tag/v0.24.0 |
126 |
| - |
127 |
| -curl -L https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.24.0/install.sh -o install.sh |
128 |
| -chmod +x install.sh |
129 |
| -./install.sh v0.24.0 |
130 |
| - |
131 |
| - |
132 |
| -# 运行 operator |
133 |
| - |
134 |
| -operator-sdk run bundle registry.cn-hangzhou.aliyuncs.com/bobz/kube-combo-bundle:v0.0.1 |
135 |
| - |
136 |
| -# 检查 operator 已安装 |
137 |
| - |
138 |
| -kubectl get csv |
139 |
| - |
140 |
| - |
141 |
| - |
142 |
| -## 基于 kubectl apply 运行一个该 operator 维护的 crd |
143 |
| - |
144 |
| -# 清理该 operator |
145 |
| -k get operator |
146 |
| - |
147 |
| -operator-sdk cleanup vpn-gw |
148 |
| - |
149 |
| -``` |
150 |
| - |
151 |
| -### 4. certmanager |
152 |
| - |
153 |
| -``` bash |
154 |
| -operator-sdk olm install |
155 |
| - |
156 |
| -# 功能上 operator-sdk == kubectl operator |
157 |
| - |
158 |
| -kubectl krew install operator |
159 |
| -kubectl create ns cert-manager |
160 |
| -kubectl operator install cert-manager -n cert-manager --channel candidate --approval Automatic --create-operator-group |
161 |
| - |
162 |
| -# kubectl operator install cert-manager -n operators --channel stable --approval Automatic |
163 |
| - |
164 |
| -kubectl get events -w -n operators |
165 |
| - |
166 |
| -kubectl operator list |
167 |
| -kubectl operator uninstall cert-manager -n cert-manager |
168 |
| - |
169 |
| -# 目前 基于operator 安装的版本普遍较旧,差了一个大版本,可能要跟下 operator 的维护策略 |
170 |
| -# 目前认为最好是基于 kubectl apply 安装最新的 |
171 |
| - |
172 |
| -kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.12.1/cert-manager.yaml |
173 |
| -kubectl get pods -n cert-manager |
174 |
| -kubectl get crd | grep cert-manager.io |
175 |
| - |
176 |
| -# 清理: https://cert-manager.io/docs/installation/kubectl/ |
177 |
| - |
178 |
| - |
179 |
| -``` |
180 |
| - |
181 |
| -### 5. 通用性 |
182 |
| - |
183 |
| -目前 vpn gw pod 只需要一个 IP,所以只需要保证固定内网 IP 是符合 k8s 通用规范即可保证能够适用于其他 CNI。 |
184 |
| -该 IP 对应的 nat, 以及如何公网互联的路由和该功能是完全解耦的。 |
185 |
| - |
186 |
| -各大公有云都是 sdn 网络,支持在 k8s 托管, 基于该 vpn gw operator 互相打通,比起申请虚拟机资源部署的方式应该更节省成本。 |
187 |
| - |
188 |
| -### 6. 参考 |
189 |
| - |
190 |
| -- [一个简单的 ipsec vpn 在公有云部署的项目就可以有 23k 的 star](https://github.com/hwdsl2/setup-ipsec-vpn/blob/master/README-zh.md#%E4%B8%8B%E4%B8%80%E6%AD%A5) |
| 12 | +Kube-Combo 支持一键安装,帮助用户迅速搭建生产就绪的网络应用。同时内置的丰富的监控指标和 Grafana 面板,可帮助用户建立完善的监控体系。 |
0 commit comments