13 将项目打包到k8s中

13.1 将项目进行打包

参考: docker 入门到实战(九)springboot 打包到docker
image.png
将项目传到阿里云:docker 入门到实战(八)本地镜像发布到阿里云
image.png
使用k8s部署镜像

  1. #导出yaml
  2. kubectl create deployment hello --image=registry.cn-shanghai.aliyuncs.com/remzhi/hello:latest --dry-run -o yaml > hello.yaml
  3. #运行yaml
  4. kubectl apply -f hello.yaml
  5. #创建service NodePort 对外访问
  6. kubectl expose deployment hello --port=8080 --target-port=8080 --type=NodePort
  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. creationTimestamp: null
  5. labels:
  6. app: hello
  7. name: hello
  8. spec:
  9. replicas: 1
  10. selector:
  11. matchLabels:
  12. app: hello
  13. strategy: {}
  14. template:
  15. metadata:
  16. creationTimestamp: null
  17. labels:
  18. app: hello
  19. spec:
  20. containers:
  21. - image: registry.cn-shanghai.aliyuncs.com/remzhi/hello:latest
  22. name: hello
  23. resources: {}
  24. status: {}

image.png
image.png