Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复chart在未开启mysql服务代理时无法使用配置的mysql端口问题 #3385

Merged
merged 3 commits into from
Nov 22, 2020

Conversation

changfubai
Copy link
Contributor

修复admin、config、portal三个服务在通过helm部署时,如果不开启mysql的代理服务,values.yaml中的mysql端口不会被使用,会使用代理服务的端口

apollo-server/configserver 为例:
如果Values.configdb.service.enabled=false时,表示不使用mysql的代理,
此时configmap中的定义是:

spring.datasource.url = jdbc:mysql://{{include "apollo.configdb.serviceName" .}}:{{ .Values.configdb.service.port }}

注意,服务地址使用的模板定义,但端口使用的Values.configdb.service.port,这意味着不开启mysql代理时,连接的是自定义的mysql服务地址+代理服务的端口(尽管此时并没有开启代理服务)。

三个服务均有该问题,如果配置的mysql端口不是默认的3306时就能发现该问题(服务连不上数据库)

解决方案
对数据库端口也进行模板定义,configmap中修改为:

spring.datasource.url = jdbc:mysql://{{include "apollo.configdb.serviceName" .}}:{{include "apollo.configdb.servicePort" .}}

apollo.configdb.servicePort的模板定义如下:

{{/*
Service port for configdb
*/}}
{{- define "apollo.configdb.servicePort" -}}
{{- if .Values.configdb.service.enabled -}}
{{- .Values.configdb.service.port -}}
{{- else -}}
{{- .Values.configdb.port -}}
{{- end -}}
{{- end -}}

以上是对configserver的修改,对adminserver只需调整configmap即可;portal则进行了以上相同的修改~

@changfubai changfubai changed the title helm支持直接使用mysql服务的port 修复chart在未开启mysql服务代理时无法使用配置的mysql端口问题 Nov 19, 2020
Copy link
Member

@nobodyiam nobodyiam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@codecov-io
Copy link

codecov-io commented Nov 22, 2020

Codecov Report

Merging #3385 (3d25662) into master (942be32) will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3385      +/-   ##
============================================
- Coverage     51.45%   51.43%   -0.02%     
+ Complexity     2303     2301       -2     
============================================
  Files           442      442              
  Lines         13741    13741              
  Branches       1399     1399              
============================================
- Hits           7070     7068       -2     
- Misses         6180     6185       +5     
+ Partials        491      488       -3     
Impacted Files Coverage Δ Complexity Δ
...framework/apollo/openapi/entity/ConsumerAudit.java 42.42% <0.00%> (-6.07%) 9.00% <0.00%> (-2.00%)
...mework/apollo/openapi/service/ConsumerService.java 47.57% <0.00%> (-1.95%) 12.00% <0.00%> (-1.00%)
.../apollo/internals/RemoteConfigLongPollService.java 78.31% <0.00%> (+1.20%) 29.00% <0.00%> (+1.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b8be1cd...3d25662. Read the comment docs.

@nobodyiam nobodyiam merged commit bd388e8 into apolloconfig:master Nov 22, 2020
@nobodyiam nobodyiam added this to the 1.8.0 milestone Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants