原生kubesphere
的B2I镜像不太满足我们实际的业务需求,针对B2I镜像我们做了一些本地化内容
1. 镜像内添加Arthas
镜像内置 Arthas , 便于调试。
ADD arthas.tar.gz .
当然,这样做不太符合容器设计模式,不应将非业务性内容添加至业务容器内,比较合理的做法就是将这些工具类的内容打包为debug镜像,作为sidecar
容器运行。但不得不承认打包在一起管理起来更为方便。
2. 镜像内添加skywalking-agent
为了方便集成链路追踪,我们在基础镜像内置了skywalking-agent
RUN mkdir -p /app/plugins/skywalking
ADD skywalking-agent.tar.gz /app/plugins/skywalking
3.调整jvm参数
jvm参数在原有的基础上添加以下内容
# 时区
-Duser.timezone=GMT+08
# skywalking agent
-javaagent:/app/plugins/skywalking/skywalking-agent/skywalking-agent.jar=agent.service_name=${SW_AGENT_NAME},collector.backend_service=skywalking-oap.${SW_OAP_NAMESPACE:-serviceA}:11800
针对实际需求,我们拓展了B2I基础镜像(比如字体、openoffice等),并在部署阶段调整B2I配置,最终B2I配置如下:
java
...
spec:
codeFramework: java
containerInfo:
- buildVolumes:
- 's2i_java_cache:/tmp/artifacts'
builderImage: 'harbor.wl.io/b2i/java-8-centos7:base'
runtimeArtifacts:
- source: /deployments
runtimeImage: 'harbor.wl.io/b2i/java-8-runtime:base'
- buildVolumes:
- 's2i_java_cache:/tmp/artifacts'
builderImage: 'harbor.wl.io/b2i/java-8-centos7:advance'
runtimeArtifacts:
- source: /deployments
runtimeImage: 'harbor.wl.io/b2i/java-8-runtime:advance'
- buildVolumes:
- 's2i_java_cache:/tmp/artifacts'
builderImage: 'harbor.wl.io/b2i/java-8-centos7:base'
runtimeArtifacts:
- source: /deployments
runtimeImage: 'harbor.wl.io/b2i/java-8-runtime:base'
defaultBaseImage: 'harbor.wl.io/b2i/java-8-centos7:base'
...
tomcat
...
spec:
codeFramework: java
containerInfo:
- buildVolumes:
- 's2i_java_cache:/tmp/artifacts'
builderImage: harbor.wl.io/b2i/tomcat8-java8-centos7
runtimeArtifacts:
- source: /deployments
runtimeImage: harbor.wl.io/b2i/tomcat8-java8-runtime
- buildVolumes:
- 's2i_java_cache:/tmp/artifacts'
builderImage: harbor.wl.io/b2i/tomcat9-java8-centos7
runtimeArtifacts:
- source: /deployments
runtimeImage: harbor.wl.io/b2i/tomcat9-java8-runtime
defaultBaseImage: harbor.wl.io/b2i/tomcat8-java8-centos7
...
网友评论