13 将项目打包到k8s中
13.1 将项目进行打包
参考: docker 入门到实战(九)springboot 打包到docker
将项目传到阿里云:docker 入门到实战(八)本地镜像发布到阿里云
使用k8s部署镜像
#导出yaml
kubectl create deployment hello --image=registry.cn-shanghai.aliyuncs.com/remzhi/hello:latest --dry-run -o yaml > hello.yaml
#运行yaml
kubectl apply -f hello.yaml
#创建service NodePort 对外访问
kubectl expose deployment hello --port=8080 --target-port=8080 --type=NodePort
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: hello
name: hello
spec:
replicas: 1
selector:
matchLabels:
app: hello
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: hello
spec:
containers:
- image: registry.cn-shanghai.aliyuncs.com/remzhi/hello:latest
name: hello
resources: {}
status: {}