yangxg 3 lat temu
rodzic
commit
794c17411e
7 zmienionych plików z 367 dodań i 0 usunięć
  1. 1 0
      Dockerfile
  2. 1 0
      Dockerfile-template
  3. 3 0
      README.md
  4. 8 0
      build/Dockerfile
  5. 97 0
      deploy-tmp-template.yaml
  6. 165 0
      deploy-tmp.yaml
  7. 92 0
      drone.template.yml

+ 1 - 0
Dockerfile

@@ -0,0 +1 @@
+FROM hub.evbj.easou.com/qa/offline-process-charge:v1.1.17

+ 1 - 0
Dockerfile-template

@@ -0,0 +1 @@
+FROM hub.evbj.easou.com/[ENV]/[APP]:[TAG]

+ 3 - 0
README.md

@@ -0,0 +1,3 @@
+# offline-process-charge
+
+!!不要手动修改此仓库的任何文件,依赖于vipbook-backend-deploy脚本部署

+ 8 - 0
build/Dockerfile

@@ -0,0 +1,8 @@
+FROM hub.evbj.easou.com/pro/base-alpine:v1.0
+VOLUME /tmp
+ARG JAR_FILE
+COPY ${JAR_FILE} app.jar
+EXPOSE 8080
+#JAVA_OPTS="-server -Xmx2g -Xms2g -Xss512k -Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom "
+#DEBUG_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8001,suspend=n "
+ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -jar -Dlogging.config=classpath:logback-k8s.xml -Dserver.port=8080 app.jar"]

+ 97 - 0
deploy-tmp-template.yaml

@@ -0,0 +1,97 @@
+---
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+  name: [APP]
+  namespace: [ENV]
+  labels:
+    app: [APP]
+spec:
+  serviceName: [APP]
+  replicas: [REPLICA]
+  selector:
+    matchLabels:
+      app: [APP]
+  template:
+    metadata:
+      labels:
+        app: [APP]
+    spec:
+      terminationGracePeriodSeconds: 60
+      initContainers:
+        - name: init
+          image: hub.evbj.easou.com/dev/busybox
+          command: [ "chmod","777","-R","/data" ]
+          imagePullPolicy: Always
+          volumeMounts:
+            - name: volume
+              mountPath: /data
+      #nodeSelector:
+      #  app.touchrs: touchrs
+      containers:
+        - name: [APP]
+          image: hub.evbj.easou.com/[ENV]/[APP]:[TAG]
+          imagePullPolicy: Always
+          env:
+            - name: JAVA_OPTS
+              value: "-server [DEBUG_OPTS] -Xmx2g -Xms2g -Xss512k -Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom -Dspring.profiles.active=[PROFILE]"
+          ports:
+            - containerPort: 8080
+              name: port
+            - containerPort: 8001
+              name: "jvm-debug"
+          volumeMounts:
+            - name: volume
+              mountPath: /data
+          livenessProbe:
+            tcpSocket:
+              port: 8080
+            initialDelaySeconds: 30
+            periodSeconds: 15
+          readinessProbe:
+            tcpSocket:
+              port: 8080
+            initialDelaySeconds: 30
+            periodSeconds: 15
+  volumeClaimTemplates:
+    - metadata:
+        name: volume
+      spec:
+        accessModes: [ "ReadWriteOnce" ]
+        storageClassName: rbd
+        resources:
+          requests:
+            storage: 100Gi
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: [APP]-svc
+  namespace: [ENV]
+  labels:
+    app: [APP]-svc
+spec:
+  type: NodePort
+  ports:
+    - port: 80
+      targetPort: 8080
+      name: "main"
+  selector:
+    app: [APP]
+---
+apiVersion: extensions/v1beta1
+kind: Ingress
+metadata:
+  name: [APP]-ingress
+  namespace: [ENV]
+  annotations:
+    kubernetes.io/ingress.class: nginx
+spec:
+  rules:
+    - host: [APP]-[ENV].ieasou.cn
+      http:
+        paths:
+          - path: /
+            backend:
+              serviceName: [APP]-svc
+              servicePort: 80

+ 165 - 0
deploy-tmp.yaml

