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

修复导致在k8s中部署中失败的两个地方 #2113

Merged
merged 4 commits into from
Apr 7, 2019
Merged

修复导致在k8s中部署中失败的两个地方 #2113

merged 4 commits into from
Apr 7, 2019

Conversation

sunnoy
Copy link
Contributor

@sunnoy sunnoy commented Apr 5, 2019

1 修复因为Dockerfile中ENTRYPOINT导致在k8s中运行容器报错read-only
2 修复多个环境使用同dev环境注册中心导致web管理界面获取admin Server不一致
已经通过测试

修复多个环境使用同dev环境注册中心导致web管理界面获取admin Server不一致
@codecov-io
Copy link

codecov-io commented Apr 5, 2019

Codecov Report

Merging #2113 into master will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ Complexity Δ
.../apollo/internals/RemoteConfigLongPollService.java 80.36% <0%> (+1.22%) 28% <0%> (+1%) ⬆️

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 f9ebf01...013a8d1. Read the comment docs.

@coveralls
Copy link

coveralls commented Apr 5, 2019

Coverage Status

Coverage increased (+0.008%) to 53.678% when pulling 013a8d1 on sunnoy:master into f9ebf01 on ctripcorp:master.

@@ -24,6 +24,6 @@ ENV DATASOURCES_PASSWORD="FillInCorrectPassword"

EXPOSE 8090

ENTRYPOINT ["/apollo-admin-server/entrypoint.sh"]
#ENTRYPOINT ["/apollo-admin-server/entrypoint.sh"]
Copy link
Member

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?

Copy link
Contributor Author

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中推荐的配置和容器解耦的方式。

Copy link
Member

Choose a reason for hiding this comment

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

如果确实不需要的话,是否可以直接删除相关的行以及文件?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

是的 已经删除提交了

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.

LGTM

@nobodyiam nobodyiam merged commit f0d0a48 into apolloconfig:master Apr 7, 2019
CrackerCat pushed a commit to CrackerCat/apollo-1 that referenced this pull request Jul 31, 2024
修复因为Dockerfile中ENTRYPOINT导致运行容器read-only报错
修复多个环境使用同dev环境注册中心导致web管理界面获取admin Server不一致
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants