Selaa lähdekoodia

deploy pro/abroadpay:1.0 运行环境prod

pmrd 2 vuotta sitten
vanhempi
commit
b4e288c9eb
3 muutettua tiedostoa jossa 218 lisäystä ja 0 poistoa
  1. 77 0
      .drone.yml
  2. 1 0
      Dockerfile
  3. 140 0
      deploy-tmp.yaml

+ 77 - 0
.drone.yml

@@ -0,0 +1,77 @@
+kind: pipeline
+type: kubernetes
+name: abroadpay
+
+clone:
+  disable: true
+
+metadata:
+  namespace: ci
+
+steps:
+  - name: clone
+    image: hub.evbj.easou.com/dev/alpine-git:20200622
+    commands:
+      - git clone $DRONE_GIT_HTTP_URL .
+
+  - name: deployment
+    image: hub.evbj.easou.com/dev/drone-agent:v3.0.1
+    pull: always
+    # privileged: true
+    environment:
+      JNLP_ENV: pro
+      JNLP_REPLICAS: 2
+      JNLP_TAG: 1.0
+      JNLP_VERSION: v1  # default v1, v2 for canary
+      DEPLOY_ENV: k8s-1 # 可以选择把应用部署到集群: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
+      JNLP_INGRESS_PUB: [EXPOSE]
+    commands:
+      # 切换目标集群
+      - kubecm s $DEPLOY_ENV
+      # 生成配置YAML文件
+      - python3 /root/tools.py -b
+      # 部署服务到kubernetes上
+      - python3 /root/tools.py -a
+      # 添加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 pro/abroadpay:1.0 Success"
+      description: "${DRONE_BUILD_LINK} pro/abroadpay:1.0 部署完成 [DEPLOY_MSG]"
+      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 pro/abroadpay:1.0 Failure"
+      description: "${DRONE_BUILD_LINK} 部署失败,请检查配置![DEPLOY_MSG]"
+      msg_url: ${DRONE_BUILD_LINK}
+      btn_txt: "否"
+    when:
+      status:
+        - failure

+ 1 - 0
Dockerfile

@@ -0,0 +1 @@
+FROM hub.evbj.easou.com/pro/abroadpay:1.0

+ 140 - 0
deploy-tmp.yaml

@@ -0,0 +1,140 @@
+---
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+  name: abroadpay
+  namespace: pro
+  labels:
+    app: abroadpay
+spec:
+  serviceName: abroadpay
+  replicas: 2
+  selector:
+    matchLabels:
+      app: abroadpay
+  template:
+    metadata:
+      labels:
+        app: abroadpay
+    spec:
+      terminationGracePeriodSeconds: 30
+      dnsPolicy: None
+      dnsConfig:
+        nameservers:
+          - 223.5.5.5
+          - 10.26.22.50
+      initContainers:
+        - name: init
+          image: hub.evbj.easou.com/dev/busybox
+          command: [ "chmod","777","-R","/data" ]
+          imagePullPolicy: IfNotPresent
+          volumeMounts:
+            - name: volume
+              mountPath: /data
+      #nodeSelector:
+      #  app.touchrs: touchrs
+      #      affinity:
+      #        podAntiAffinity:
+      #          preferredDuringSchedulingIgnoredDuringExecution:
+      #          - weight: 100
+      #            podAffinityTerm:
+      #              labelSelector:
+      #                matchExpressions:
+      #                - key: app
+      #                  operator: In
+      #                  values:
+      #                  - abroadpay
+      #              topologyKey: kubernetes.io/hostname
+      containers:
+        - name: abroadpay
+          image: hub.evbj.easou.com/pro/abroadpay:1.0
+          imagePullPolicy: IfNotPresent
+          env:
+            - name: MY_NODE_NAME
+              valueFrom:
+                fieldRef:
+                  fieldPath: spec.nodeName
+            - name: MY_POD_IP
+              valueFrom:
+                fieldRef:
+                  fieldPath: status.podIP
+            - name: MY_POD_NAME
+              valueFrom:
+                fieldRef:
+                  fieldPath: metadata.name
+            - name: MY_POD_NAMESPACE
+              valueFrom:
+                fieldRef:
+                  fieldPath: metadata.namespace
+            - name: JAVA_OPTS
+              value: "-server  -Xmx2g -Xms2g -Xss512k -Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom -Dspring.profiles.active=prod"
+          ports:
+            - containerPort: 6700
+              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: /common/gip
+              port: 6700
+            initialDelaySeconds: 40        #60s后启动第一次探测
+            periodSeconds: 15              # 每隔10s启动一次探测
+            timeoutSeconds: 3              # 超时时间3s
+            successThreshold: 1            # 成功1次即表示容器健康
+            failureThreshold: 5            # 连续5次失败,则判定容器不健康,默认3次
+          readinessProbe:
+            tcpSocket:
+              port: 6700
+            initialDelaySeconds: 40
+            periodSeconds: 15
+  volumeClaimTemplates:
+    - metadata:
+        name: volume
+      spec:
+        accessModes: [ "ReadWriteOnce" ]
+        storageClassName: rbd
+        resources:
+          requests:
+            storage: 100Gi
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: abroadpay-svc
+  namespace: pro
+  labels:
+    app: abroadpay-svc
+spec:
+  type: NodePort
+  ports:
+    - port: 80
+      targetPort: 8080
+      name: "main"
+  selector:
+    app: abroadpay
+---
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+  name: abroadpay-ingress
+  namespace: pro
+spec:
+  rules:
+    - host: pro-abroadpay.ieasou.cn
+      http:
+        paths:
+            - path: /
+              pathType: Prefix
+              backend:
+                service:
+                  name: abroadpay-svc
+                  port:
+                    number: 8080
+  ingressClassName: nginx