-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
修复导致在k8s中部署中失败的两个地方 #2113
修复导致在k8s中部署中失败的两个地方 #2113
Conversation
修复多个环境使用同dev环境注册中心导致web管理界面获取admin Server不一致
Codecov Report
@@ Coverage Diff @@
## master #2113 +/- ##
============================================
+ Coverage 49.97% 49.99% +0.01%
- Complexity 1980 1981 +1
============================================
Files 401 401
Lines 12411 12411
Branches 1279 1279
============================================
+ Hits 6203 6205 +2
+ Misses 5750 5749 -1
+ Partials 458 457 -1
Continue to review full report at Codecov.
|
@@ -24,6 +24,6 @@ ENV DATASOURCES_PASSWORD="FillInCorrectPassword" | |||
|
|||
EXPOSE 8090 | |||
|
|||
ENTRYPOINT ["/apollo-admin-server/entrypoint.sh"] | |||
#ENTRYPOINT ["/apollo-admin-server/entrypoint.sh"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the logic of entrypoint.sh is to fill in the database connection information, if this line is commentted, then the database connection information will be missed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
数据库连接信息是通过configmap对象提供的,然后通过volumes挂载到容器中,实际上挂载的是文件application-github.properties
请参考文件apollo/scripts/apollo-on-kubernetes/kubernetes/apollo-env-dev/service-apollo-admin-server-dev.yaml
#定义configmap
kind: ConfigMap
apiVersion: v1
metadata:
namespace: sre
name: configmap-apollo-admin-server-dev
data:
application-github.properties: |
spring.datasource.url = jdbc:mysql://service-mysql-for-apollo-dev-env.sre:3306/DevApolloConfigDB?characterEncoding=utf8
spring.datasource.username = FillInCorrectUser
spring.datasource.password = FillInCorrectPassword
eureka.service.url = http://statefulset-apollo-config-server-dev-0.service-apollo-meta-server-dev:8080/eureka/,http://statefulset-apollo-config-server-dev-1.service-apollo-meta-server-dev:8080/eureka/,http://statefulset-apollo-config-server-dev-2.service-apollo-meta-server-dev:8080/eureka/
#创建volumes
volumes:
- name: volume-configmap-apollo-admin-server-dev
configMap:
name: configmap-apollo-admin-server-dev
items:
- key: application-github.properties
path: application-github.properties
#挂载volumes
volumeMounts:
- name: volume-configmap-apollo-admin-server-dev
mountPath: /apollo-admin-server/config/application-github.properties
subPath: application-github.properties
但是为什么出现read-only报错呢?
kubernetes v1.9.3 之后configmap权限默认是只读请参考
文件entrypoint.sh中需要创建application-github.properties,实际上在创建容器的时候该文件就已经通过只读方式挂载了,所以会出现read-only错误。
cat ${admin_server_config}.cp > ${admin_server_config}
综上,数据连接信息通过configmap来注入,就不用entrypoint方式了,这也是kubernetes中推荐的配置和容器解耦的方式。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果确实不需要的话,是否可以直接删除相关的行以及文件?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是的 已经删除提交了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
修复因为Dockerfile中ENTRYPOINT导致运行容器read-only报错 修复多个环境使用同dev环境注册中心导致web管理界面获取admin Server不一致
1 修复因为Dockerfile中ENTRYPOINT导致在k8s中运行容器报错read-only
2 修复多个环境使用同dev环境注册中心导致web管理界面获取admin Server不一致
已经通过测试