当前位置: 首页 > 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/news/311986.html

相关文章:

  • 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
  • 大模型-模型架构-新型模型架构
  • 程序员常用开发软件集合
  • AirTest 基本操作范例和参数解释(一)
  • 第157天: 安全开发-Python 自动化挖掘项目SRC 目标FOFA 资产Web 爬虫解析库
  • 缓存穿透 问题(缓存空对象)
  • C++ 中std::promise和std::future基本使用
  • OpenCV基础入门30讲(Python)——第二讲 图像色彩转换
  • 卷积参数量计算公式
  • GO主流开源框架
  • python测试开发---js基础
  • 网工请注意!华为认证笔试考试系统升级公告!
  • Matlab Delany-Bazley和Miki模型预测多孔材料吸声性能