Skip to content

Commit 8204ae2

Browse files
committed
feat: 新增多个Ingress控制器类型
1 parent 3600fdc commit 8204ae2

File tree

5 files changed

+57
-8
lines changed

5 files changed

+57
-8
lines changed

bcs-services/cluster-resources/pkg/resource/constants/network.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ const (
2727

2828
// IngSubNetIDAnnoKey ...
2929
IngSubNetIDAnnoKey = "kubernetes.io/ingress.subnetId"
30+
31+
// AwsIngSubNetIDAnnoKey ...
32+
AwsIngSubNetIDAnnoKey = "alb.ingress.kubernetes.io/subnets"
3033
)
3134

3235
const (

bcs-services/cluster-resources/pkg/resource/form/parser/network/ing.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ func ParseIngNetwork(manifest map[string]interface{}, network *model.IngNetwork)
7676

7777
subNetIDPath := []string{"metadata", "annotations", resCsts.IngSubNetIDAnnoKey}
7878
network.SubNetID = mapx.GetStr(manifest, subNetIDPath)
79+
// 新增aws ingress 子网id解析
80+
if network.SubNetID == "" {
81+
network.SubNetID = mapx.GetStr(manifest, []string{"metadata", "annotations", resCsts.AwsIngSubNetIDAnnoKey})
82+
}
7983

8084
// 如果已指定子网 ID,则使用模式为为自动创建新 clb,否则使用已存在的 clb
8185
if network.SubNetID != "" {

bcs-services/cluster-resources/pkg/resource/form/tmpl/manifest/Ingress.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ metadata:
99
{{- end }}
1010
annotations:
1111
{{- range .metadata.annotations }}
12-
{{- if and (ne .key "kubernetes.io/ingress.class") (ne .key "kubernetes.io/ingress.existLbId") (ne .key "ingress.cloud.tencent.com/pass-to-target") (ne .key "kubernetes.io/ingress.subnetId") (ne .key "ingress.cloud.tencent.com/auto-rewrite") }}
12+
{{- if and
13+
(ne .key "kubernetes.io/ingress.class")
14+
(ne .key "kubernetes.io/ingress.existLbId")
15+
(ne .key "ingress.cloud.tencent.com/pass-to-target")
16+
(ne .key "kubernetes.io/ingress.subnetId")
17+
(ne .key "alb.ingress.kubernetes.io/subnets")
18+
(ne .key "ingress.cloud.tencent.com/auto-rewrite") }}
1319
{{ .key | quote }}: {{ .value | default "" | quote }}
1420
{{- end }}
1521
{{- end }}
@@ -28,6 +34,12 @@ metadata:
2834
{{- end }}
2935
ingress.cloud.tencent.com/pass-to-target: "true"
3036
{{- end }}
37+
# 处理 aws 特有的一些 annotations
38+
{{- if eq .controller.type "alb" }}
39+
{{- if ne .spec.network.subNetID "" }}
40+
alb.ingress.kubernetes.io/subnets: {{ .spec.network.subNetID | quote }}
41+
{{- end }}
42+
{{- end }}
3143
{{- if .metadata.resVersion }}
3244
resourceVersion: {{ .metadata.resVersion | quote }}
3345
{{- end }}

bcs-services/cluster-resources/pkg/resource/form/tmpl/schema/Ingress.yaml

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,30 @@ properties:
1919
value: qcloud
2020
disabled: false
2121
tips: ""
22+
- label: alb
23+
value: alb
24+
disabled: false
25+
tips: ""
26+
- label: gce
27+
value: gce
28+
disabled: false
29+
tips: ""
30+
- label: azure/application-gateway
31+
value: azure/application-gateway
32+
disabled: false
33+
tips: ""
2234
- label: nginx
2335
value: nginx
24-
disabled: true
25-
tips: {{ i18n "暂时不支持该控制器" .lang }}
36+
disabled: false
37+
tips: ""
2638
- label: bcs
2739
value: bcs
2840
disabled: true
2941
tips: {{ i18n "暂时不支持该控制器" .lang }}
3042
ui:reactions:
31-
# qcloud 暂时不支持 defaultBackend
43+
# qcloud、alb 暂时不支持 defaultBackend
3244
- target: spec.defaultBackend.targetSVC
33-
if: "{{`{{`}} $self.value === 'qcloud' {{`}}`}}"
45+
if: "{{`{{`}} $self.value === 'qcloud' || $self.value === 'alb' {{`}}`}}"
3446
then:
3547
state:
3648
value: ""
@@ -39,14 +51,32 @@ properties:
3951
state:
4052
disabled: false
4153
- target: spec.defaultBackend.port
42-
if: "{{`{{`}} $self.value === 'qcloud' {{`}}`}}"
54+
if: "{{`{{`}} $self.value === 'qcloud' || $self.value === 'alb' {{`}}`}}"
4355
then:
4456
state:
4557
value: 0
4658
disabled: true
4759
else:
4860
state:
4961
disabled: false
62+
- target: spec.network.clbUseType
63+
if: "{{`{{`}} $self.value === 'alb' {{`}}`}}"
64+
then:
65+
state:
66+
value: "autoCreate"
67+
visible: false
68+
else:
69+
state:
70+
visible: true
71+
- target: spec.network
72+
if: "{{`{{`}} $self.value === 'gce' || $self.value === 'azure/application-gateway' || $self.value === 'nginx' {{`}}`}}"
73+
then:
74+
state:
75+
value: ""
76+
visible: false
77+
else:
78+
state:
79+
visible: true
5080
# 目前只支持 qcloud 的重定向,nginx 后续支持了再开放
5181
- target: spec.cert.autoRewriteHttp
5282
if: "{{`{{`}} $self.value === 'qcloud' {{`}}`}}"

bcs-services/cluster-resources/pkg/resource/form/tmpl/schema/network.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ defaultBackend:
184184
targetSVC:
185185
title: {{ i18n "目标 Service" .lang }}
186186
type: string
187-
description: {{ i18n "控制器类型 qcloud 暂时不支持配置默认后端" .lang }}
187+
description: {{ i18n "控制器类型 qcloud、alb 暂时不支持配置默认后端" .lang }}
188188
default: ""
189189
ui:component:
190190
name: select
@@ -212,7 +212,7 @@ defaultBackend:
212212
port:
213213
title: {{ i18n "端口" .lang }}
214214
type: integer
215-
description: {{ i18n "控制器类型 qcloud 暂时不支持配置默认后端" .lang }}
215+
description: {{ i18n "控制器类型 qcloud、alb 暂时不支持配置默认后端" .lang }}
216216
ui:component:
217217
props:
218218
min: 1

0 commit comments

Comments
 (0)