In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how to deploy the java project in K8s. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Download jar's package
[root@master test] # wget https://dl.halo.run/release/halo-1.4.16.jar[root@master ~] # lsanaconda-ks.cfg flannel.yml halo-1.4.16.jar init [root@master ~] #
Write Dockerfile and make a mirror image
[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 .Sending build context to Docker daemon 79.63MBStep 1 build context to Docker daemon 79.63MBStep 3: FROM centos-- > 5d0da3dc9764Step 2 usr/local/halo-1.4.16.jar 3: COPY files/halo-1.4.16.jar / usr/local/halo-1.4.16.jar-- > 099645e57a21Step 3 usr/local/halo-1.4.16.jar 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 seconds ago 311MB [root@master test] #
Upload images to docker repository
[root@master ~] # docker login [root@master ~] # docker push 3199560936/halo:v1The push refers to repository [docker.io/3199560936/halo] 5906a49ee250: Pushed 74ddd0ec08fa: Mounted from library/centos v1: digest: sha256:fb8cb538526b4d73e1a16b9b1b8a3e4ab4b171f0dbaadfbf6673def9620367f2 size: 741 [root@master ~] #
Write a list of resources for k8s
[root@master test] # cat halo.yml apiVersion: apps/v1kind: Deploymentmetadata: name: halo labels: halospec: replicas: 1 selector: matchLabels: app: halo template: metadata: name: halo labels: app: halospec: containers:-image: 3199560936/halo:v1 imagePullPolicy: IfNotPresent name: halo---apiVersion: v1kind: Servicemetadata: name: halospec: ports:- Port: 8090 targetPort: 8090 nodePort: 32767 selector: app: halo type: NodePort [root@master test] #
Create
[root@master test] # kubectl apply-f halo.ymldeployment.apps/halo createdservice/halo created
View
[root@master test] # kubectl get deploy,pod SvcNAME READY UP-TO-DATE AVAILABLE AGEdeployment.apps/halo 1 Running 1 1 1 32sNAME READY STATUS RESTARTS AGEpod/halo-6d4cb5dc7b-nzdpw 1 Running 0 32sNAME TYPE CLUSTER-IP EXTERNAL-IP PORT (S) AGEservice/halo NodePort 10.106.13.87 8090:32767/TCP 32sservice/kubernetes ClusterIP 10.96.0.1 443/TCP 46h
Access using native IP:32767
Thank you for reading! This is the end of the article on "how to deploy the java project in K8s". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.