Skip to content

Commit 3e3ef69

Browse files
authored
feat: add ETCD dependency for api7 dashboard (#45)
1 parent b8a9801 commit 3e3ef69

File tree

6 files changed

+70
-119
lines changed

6 files changed

+70
-119
lines changed

chart/api7-dashboard/Chart.lock

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
dependencies:
2+
- name: etcd
3+
repository: https://charts.bitnami.com/bitnami
4+
version: 5.2.1
25
- name: prometheus
36
repository: https://prometheus-community.github.io/helm-charts
47
version: 9.7.5
58
- name: grafana
69
repository: https://grafana.github.io/helm-charts
710
version: 6.0.0
8-
digest: sha256:0b3f674fd91279a390c1752cb2b5d8b609578a8814df9dd536f0cb1c0aa9ee8b
9-
generated: "2021-11-18T14:27:32.795905+08:00"
11+
digest: sha256:3a48311c20e4406b0fc709edcc04bf7ae4bd0f24c516068a57870aef0e064db0
12+
generated: "2021-12-16T10:21:57.083452+08:00"

chart/api7-dashboard/Chart.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ maintainers:
2626
2727
name: Chao Zhang
2828
dependencies:
29+
- name: etcd
30+
version: 5.2.1
31+
repository: https://charts.bitnami.com/bitnami
32+
condition: etcd.builtin
2933
- name: prometheus
3034
version: 9.0
3135
condition: prometheus.builtin

chart/api7-dashboard/README.md

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,12 @@ kubectl create namespace api7
2626

2727
Images for api7-dashboard is private and never should be uploaded to public image registries like [dockerhub](https://hub.docker.com), so make sure the image for api7-dashboard was stashed in a registry that can be accessed from the Kubernetes cluster.
2828

29-
Also, as api7-dashboard is used to operate configurations for api7, so api7 and ETCD cluster should be installed before api7-dashboard, we assume that them were installed already, if not, please refer to [api7-chart](../api7/README.md).
30-
3129
```sh
32-
# api7-dashboard.yaml
33-
image:
34-
registry: localhost:5000
35-
repository: api7/api7-dashboard
36-
tag: v2.1ee
37-
config:
38-
clusters:
39-
- name: cluster_1
40-
etcd:
41-
hosts:
42-
- https://api7-etcd.api7.svc.cluster.local
43-
selfEtcd:
44-
hosts:
45-
- https://api7-etcd.api7.svc.cluster.local
46-
47-
helm install api7-dashboard . -n api7 --values api7-dashboard.yaml
30+
helm install api7-dashboard . -n api7 \
31+
--set image.registry=apisixacr.azurecr.cn \
32+
--set image.repository=api7-dashboard \
33+
--set service.type=NodePort \
34+
--set image.tag=2.7.2112
4835
```
4936

5037
When you execute the above command, change the registry, repository and tag according to your situation.

chart/api7-dashboard/templates/configmap.yaml

Lines changed: 18 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -94,53 +94,27 @@ data:
9494
{{ end }}
9595
{{- end -}}
9696
{{- end }}
97-
etcd_clusters:
98-
{{ range .Values.config.clusters }}
99-
{{- .name | indent 2 }}:
100-
endpoints:
101-
{{- range .etcd.hosts }}
102-
- {{ . -}}
103-
{{ end }}
104-
prefix: {{ .etcd.prefix -}}
105-
{{- if .etcd.auth.rbac.enabled }}
106-
username: {{ .etcd.auth.rbac.user | quote }}
107-
password: {{ .etcd.auth.rbac.password | quote }}
108-
{{ end }}
109-
{{- if .etcd.auth.tls.enabled }}
110-
mtls:
111-
key_file: "/usr/local/apisix-dashboard/{{ .name }}-etcd-ssl/{{ .etcd.auth.tls.certKeyFilename }}"
112-
cert_file: "/usr/local/apisix-dashboard/{{ .name }}-etcd-ssl/{{ .etcd.auth.tls.certFilename }}"
113-
ca_file: "/usr/local/apisix-dashboard/{{ .name }}-etcd-ssl/{{ .etcd.auth.tls.certCAFilename }}"
114-
{{- end }}
115-
{{ end }}
116-
user_conf:
117-
endpoints:
118-
{{ range .Values.config.selfEtcd.hosts -}}
119-
- {{ . }}
120-
{{ end }}
121-
prefix: {{ .Values.config.selfEtcd.prefix -}}
122-
{{- if .Values.config.selfEtcd.auth.rbac.enabled }}
123-
username: {{ .Values.config.selfEtcd.auth.rbac.user | quote }}
124-
password: {{ .Values.config.selfEtcd.auth.rbac.password | quote }}
125-
{{ end }}
126-
{{- if .Values.config.selfEtcd.auth.tls.enabled }}
127-
mtls:
128-
key_file: "/usr/local/apisix-dashboard/self-etcd-ssl/{{ .Values.config.selfEtcd.auth.tls.certKeyFilename }}"
129-
cert_file: "/usr/local/apisix-dashboard/self-etcd-ssl/{{ .Values.config.selfEtcd.auth.tls.certFilename }}"
130-
ca_file: "/usr/local/apisix-dashboard/self-etcd-ssl/{{ .Values.config.selfEtcd.auth.tls.certCAFilename }}"
131-
{{- end }}
13297
etcd:
133-
name: {{ .Values.config.selfEtcd.name }}
98+
name: {{ .Values.etcd.name }}
99+
{{- if .Values.etcd.builtin }}
134100
endpoints:
135-
{{ range .Values.config.selfEtcd.hosts -}}
136-
- {{ . }}
137-
{{ end }}
138-
prefix: {{ .Values.config.selfEtcd.prefix -}}
139-
{{- if .Values.config.selfEtcd.auth.tls.enabled }}
101+
- "http://{{ .Release.Name }}-etcd.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}:{{ .Values.etcd.service.port }}"
102+
{{- else }}
103+
endpoints:
104+
{{- range $value := .Values.etcd.hosts }}
105+
- "{{ $value }}"
106+
{{- end }}
107+
{{- end }}
108+
{{- if .Values.etcd.auth.rbac.enabled }}
109+
username: {{ .Values.etcd.auth.rbac.user | quote }}
110+
password: {{ .Values.etcd.auth.rbac.password | quote }}
111+
{{- end }}
112+
prefix: {{ .Values.etcd.prefix -}}
113+
{{- if .Values.etcd.auth.tls.enabled }}
140114
mtls:
141-
key_file: "/usr/local/apisix-dashboard/self-etcd-ssl/{{ .Values.config.selfEtcd.auth.tls.certKeyFilename }}"
142-
cert_file: "/usr/local/apisix-dashboard/self-etcd-ssl/{{ .Values.config.selfEtcd.auth.tls.certFilename }}"
143-
ca_file: "/usr/local/apisix-dashboard/self-etcd-ssl/{{ .Values.config.selfEtcd.auth.tls.certCAFilename }}"
115+
key_file: "/usr/local/apisix-dashboard/self-etcd-ssl/{{ .Values.etcd.auth.tls.certKeyFilename }}"
116+
cert_file: "/usr/local/apisix-dashboard/self-etcd-ssl/{{ .Values.etcd.auth.tls.certFilename }}"
117+
ca_file: "/usr/local/apisix-dashboard/self-etcd-ssl/{{ .Values.etcd.auth.tls.certCAFilename }}"
144118
{{- end }}
145119
log:
146120
error_log:

chart/api7-dashboard/templates/deployment.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ spec:
8181
mountPath: "/usr/local/apisix-dashboard/{{ .name }}-etcd-ssl"
8282
{{- end }}
8383
{{- end }}
84-
{{- if .Values.config.selfEtcd.auth.tls.enabled }}
84+
{{- if .Values.etcd.auth.tls.enabled }}
8585
- name: self-etcd-ssl
8686
mountPath: "/usr/local/apisix-dashboard/self-etcd-ssl"
8787
{{- end }}
@@ -110,10 +110,10 @@ spec:
110110
secretName: {{ .etcd.auth.tls.existingSecret }}
111111
{{- end }}
112112
{{- end }}
113-
{{- if .Values.config.selfEtcd.auth.tls.enabled }}
113+
{{- if .Values.etcd.auth.tls.enabled }}
114114
- name: self-etcd-ssl
115115
secret:
116-
secretName: {{ .Values.config.selfEtcd.auth.tls.existingSecret }}
116+
secretName: {{ .Values.etcd.auth.tls.existingSecret }}
117117
{{- end }}
118118
{{- with .Values.nodeSelector }}
119119
nodeSelector:

chart/api7-dashboard/values.yaml

Lines changed: 35 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,48 @@ prometheus:
7676
grafana:
7777
builtin: true
7878

79+
# etcd configuration
80+
# use the FQDN address or the IP of the etcd
81+
etcd:
82+
# install etcd(v3) by default, set false if do not want to install etcd(v3) together,
83+
# in such a case, etcd.host should be configured so that existing ETCD cluster can be
84+
# used.
85+
builtin: true
86+
name: "default"
87+
hosts:
88+
- http://etcd.host:2379 # host or ip e.g. http://172.20.128.89:2379
89+
prefix: "/api7"
90+
timeout: 30
91+
defaultPort: 2379
92+
auth:
93+
rbac:
94+
# No authentication by default
95+
enabled: false
96+
## etcd user
97+
##
98+
user: ""
99+
## etcd password
100+
##
101+
password: ""
102+
# Whether to set up secure transport to ETCD cluster.
103+
tls:
104+
enalbed: false
105+
# An existing secret stores the credentials to communicate with ETCD cluster.
106+
existingSecret: ""
107+
# Certificate filename used to communicate ETCD cluster.
108+
certFilename: "tls.crt"
109+
# Private key filename used to communicate ETCD cluster.
110+
certKeyFilename: "tls.key"
111+
certCAFilename: "ca.crt"
112+
verify: true
113+
79114
# api7-dashboard configurations
80115
config:
81116
# Key prefix used by api7-dashboard in ETCD cluster.
82117
allowList:
83118
- 127.0.0.0/24
84119
allowAdmin: []
85120
trustedProxies: []
86-
87121
http:
88122
enabled: true
89123
servicePort: 9000
@@ -94,63 +128,13 @@ config:
94128
port: 9443
95129
secretName: ""
96130
mtls_enabled: true
97-
98-
# Multiple clusters configuration
99-
clusters:
100-
- name: cluster_1
101-
etcd:
102-
hosts: []
103-
service:
104-
port: 2379
105-
auth:
106-
rbac:
107-
enabled: false
108-
## etcd user
109-
##
110-
user: ""
111-
## etcd password
112-
##
113-
password: ""
114-
tls:
115-
enabled: false
116-
# Specify an existing secret with credentials for the communication with ETCD.
117-
existingSecret: ""
118-
certFilename: "tls.crt"
119-
certKeyFilename: "tls.key"
120-
certCAFilename: "ca.crt"
121-
prefix: /api7
122-
# selfEtcd configures the etcd cluster used to store
123-
# metadata.
124-
selfEtcd:
125-
hosts: []
126-
name: "default"
127-
service:
128-
port: 2379
129-
auth:
130-
rbac:
131-
enabled: false
132-
## etcd user
133-
##
134-
user: ""
135-
## etcd password
136-
##
137-
password: ""
138-
tls:
139-
enabled: false
140-
# Specify an existing secret with credentials for the communication with ETCD.
141-
existingSecret: ""
142-
certFilename: "tls.crt"
143-
certKeyFilename: "tls.key"
144-
certCAFilename: "ca.crt"
145-
prefix: /api7
146131
k8sSupport:
147132
enable: true
148133
namespaces: ["*"]
149134
clusterDomain: "cluster.local"
150135
clusterRole: "services-lister"
151136
serviceAccount: "api7-account"
152137
clusterRoleBinding: "api7-services-account-binding"
153-
154138
authentication:
155139
secret: "qwerty"
156140
expire_time: 3600 # jwt token expire time, in second
@@ -161,7 +145,6 @@ config:
161145
users: # yamllint enable rule:comments-indentation
162146
- username: admin # username and password for login `manager api`
163147
password: admin
164-
165148
log:
166149
error_log:
167150
level: warn

0 commit comments

Comments
 (0)