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
Table of contents background CommonsChunkPlugin s...
This article shares the specific code for JavaScr...
Use Javascript to implement a drop-down menu for ...
Table of contents 1. Route navigation 2. History ...
The find command is mainly used to find directori...
This article introduces the sample code of CSS3 t...
Table of contents Preface Basic Introduction Code...
Zabbix Server Environment Platform Version: ZABBI...
1. Implement a simple triangle Using the border i...
Using the CSS3 border-image property, you can set...
MySQL query not using index aggregation As we all...
Table of contents JSON.parse JSON.parse Syntax re...
Table of contents background 1. The query conditi...
Hardware View Commands system # uname -a # View k...
This article describes how to install php7 + ngin...