K8S 如何部署SpringBoot项目
1:首先,需要安装docker环境,以及安装Harbor仓库
2:安装K8S集群环境
3:进行docker镜像的制作并上传到仓库
4: 进行容器的编排。启动
至此就可以了。
创建dockertest.yaml文件如下
imageapiVersion: v1
kind: Service
metadata:
name: spring-boot-docker
namespace: default
labels:
app: spring-boot-docker
spec:
type: NodePort
ports:
- port: 8099
nodePort: 30090
selector:
app: spring-boot-docker
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: spring-boot
labels:
app: spring-boot
spec:
replicas: 1
selector:
matchLabels:
app: spring-boot
template:
metadata:
labels:
app: spring-boot
spec:
containers:
- name: spring-boot-docker
image: 192.168.x.240/test_dev/spring-boot:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8099
运行kubectl create -f dockertest.yaml
创建Deployment , Service
kubectl create -f dockertest.yaml
运行kubectl logs -f podsname
查看日志
kubectl logs -f xxxxxxx
网友评论