Skip to content

Commit fe2e49f

Browse files
authored
feat: Adds Control API releated Resources (#739)
1 parent 0c84f99 commit fe2e49f

File tree

6 files changed

+198
-0
lines changed

6 files changed

+198
-0
lines changed

charts/apisix/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ The command removes all the Kubernetes components associated with the chart and
135135
| autoscaling.targetCPUUtilizationPercentage | int | `80` | |
136136
| autoscaling.targetMemoryUtilizationPercentage | int | `80` | |
137137
| autoscaling.version | string | `"v2"` | HPA version, the value is "v2" or "v2beta1", default "v2" |
138+
| control.enabled | bool | `true` | Enable Control API |
139+
| control.ingress | object | `{"annotations":{},"enabled":false,"hosts":[{"host":"apisix-control.local","paths":["/*"]}],"tls":[]}` | Using ingress access Apache APISIX Control service |
140+
| control.ingress.annotations | object | `{}` | Ingress annotations |
141+
| control.ingress.hosts | list | `[{"host":"apisix-control.local","paths":["/*"]}]` | Ingress Class Name className: "nginx" |
142+
| control.service.annotations | object | `{}` | Control annotations |
143+
| control.service.externalIPs | list | `[]` | IPs for which nodes in the cluster will also accept traffic for the servic |
144+
| control.service.ip | string | `"127.0.0.1"` | which ip to listen on for Apache APISIX Control API |
145+
| control.service.port | int | `9090` | which port to use for Apache APISIX Control API |
146+
| control.service.servicePort | int | `9090` | Service port to use for Apache APISIX Control API |
147+
| control.service.type | string | `"ClusterIP"` | Control service type |
138148
| dashboard.config.conf.etcd.endpoints | list | `["apisix-etcd:2379"]` | Supports defining multiple etcd host addresses for an etcd cluster |
139149
| dashboard.config.conf.etcd.password | string | `nil` | Specifies etcd basic auth password if enable etcd auth |
140150
| dashboard.config.conf.etcd.prefix | string | `"/apisix"` | apisix configurations prefix |

charts/apisix/templates/configmap.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ data:
5959
extra_lua_path: {{ .Values.apisix.customPlugins.luaPath }};{{ .Values.apisix.luaModuleHook.luaPath }}
6060
{{- end }}
6161
62+
enable_control: {{ .Values.control.enabled }}
63+
{{- if .Values.control.enabled }}
64+
control:
65+
ip: {{ default "127.0.0.1" .Values.control.service.ip }}
66+
port: {{ default 9090 .Values.control.service.port }}
67+
{{- end }}
68+
6269
{{- if .Values.apisix.luaModuleHook.enabled }}
6370
lua_module_hook: {{ .Values.apisix.luaModuleHook.hookPoint | quote }}
6471
{{- end }}

charts/apisix/templates/deployment.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ spec:
121121
containerPort: {{ .Values.apisix.admin.port }}
122122
protocol: TCP
123123
{{- end }}
124+
{{- if .Values.control.enabled }}
125+
- name: control
126+
containerPort: {{ .Values.control.service.port }}
127+
protocol: TCP
128+
{{- end }}
124129
{{- if .Values.apisix.prometheus.enabled }}
125130
- name: prometheus
126131
containerPort: {{ .Values.apisix.prometheus.containerPort }}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
{{- if (and .Values.control.enabled .Values.control.ingress.enabled) -}}
18+
{{- $fullName := include "apisix.fullname" . -}}
19+
{{- $svcPort := .Values.control.servicePort -}}
20+
{{- if and .Values.control.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
21+
{{- if not (hasKey .Values.control.ingress.annotations "kubernetes.io/ingress.class") }}
22+
{{- $_ := set .Values.control.ingress.annotations "kubernetes.io/ingress.class" .Values.control.ingress.className}}
23+
{{- end }}
24+
{{- end }}
25+
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.Version }}
26+
apiVersion: networking.k8s.io/v1
27+
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.Version }}
28+
apiVersion: networking.k8s.io/v1beta1
29+
{{- else -}}
30+
apiVersion: extensions/v1beta1
31+
{{- end }}
32+
kind: Ingress
33+
metadata:
34+
name: {{ $fullName }}-control
35+
labels:
36+
{{- include "apisix.labels" . | nindent 4 }}
37+
{{- with .Values.control.ingress.annotations }}
38+
annotations:
39+
{{- toYaml . | nindent 4 }}
40+
{{- end }}
41+
spec:
42+
{{- if and .Values.control.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
43+
ingressClassName: {{ .Values.control.ingress.className }}
44+
{{- end }}
45+
{{- if .Values.control.ingress.tls }}
46+
tls:
47+
{{- range .Values.control.ingress.tls }}
48+
- hosts:
49+
{{- range .hosts }}
50+
- {{ . | quote }}
51+
{{- end }}
52+
secretName: {{ .secretName }}
53+
{{- end }}
54+
{{- end }}
55+
rules:
56+
{{- range .Values.control.ingress.hosts }}
57+
- host: {{ .host | quote }}
58+
http:
59+
paths:
60+
{{- range .paths }}
61+
- path: {{ . }}
62+
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.Version }}
63+
pathType: ImplementationSpecific
64+
backend:
65+
service:
66+
name: {{ $fullName }}-control
67+
port:
68+
number: {{ $svcPort }}
69+
{{- else }}
70+
backend:
71+
serviceName: {{ $fullName }}-control
72+
servicePort: {{ $svcPort }}
73+
{{- end }}
74+
{{- end }}
75+
{{- end }}
76+
{{- end }}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
{{ if (and .Values.apisix.enabled .Values.control.enabled) }}
17+
apiVersion: v1
18+
kind: Service
19+
metadata:
20+
name: {{ include "apisix.fullname" . }}-control
21+
namespace: {{ .Release.Namespace }}
22+
annotations:
23+
{{- range $key, $value := .Values.control.service.annotations }}
24+
{{ $key }}: {{ $value | quote }}
25+
{{- end }}
26+
labels:
27+
{{- include "apisix.labels" . | nindent 4 }}
28+
app.kubernetes.io/service: apisix-control
29+
spec:
30+
type: {{ .Values.control.service.type }}
31+
{{- if eq .Values.control.service.type "LoadBalancer" }}
32+
{{- if .Values.control.service.loadBalancerIP }}
33+
loadBalancerIP: {{ .Values.control.service.loadBalancerIP }}
34+
{{- end }}
35+
{{- if .Values.control.service.loadBalancerSourceRanges }}
36+
loadBalancerSourceRanges:
37+
{{- range $cidr := .Values.control.service.loadBalancerSourceRanges }}
38+
- {{ $cidr }}
39+
{{- end }}
40+
{{- end }}
41+
{{- end }}
42+
{{- if gt (len .Values.control.service.externalIPs) 0 }}
43+
externalIPs:
44+
{{- range $ip := .Values.control.service.externalIPs }}
45+
- {{ $ip }}
46+
{{- end }}
47+
{{- end }}
48+
ports:
49+
- name: apisix-control
50+
port: {{ .Values.control.service.servicePort }}
51+
targetPort: {{ .Values.control.service.port }}
52+
{{- if (and (eq .Values.control.service.type "NodePort") (not (empty .Values.control.service.nodePort))) }}
53+
nodePort: {{ .Values.control.service.nodePort }}
54+
{{- end }}
55+
protocol: TCP
56+
selector:
57+
{{- include "apisix.selectorLabels" . | nindent 4 }}
58+
{{ end }}

