下载jar的包
[root@master test]# wget https://dl.halo.run/relea/halo-1.4.16.jar[root@master ~]# lsanaconda-ks.cfg flannel.yml halo-1.4.16.jar init[root@master ~]#
编写dockerfile并制作镜像
[root@master ~]# mkdir -p test/files[root@master ~]# mv halo-1.4.16.jar test/files/[root@master ~]# cd test/[root@master test]# touch dockerfile[root@master test]# lsdockerfile files[root@master test]# [root@master test]# cat dockerfile from centoscopy files/halo-1.4.16.jar /usr/local/halo-1.4.16.jarentrypoint ["java"化学高一,"-jar","/usr/local/halo-1.4.16.jar"][root@master test]#
[root@master test]# docker build -t 3199560936/halo:v1 .nding build context to docker daemon 79.63mbstep 1/3 : from centos ---> 5d0da3dc9764step 2/3 : copy files/halo-1.4.16.jar /usr/local/halo-1.4.16.jar ---> 099645e57a21step 3/3 : entrypoint ["java","-jar","/usr/local/halo-1.4.16.jar"] ---> running in d1e44734578cremoving intermediate container d1e44734578c ---> a38d07129607successfully built a38d07129607successfully tagged 3199560936/halo:v1[root@master test]# docker imagesrepository tag image id created 信息技术专业 size3199560936/halo v1 a38d07129607 3 conds ago 311mb[root@master test]#
上传镜像到docker仓库
[root@master ~]# docker login[root@master ~]# docker push 3199560936/halo:v1the push refers to rep三氧化二铁什么颜色ository [docker.io/3199560936/halo]5906a49ee250: pushed 74ddd0ec08fa: mounted from library/centos v1: digest: sha256:fb8cb538526b4d73e1a16b9b1b8a3e4ab4b171f0dbaadfbf6673def9620367f2 size: 741[root@master ~]#
编写k8s的资源清单
[root@master test]# cat halo.yml apiversion: apps/v1kind: deploymentmetadata: name: halo labels: app: halospec: replicas: 1 lector: matchlabels: app: halo template: metadata: name: halo labels: app: halo spec: containers: - image: 3199560936/halo:v1 imagepullpolicy: ifnotprent name: halo---apiversion: v1kind: rvicemetadata: name: halospec: ports: - port: 8090 targetport: 8090 nodeport: 32767 lector: app: halo type: nodeport[root@master test]#
创建
[root@master test]# kubectl apply -f halo.ymldeployment.apps/halo createdrvice/halo created
查看
[root@master test]# kubectl get deploy,pod,svcname ready up-to-date available agedeployment.apps/halo 1/1 1 1 32sname ready status restarts agepod/halo-6d4cb5dc7b-nzdpw 1/1 running 0 32sname type cEmbrace the Darknessluster-ip external-ip port(s) agervice/halo nodeport 10.106.13.87 <none> 8090:32767/tcp 32srvice/kubernetes clusterip 10.96.0.1 <none> 443/tcp 46h
使用本机ip:32767访问
到此这篇关于k8s部署java项目的实现的文章就介绍到这了,更多相关k8s部署java项目内容请搜索www.887551.com以前的文章或继续浏览下面的相关文章希望大家以后多多支持www.887551安第斯山脉.com!
本文发布于:2023-04-04 07:58:03,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/eef78f0c9284409c9314caddd1bb7310.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:k8s部署java项目的实现.doc
本文 PDF 下载地址:k8s部署java项目的实现.pdf
留言与评论(共有 0 条评论) |