From c2d22a196e7849fdd9baea4dfad97a8f34b7f63b Mon Sep 17 00:00:00 2001 From: axzsd Date: Fri, 20 Oct 2023 10:58:33 +0800 Subject: [PATCH] add: road --- builds/Dockerfile-roadbed | 19 +++++ builds/Jenkinsfile-roadbed | 44 ++++++++++ builds/deploy-roadbed.yml | 84 +++++++++++++++++++ pom.xml | 5 +- .../genersoft/iot/vmp/VManageBootstrap.java | 1 - src/main/resources/application-road.yml | 47 +++++++++++ 6 files changed, 198 insertions(+), 2 deletions(-) create mode 100644 builds/Dockerfile-roadbed create mode 100644 builds/Jenkinsfile-roadbed create mode 100644 builds/deploy-roadbed.yml create mode 100644 src/main/resources/application-road.yml diff --git a/builds/Dockerfile-roadbed b/builds/Dockerfile-roadbed new file mode 100644 index 0000000..f9a3141 --- /dev/null +++ b/builds/Dockerfile-roadbed @@ -0,0 +1,19 @@ +FROM openjdk:8u342-slim +LABEL Author="axzsd" \ + Email="atva725@qq.com" \ + Description="智慧涉路作业平台视频WVP" + +WORKDIR /opt + +COPY target/*.jar app.jar + +ENV SPRING_PROFILES_ACTIVE="dev" +ENV JAVA_OPTIONS "-Xms512m -Xmx1024m \ +-Dfile.encoding=UTF-8 \ +-Djava.awt.headless=true \ +-Dsun.net.client.defaultConnectTimeout=10000 \ +-Dsun.net.client.defaultReadTimeout=30000" + + +EXPOSE 80 +ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTIONS -Dspring.profiles.active=${SPRING_PROFILES_ACTIVE} app.jar"] diff --git a/builds/Jenkinsfile-roadbed b/builds/Jenkinsfile-roadbed new file mode 100644 index 0000000..81c6c4f --- /dev/null +++ b/builds/Jenkinsfile-roadbed @@ -0,0 +1,44 @@ +pipeline { + agent any + + environment { + REGISTRY='registry.cn-chengdu.aliyuncs.com' + INTERIOR_REGISTRY='registry-vpc.cn-chengdu.aliyuncs.com' + + IMAGE_NAMESPACE='chkj' + IMAGE_NAME='roadbed-iot-vmp-vmanager' + + DOCKER_FILE="builds/Dockerfile-roadbed" + K8S_FILE="builds/deploy-roadbed.yml" + } + + + stages { + + stage('compile & buildImage->push') { + steps { + withMaven(maven: 'M3', jdk: '8') { + sh 'mvn clean package -pl platform -am -Dmaven.test.skip=true' + } + withDockerServer([credentialsId: 'chkj-docker-client-cert', uri: 'tcp://8.137.98.119']) { + withCredentials([usernamePassword(credentialsId: 'ch-aliyun-registry', passwordVariable: 'DOCKER_PASSWORD', usernameVariable: 'DOCKER_USERNAME')]) { + sh 'echo "$DOCKER_PASSWORD" | docker login $INTERIOR_REGISTRY -u "$DOCKER_USERNAME" --password-stdin' + sh 'docker build -f $DOCKER_FILE -t $INTERIOR_REGISTRY/$IMAGE_NAMESPACE/$IMAGE_NAME:$BUILD_ID .' + sh 'echo "push start..."' + sh 'docker push $INTERIOR_REGISTRY/$IMAGE_NAMESPACE/$IMAGE_NAME:$BUILD_ID' + } + } + } + } + + stage('ack deploy') { + agent none + steps { + configFileProvider([configFile(fileId: '87b5c827-bd51-40af-99f4-31a800614e92', targetLocation: 'K8S-CONFIG', variable: 'KUBECONFIG')]) { + sh 'export tag=$BUILD_ID && envsubst < $K8S_FILE | kubectl apply -f -' + } + } + } + + } +} \ No newline at end of file diff --git a/builds/deploy-roadbed.yml b/builds/deploy-roadbed.yml new file mode 100644 index 0000000..4745ee2 --- /dev/null +++ b/builds/deploy-roadbed.yml @@ -0,0 +1,84 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: roadbed-iot-vmp-vmanager-api + namespace: kube-qa + labels: + app: roadbed-iot-vmp-vmanager-api +spec: + replicas: 1 + selector: + matchLabels: + app: roadbed-iot-vmp-vmanager-api + strategy: + rollingUpdate: + maxSurge: 25% + maxUnavailable: 25% + type: RollingUpdate + template: + metadata: + labels: + app: roadbed-iot-vmp-vmanager-api + spec: + containers: + - name: roadbed-iot-vmp-vmanager-api + image: ${REGISTRY}/${IMAGE_NAMESPACE}/${IMAGE_NAME}:${tag} + imagePullPolicy: Always + ports: + - name: web + containerPort: 80 + protocol: TCP + - name: sip + containerPort: 5060 + env: + - name: TZ + value: Asia/Shanghai + - name: SPRING_PROFILES_ACTIVE + value: road + readinessProbe: + initialDelaySeconds: 20 + periodSeconds: 10 + timeoutSeconds: 10 + httpGet: + scheme: HTTP + port: 80 + path: /actuator/health + resources: + limits: + cpu: 2000m + memory: 1024Gi + requests: + cpu: 100m + memory: 512Mi + volumes: + - name: data-volume + persistentVolumeClaim: + claimName: zhslzy-pvc-nfs + dnsPolicy: ClusterFirst + imagePullSecrets: + - name: ch-aliyun-registry + restartPolicy: Always + securityContext: { } + terminationGracePeriodSeconds: 30 +--- +apiVersion: v1 +kind: Service +metadata: + name: roadbed-iot-vmp-vmanager-api + namespace: kube-qa + labels: + name: roadbed-iot-vmp-vmanager-api +spec: + selector: + app: roadbed-iot-vmp-vmanager-api + type: NodePort + ports: + - name: web + port: 80 + targetPort: web + protocol: TCP + - name: sip + port: 5060 + targetPort: sip + protocol: TCP + nodePort: 5060 \ No newline at end of file diff --git a/pom.xml b/pom.xml index ec4e9c3..6a173f1 100644 --- a/pom.xml +++ b/pom.xml @@ -143,7 +143,10 @@ jedis 2.9.0 - + + org.springframework.boot + spring-boot-starter-actuator + diff --git a/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java b/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java index 664b0d2..ce833f0 100644 --- a/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java +++ b/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java @@ -11,7 +11,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; //@EnableTransactionManagement //@EnableFeignClients(basePackages = { "com.genersoft.iot.vmp", "org.integrain" }) //@ServletComponentScan("com.genersoft.iot.vmp") -@EnableAutoConfiguration public class VManageBootstrap extends LogManager { public static void main(String[] args) { SpringApplication.run(VManageBootstrap.class, args); diff --git a/src/main/resources/application-road.yml b/src/main/resources/application-road.yml new file mode 100644 index 0000000..ee76775 --- /dev/null +++ b/src/main/resources/application-road.yml @@ -0,0 +1,47 @@ +spring: + application: + name: iot-vmp-vmanager + # 影子数据存储方式,支持redis、jdbc + database: redis + # 通信方式,支持kafka、http + communicate: http + redis: + # Redis服务器IP + #host: 10.24.20.63 + host: redis.kube-qa.svc.cluster.local + #端口号 + port: 6379 + database: 1 + #访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接 + password: 20221122@dev + #超时时间 + timeout: 10000 + datasource: + name: eiot + url: jdbc:mysql://mysql.kube-qa.svc.cluster.local:3306/eiot_road?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true + username: root + password: axzsd110 + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: com.mysql.jdbc.Driver +server: + port: 80 +sip: + # ip: 10.200.64.63 + ip: 113.141.178.17 + port: 5060 + # 根据国标6.1.2中规定,domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码(由省级、市级、区级、基层编号组成,参照GB/T 2260-2007) + # 后两位为行业编码,定义参照附录D.3 + # 3701020049标识山东济南历下区 信息行业接入 + domain: 3701020049 + id: 37010200492000000001 + # 默认设备认证密码,后续扩展使用设备单独密码 + password: admin123 +media: + # ip: 10.200.64.88 + ip: zlmediakit-0.zlmediakit.kube-qa.svc.cluster.local + port: 10000 +endpoints: + actuator: + enabled: false + health: + enabled: true