charts/apisix/values.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,48 @@ ingress:
217217
paths: []
218218
tls: []
219219

220+
control:
221+
# -- Enable Control API
222+
enabled: true
223+
service:
224+
# -- Control annotations
225+
annotations: {}
226+
# -- Control service type
227+
type: ClusterIP
228+
# loadBalancerIP: a.b.c.d
229+
# loadBalancerSourceRanges:
230+
# - "143.231.0.0/16"
231+
# -- IPs for which nodes in the cluster will also accept traffic for the servic
232+
externalIPs: []
233+
234+
# -- NodePort (only if control.service.type is NodePort)
235+
# nodePort: 32000
236+
237+
# -- which ip to listen on for Apache APISIX Control API
238+
ip: "127.0.0.1"
239+
# -- which port to use for Apache APISIX Control API
240+
port: 9090
241+
# -- Service port to use for Apache APISIX Control API
242+
servicePort: 9090
243+
# -- Using ingress access Apache APISIX Control service
244+
ingress:
245+
enabled: false
246+
# -- Ingress annotations
247+
annotations:
248+
{}
249+
# kubernetes.io/ingress.class: nginx
250+
# kubernetes.io/tls-acme: "true"
251+
# -- Ingress Class Name
252+
# className: "nginx"
253+
hosts:
254+
- host: apisix-control.local
255+
paths:
256+
- "/*"
257+
tls: []
258+
# - secretName: apisix-tls
259+
# hosts:
260+
# - chart-example.local
261+
220262
# -- Observability configuration.
221263
metrics:
222264
serviceMonitor:

0 commit comments

Comments
 (0)