当前位置: 首页 > article >正文

k8s部署springboot项目

1.Dockerfile

FROM base/jre1.8-chinese:latest

ENV HOME /app

##设置控制台字符集编码
ENV LANG C.UTF-8
###设置docker容器的时间
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

ADD earthquake-resp-creator-0.0.1-SNAPSHOT.jar ${HOME}/earthquake-resp-creator-0.0.1-SNAPSHOT.jar

WORKDIR ${HOME}
EXPOSE 8083
ENTRYPOINT ["java","-jar","-Xms2048m", "-Xmx4096m","earthquake-resp-creator-0.0.1-SNAPSHOT.jar","--spring.config.local=application.properties"]

2.yaml文件

apiVersion: v1
kind: ConfigMap
metadata:
  name: earthquake-resp-creator
  namespace: dz-piecloud-business
data:
  application.properties: |
    server.port=8083
    server.servlet.context-path=/v1/resp/creator
    spring.datasource.driver-class-name=org.postgresql.Driver
    spring.datasource.url=jdbc:postgresql://*.*.*.*:*/db_base?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
    spring.datasource.username=
    spring.datasource.password=
    # mybatis
    mybatis.mapper-locations=classpath:/Mapper/*.xml
    mybatis.type-aliases-package=cn.piesat.entity
    mybatis.configuration.map-underscore-to-camel-case=true
    mybatis.configuration.call-setters-on-nulls=true

    mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl

    generate.resp.file.py=/pie/data/earthquake-share/common-transform/generate_resp_file.py
    resp.file.out.path=/pie/data/earthquake-share/resp/respOut
    json.out.path=/pie/data/earthquake-share/resp/jsonOut
    # resp.file.out.path=/data/dz-server/common-services/earthquake-resp-creator/out/respOut
    # json.out.path=/data/dz-server/common-services/earthquake-resp-creator/out/jsonOut
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: earthquake-resp-creator
  namespace: dz-piecloud-business
spec:
  replicas: 1
  selector:
    matchLabels:
      name: earthquake-resp-creator
  template:
    metadata:
      labels:
        name: earthquake-resp-creator
    spec:
      nodeSelector:
        dz-business-common: "true"
      hostAliases:
      - ip: "*.*.*.*"
        hostnames:
        - "myhbase"
      containers:
        - name: earthquake-resp-creator
          image: dz-server/earthquake-resp-creator:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 8083
          volumeMounts:
            - name: configmap-volume
              mountPath: /app/application.properties
              subPath: application.properties
            - name: data
              mountPath: /pie/data
            - name: out
              mountPath: /data
      volumes:
        - name: configmap-volume
          configMap:
            name: earthquake-resp-creator
            items:
              - key: application.properties
                path: application.properties
        - name: data
          hostPath:
            path: /pie/data
        - name: out
          hostPath:
            path: /data
---
apiVersion: v1
kind: Service
metadata:
  namespace: dz-piecloud-business
  name: earthquake-resp-creator
  labels:
    app: earthquake-resp-creator
spec:
  type: NodePort
  selector:
    name: earthquake-resp-creator
  ports:
    - port: 8083
      targetPort: 8083
      nodePort: 31173

3.restart.sh

#!/bin/bash
kubectl delete -f earthquake-resp-creator.yaml
sleep 3
docker rmi -f dz-server/earthquake-resp-creator:latest
docker build -t dz-server/earthquake-resp-creator:latest .
docker push dz-server/earthquake-resp-creator:latest
kubectl apply -f earthquake-resp-creator.yaml



http://www.kler.cn/a/311986.html

相关文章:

  • 算法训练(leetcode)二刷第二十三天 | 455. 分发饼干、*376. 摆动序列、53. 最大子数组和
  • 文件上传漏洞--理论
  • EDUCODER头哥 基于MVC模式的用户登录
  • IDEA 如何手动创建spring boot工程
  • 【架构论文-1】面向服务架构(SOA)
  • MIT 6.S081 Lab1: Xv6 and Unix utilities翻译
  • Vue3 : Pinia的性质与作用
  • Pandas与Matplotlib:Python中的动态数据可视化
  • 计算机专业的就业方向
  • Vue 3 中 `$emit` 的使用示例
  • 最新Kali Linux超详细安装教程(附镜像包)
  • go 实现操作mysql并且防止sql注入
  • 从《中国数据库前世今生》看中国数据库技术的发展与挑战
  • C#使用实体类Entity Framework Core操作mysql入门:从数据库反向生成模型
  • 【AI】简单了解AIGC与ChatGPT
  • VUE项目运行npm run dev命令后,自动打开浏览器导航到主页
  • flink 批量写clickhouse
  • SQL 查询语句汇总
  • 金砖软件测试赛项之Jmeter如何录制脚本!
  • 算法训练——day18 两数之和三数之和
  • 力扣春招100题——队列
  • Acwing 堆
  • 【QT】基于HTTP协议的网络应用程序
  • docker构建java镜像,运行镜像出现日志 no main manifest attribute, in /xxx.jar
  • 大模型-模型架构-新型模型架构
  • 程序员常用开发软件集合