@@ -0,0 +1,165 @@
+---
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+  name: offline-process-charge
+  namespace: qa
+  labels:
+    app: offline-process-charge
+spec:
+  serviceName: offline-process-charge
+  replicas: 1
+  selector:
+    matchLabels:
+      app: offline-process-charge
+  template:
+    metadata:
+      labels:
+        app: offline-process-charge
+    spec:
+      terminationGracePeriodSeconds: 60
+      initContainers:
+        - name: init
+          image: hub.evbj.easou.com/dev/busybox
+          command: [ "chmod","777","-R","/data" ]
+          imagePullPolicy: Always
+          volumeMounts:
+            - name: volume
+              mountPath: /data
+      #nodeSelector:
+      #  app.touchrs: touchrs
+      containers:
+        - name: offline-process-charge
+          image: hub.evbj.easou.com/qa/offline-process-charge:v1.1.17
+          imagePullPolicy: Always
+          env:
+            - name: JAVA_OPTS
+              value: "-server  -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8001,suspend=n  -Xmx2g -Xms2g -Xss512k -Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom -Dspring.profiles.active=test"
+          ports:
+            - containerPort: 8080
+              name: port
+            - containerPort: 8001
+              name: "jvm-debug"
+          volumeMounts:
+            - name: volume
+              mountPath: /data
+          lifecycle:
+            preStop:
+              exec:
+                command: ["/bin/sh","-c","curl -H 'loginName:admin -H password:ea1so2ua3dm4in5' -X POST 127.0.0.1:8080/actuator/shutdown"]
+          livenessProbe:
+            httpGet:
+              path: /actuator/health
+              port: 8080
+              httpHeaders:
+                - name: loginName
+                  value: admin
+                - name: password
+                  value: ea1so2ua3dm4in5
+            initialDelaySeconds: 30        #60s后启动第一次探测
+            periodSeconds: 10              # 每隔10s启动一次探测
+            timeoutSeconds: 3              # 超时时间3s
+            successThreshold: 1            # 成功1次即表示容器健康
+            failureThreshold: 5            # 连续5次失败,则判定容器不健康,默认3次
+          readinessProbe:
+            tcpSocket:
+              port: 8080
+            initialDelaySeconds: 30
+            periodSeconds: 15
+        - image: docker.elastic.co/beats/filebeat:6.8.12
+          imagePullPolicy: Always
+          name: filebeat
+          volumeMounts:
+            - name: volume #日志同时挂载在nginx和filebeat中
+              mountPath: /data
+            - name: filebeat-config
+              mountPath: /usr/share/filebeat/filebeat.yml
+              subPath: filebeat.yml
+      volumes:
+        - name: filebeat-config
+          configMap:
+            name: filebeat-config-offline-process-charge
+            items:
+              - key: filebeat.yml
+                path: filebeat.yml
+
+  volumeClaimTemplates:
+    - metadata:
+        name: volume
+      spec:
+        accessModes: [ "ReadWriteOnce" ]
+        storageClassName: rbd
+        resources:
+          requests:
+            storage: 100Gi
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: offline-process-charge-svc
+  namespace: qa
+  labels:
+    app: offline-process-charge-svc
+spec:
+  type: NodePort
+  ports:
+    - port: 80
+      targetPort: 8080
+      name: "main"
+  selector:
+    app: offline-process-charge
+---
+apiVersion: extensions/v1beta1
+kind: Ingress
+metadata:
+  name: offline-process-charge-ingress
+  namespace: qa
+  annotations:
+    kubernetes.io/ingress.class: nginx
+spec:
+  rules:
+    - host: qa-offline-process-charge.ieasou.cn
+      http:
+        paths:
+          - path: /
+            backend:
+              serviceName: offline-process-charge-svc
+              servicePort: 80
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: filebeat-config-offline-process-charge
+  namespace: qa
+data:
+  filebeat.yml: |
+    filebeat.inputs:
+    - type: log
+      enabled: true
+      #多行合并
+      multiline.pattern: '^\[[0-9]{4}-[0-9]{2}-[0-9]{2}'
+      multiline.negate: true
+      multiline.match: after
+      multiline.timeout: 30
+      fields:
+          log_topic: offline-process-charge
+      fields_under_root: true
+      paths:
+        - "/data/logs/app/*.log"
+        - "/data/logs/*.log"
+    setup.template.enabled: true
+    setup.template.name: offline-process-charge
+    setup.template.pattern: offline-process-charge*
+    setup.dashboards.enabled: true
+    output.kafka:
+      version: 0.10.2.1
+      enable: true
+      hosts: ["kafka-0.kafka-svc.qa.svc.cluster.local:9093", "kafka-1.kafka-svc.qa.svc.cluster.local:9093", "kafka-2.kafka-svc.qa.svc.cluster.local:9093"]
+      topic: 'offline-process-topic'
+      partition.round_robin:
+        reachable_only: false
+      required_acks: 0
+      compression: gzip
+      max_message_bytes: 1000000
+    setup.kibana:
+      host: 'qa-kibana.ieasou.cn:80'

