如何使用 Jenkins 在没有 docker 的情况下将 Spring Boot 应用程序部署到 Kubernetes?
在我们的项目中,我们使用旧的和废弃的 docker 插件:
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.0</version>
<configuration>
<imageName>${docker.image.name}</imageName>
<imageTags>
<imageTag>${project.version}</imageTag>
<imageTag>latest</imageTag>
</imageTags>
<dockerDirectory>${basedir}/target/dockerfile</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
Jenkins 使用 docker 中的 docker 技术将应用程序部署到 kubernetes。
问题是新版本的kubernetes只包含containerd而没有docker。我不确定边界在哪里,什么仍然是containerd的一部分,什么不是(例如dockerfile)。是否已经有了如何在没有 docker 的情况下将应用程序部署到 kubernetes 的概念?
更新
我确信同样的工作不会工作,因为在 Jenkins 容器中我们正在安装 docker sock:
containers:
- name: all
image: ...
command:
- cat
tty: true
volumeMounts:
- name: m2
mountPath: /root/.m2
- name: dockersock
mountPath: /var/run/docker.sock
volumes:
- name: dockersock
hostPath:
path: /var/run/docker.sock
- name: m2
hostPath:
path: /jenkins
In our project we are using old and depraceted docker plugin:
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.0</version>
<configuration>
<imageName>${docker.image.name}</imageName>
<imageTags>
<imageTag>${project.version}</imageTag>
<imageTag>latest</imageTag>
</imageTags>
<dockerDirectory>${basedir}/target/dockerfile</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
and Jenkins deploy application using technology docker in docker to kubernetes.
Problem is that new version of kubernetes contains just containerd without docker. I am not sure where are the boundary and what is still part of containerd and what not (for example dockerfile) . Is there already concept how to deploy application to kubernetes without docker ?
UPDATE
I am sure that same job will not work because in Jenkins container we are mounting docker sock:
containers:
- name: all
image: ...
command:
- cat
tty: true
volumeMounts:
- name: m2
mountPath: /root/.m2
- name: dockersock
mountPath: /var/run/docker.sock
volumes:
- name: dockersock
hostPath:
path: /var/run/docker.sock
- name: m2
hostPath:
path: /jenkins
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无需担心:您无需关心集群内运行的容器运行时,只要它可以在 OCI 或 docker 镜像上运行即可。将实际的容器运行时视为实现细节。
这是与构建映像不同的主题。甚至还有像 Jib 或 Kaniko 这样的替代方案来使用 docker 守护进程和 Dockerfile。
如果您使用 jenkins 和 docker-as-a-container 构建镜像(docker-in-docker 只是一种选择),您甚至应该能够保持原样。
No need to worry: You don't need to care what container runtime is running inside your cluster, as long as it can operate on OCI or docker images. Consider the actual container runtime an implementation detail.
This is a separate topic from building the image. Even there are alternatives like Jib or Kaniko to using the docker daemon and a Dockerfile.
If you are building your images with jenkins and docker-as-a-container (docker-in-docker beeing just one option) you should be able to even keep that as it is.