一、新建springboot项目
在pom.xml文件添加
注意:springboot自带的spring-boot-maven-plugin不要删,否则会找不到manifast文件。
二、建立自己的镜像:
Dockerfile
在服务器上安装docker和k8s,参考
https://kuboard.cn/install/install-dashboard.html 并敲入
注意:xxx是你的Docker ID,先在Docker hub上注册一个你的账号
三、使k8s所有机器都能pull你的镜像:
上传dockerhub(要带标签,且镜像Docker ID/镜像名的命名方式):
在其他k8s(非master)上面pull下来这个镜像:
四、建立deployment.yaml
执行:
五、建立service
执行:
六、访问,成功!