+ 92 - 0
drone.template.yml

@@ -0,0 +1,92 @@
+kind: pipeline
+type: kubernetes
+name: [APP]
+
+clone:
+  disable: true
+
+metadata:
+  namespace: drone
+
+steps:
+- name: clone
+  image: hub.evbj.easou.com/dev/alpine-git:20200622
+  commands:
+   - git clone $DRONE_GIT_HTTP_URL .
+
+- name: build
+  image: plugins/docker
+  settings:
+    username: admin
+    password: Easou2)1*
+    insecure: true
+    mirror: https://ci7pm4nx.mirror.aliyuncs.com
+    registry: hub.evbj.easou.com
+    repo: hub.evbj.easou.com/[ENV]/[APP]
+    tag: [TAG]
+#    build_args:
+#      - JAR_FILE=[JAR_FILE]
+#      - SERVER_PORT=8080
+
+- name: deployment
+  image: hub.evbj.easou.com/dev/drone-agent:v2.0.0
+  pull: always
+  # privileged: true
+  environment:
+    JNLP_ENV: [ENV]
+    JNLP_REPLICAS: [REPLICA]
+    JNLP_TAG: [TAG]
+    JNLP_VERSION: v1  # default v1, v2 for canary
+    DEPLOY_ENV: k8s-2 # 可以选择把应用部署到集群:k8s-1 or k8s-2
+    JNLP_REPO: hub.evbj.easou.com
+    JNLP_CONTAINER_PORT: 80
+    JNLP_INGRESS: nginx
+    JNLP_SVC_MODE: http
+    JNLP_STORAGE_CLASS: rbd
+    JNLP_DOMAIN: .ieasou.cn
+    JNLP_CONTROL: StatefulSet
+    JNLP_STORAGE_CAPACITY: 100Gi
+    JNLP_MOUNT_PATH: /data
+    JNLP_LIVENESS_INIT: 30
+    JNLP_LIVENESS_PER: 15
+    JNLP_READINESS_INIT: 30
+    JNLP_READINESS_PER: 15
+  commands:
+    # 切换目标集群
+    - kubecm s $DEPLOY_ENV
+    # 生成配置YAML文件
+    - python3 /root/tools.py -b
+    # 部署服务到kubernetes上
+    - python3 /root/tools.py -a
+    # 检查服务部署状态
+    - python3 /root/tools.py -c
+    # 添加dns解析记录,生成访问域名
+    - python3 /root/tools.py -d
+
+- name: success
+  image: hub.evbj.easou.com/dev/drone-wechat:20200622
+  settings:
+    corpid: ww419ee4063735e1c0
+    corp_secret: zpiRBLETH9eLwIMQ4eJ_r_dcm3BPSGeLHvTcft8Ot-M
+    agent_id: 1000004
+    title: "Pipeline [ENV]/[APP]:[TAG] Success"
+    description: "${DRONE_BUILD_LINK} [ENV]/[APP]:[TAG] 部署完成"
+    msg_url: ${DRONE_BUILD_LINK}
+    btn_txt: "否"
+  when:
+    status:
+     - success
+
+- name: failure
+  image: hub.evbj.easou.com/dev/drone-wechat:20200622
+  settings:
+    corpid: ww419ee4063735e1c0
+    corp_secret: zpiRBLETH9eLwIMQ4eJ_r_dcm3BPSGeLHvTcft8Ot-M
+    agent_id: 1000004
+    title: "Pipeline [ENV]/[APP]:[TAG] Failure"
+    description: "${DRONE_BUILD_LINK} 部署失败,请检查配置!"
+    msg_url: ${DRONE_BUILD_LINK}
+    btn_txt: "否"
+  when:
+    status:
+     - failure