我有一个多模块 Maven 项目(Spring Boot),我使用 JIB Maven 插件生成 docker 图像,但是我应该如何在脚手架中命名图像?我推送到本地 docker repo 和 Skaffold afaik 不支持模板。建议在 Skaffold 中引用这些图像是什么?
请记住,对于每个模块的单独图像,我需要将它们命名为:
${image.registry.host}:${image.registry.port}/${project.artifact}
所以别无选择,只能在 pom.xml 中对它们进行参数化。
我现在需要将主机名和端口名放入 skaffold 文件吗?处理这个自动取款机的最佳方法是什么?那么 Kubernetes 部署描述符中的名称呢?
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>${jib-maven-plugin.version}</version>
<configuration>
<!--If you want custom base image and push registry, use below configuration replace above-->
<from>
<image>openjdk:8-jdk-alpine</image>
</from>
<to>
**<image>${image.registry.host}:${image.registry.port}/${project.artifactId}**:${project.version}</image>
</to>
<container>
<jvmFlags>
<jvmFlag>-Djava.security.egd=file:/dev/./urandom</jvmFlag>
<jvmFlag>-Xdebug</jvmFlag>
<jvmFlag>-Duser.timezone=GMT+08</jvmFlag>
</jvmFlags>
<mainClass>com.example.jib.JibApplication</mainClass>
<ports>
<port>8080</port>
</ports>
</container>
<allowInsecureRegistries>true</allowInsecureRegistries>
</configuration>
</plugin>
What goes in the Scaffold.yml for image name?
apiVersion: skaffold/v1beta4
kind: Config
# Enforce SKaffold to use Jib
build:
local:
push: false
# Generated artifact
artifacts:
**- image: lvthillo/my-app. ??????????? HOW SHOULD I NAME THIS?
image: module2/ ???????**
# Use jibMaven
jibMaven: {}
# Execute deployment.yml
deploy:
kubectl:
manifests:
- kubernetes/deployment.yml
这是 Kubernetes 部署描述符。
图片在这里应该有什么名字???
apiVersion: apps/v1
kind: Deployment
metadata:
name: spring-deployment
spec:
replicas: 1
selector:
matchLabels:
app: spring-boot-jib
template:
metadata:
labels:
app: spring-boot-jib
spec:
containers:
- name: spring-boot-jib-pod
**image: lvthillo/my-app. ????????? What name here???**
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 8080
apiVersion: v1
kind: Service
metadata:
name: spring-boot-jib-service
spec:
type: NodePort
ports:
- protocol: TCP
port: 8080
nodePort: 32321
selector:
app: spring-boot-jib