1 Introduction After "Maven deploys Springboot to Docker repository with one click to prepare for automation", 2 One-click deployment of Springboot 2.1 Prepare the YAML file Once the image file is prepared, it is very easy to deploy it to apiVersion: apps/v1 kind: Deployment metadata: name: pkslow-springboot-deployment spec: selector: matchLabels: app: springboot replicas: 2 template: metadata: labels: app: springboot spec: containers: - name: springboot image: pkslow/springboot-mongo:0.0.6 ports: - containerPort: 8080 --- apiVersion: v1 kind: Service metadata: labels: app: springboot name: pkslow-springboot-service spec: ports: - port: 8080 name: springboot-service protocol: TCP targetPort: 8080 nodePort: 30080 selector: app: springboot type: NodePort 2.2 Deployment through kubectl command Once the $ kubectl create -f pksow-springboot.yaml deployment.apps/pkslow-springboot-deployment created service/pkslow-springboot-service created The console log shows that Access the Check it out via the command line: $ kubectl get deployment NAME READY UP-TO-DATE AVAILABLE AGE pkslow-springboot-deployment 2/2 2 2 8m2s $ kubectl get service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 10m pkslow-springboot-service NodePort 10.102.218.119 <none> 8080:30080/TCP 8m7s $ kubectl get pod NAME READY STATUS RESTARTS AGE pkslow-springboot-deployment-68dffc6795-874tp 1/1 Running 0 8m15s pkslow-springboot-deployment-68dffc6795-89xww 1/1 Running 0 8m15s So far, we have successfully released 2.3 Try killing a pod? The smallest management element Let's try deleting a $ kubectl delete pod pkslow-springboot-deployment-68dffc6795-89xww pod "pkslow-springboot-deployment-68dffc6795-89xww" deleted $ kubectl get pod NAME READY STATUS RESTARTS AGE pkslow-springboot-deployment-68dffc6795-874tp 1/1 Running 0 13m pkslow-springboot-deployment-68dffc6795-gpw67 1/1 Running 0 46s It can be found that after deleting another 2.4 Try killing a container? Let's explore what happens if we kill a container instance. $ docker ps $ docker rm -f 57869688a226 57869688a226 $ docker ps After experimenting, we found that after killing a container, a new container instance will be automatically generated for us. 2.5 Rapid Pod Expansion When the number of user requests increases suddenly and the service cannot cope with it, the number of $ kubectl apply -f pksow-springboot.yaml Check 3 One-click deployment of Nginx If you don't have a apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: selector: matchLabels: app: nginx replicas: 3 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.19.0 ports: - containerPort: 80 --- apiVersion: v1 kind: Service metadata: labels: app: nginx name: nginx-service spec: ports: - port: 80 name: nginx-service1 protocol: TCP targetPort: 80 nodePort: 30000 - port: 81 name: nginx-service2 protocol: TCP targetPort: 80 nodePort: 30001 selector: app: nginx type: NodePort Execute the deployment command: $ kubectl apply -f nginx-deployment-scale.yaml deployment.apps/nginx-deployment created service/nginx-service created View Access the service at http://localhost:30000/ or http://localhost:30001. Because we set up two. 4 Conclusion This article uses two examples to give you a perceptual understanding of This is the end of this article about deploying Springboot or Nginx with Kubernetes. For more information about deploying Springboot or Nginx with Kubernetes, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
>>: JavaScript to achieve fancy carousel effect
1. Principle of Hotlinking 1.1 Web page preparati...
The specific code for using jQuery to implement t...
Table of contents Scene Introduction Deep respons...
In the previous article, we introduced how to use...
introduction Looking back four years ago, when I ...
Table of contents Function Introduction function ...
css-vars-ponyfill When using CSS variables to ach...
Introduction Linux is a system that can automatic...
At the end of last year, I replaced the opensuse ...
Today's Tasks 1. Choice of Linux distribution...
Table of contents 1 Question 2 Methods 3 Experime...
Step 1: Confirm the architecture of your system d...
Preface If you are like me, as a hard-working Jav...
In a complex table structure, some cells span mul...
Table of contents Variable Scope The concept of c...