瀏覽代碼

first commit

duyangang 2 年之前
當前提交
a3bc3cfb37
共有 2 個文件被更改,包括 180 次插入0 次删除
  1. 81 0
      .drone.yml
  2. 99 0
      deploy-tmp.yaml

+ 81 - 0
.drone.yml

@@ -0,0 +1,81 @@
+kind: pipeline
+type: kubernetes
+name: ums
+
+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-1129 #hub.evbj.easou.com/dev/drone-agent:v3.0.1-1128 #hub.evbj.easou.com/dev/drone-agent:v3.0.1
+    pull: always
+    # privileged: true
+    environment:
+      JNLP_ENV: datagroup-pro #datagroup-qa OR datagroup-pro  
+      JNLP_ACTIVE_PROFILE: pro #test OR pro
+      JNLP_TAG: v3.9.10
+      JNLP_REPLICAS: 1
+      JNLP_JAVA_OPTS: -XX:PermSize=512M -XX:MaxPermSize=512M -Xms2048M -Xmx2048M
+      JNLP_VERSION: v1  # default v1, v2 for canary
+      DEPLOY_ENV: k8s-3 # 可以选择把应用部署到集群:k8s-1(Aliyun) or k8s-2(Qingdao)
+      JNLP_REPO: hub.evbj.easou.com
+      JNLP_CONTAINER_PORT: 8080
+      JNLP_INGRESS: nginx
+      JNLP_SVC_MODE: http
+      JNLP_STORAGE_CLASS: rbd
+      JNLP_DOMAIN: .ieasou.cn
+      JNLP_CONTROL: StatefulSet
+      JNLP_STORAGE_CAPACITY: 10Gi
+      JNLP_MOUNT_PATH: /data
+      JNLP_LIVENESS_INIT: 50
+      JNLP_LIVENESS_PER: 15
+      JNLP_READINESS_INIT: 30
+      JNLP_READINESS_PER: 15
+      JNLP_INGRESS_PUB: no
+    commands:
+      # 切换目标集群
+      - kubecm s $DEPLOY_ENV
+      # 生成配置YAML文件 
+      - python3 /root/tools.py -b
+      # 部署服务到kubernetes上
+      - python3 /root/tools.py -a
+      # 检查服务部署状态
+      # - python3 /root/tools.py -c
+      # 添加dns解析记录,生成访问域名1 
+      - 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 ${DRONE_REPO_NAME} Success"
+      description: "${DRONE_BUILD_LINK} 部署完成"
+      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 ${DRONE_REPO_NAME} Failure"
+      description: "${DRONE_BUILD_LINK} 部署失败,请检查配置!"
+      msg_url: ${DRONE_BUILD_LINK}
+      btn_txt: "否"
+    when:
+      status:
+        - failure

+ 99 - 0
deploy-tmp.yaml

@@ -0,0 +1,99 @@
+---
+apiVersion: apps/v1
+kind: $JNLP_CONTROL
+metadata:
+  name: $DRONE_REPO_NAME
+  namespace: $JNLP_ENV
+  labels:
+    app: $DRONE_REPO_NAME
+spec:
+  serviceName: $DRONE_REPO_NAME
+  replicas: $JNLP_REPLICAS
+  selector:
+    matchLabels:
+      app: $DRONE_REPO_NAME
+  template:
+    metadata:
+      labels:
+        app: $DRONE_REPO_NAME
+    spec:
+      terminationGracePeriodSeconds: 180
+      dnsPolicy: ClusterFirstWithHostNet
+      dnsConfig:
+        nameservers:
+          - 223.5.5.5
+          - 223.6.6.6
+      initContainers:
+        - name: init
+          image: $JNLP_REPO/dev/busybox
+          command: ["chmod","777","-R","$JNLP_MOUNT_PATH"]
+          imagePullPolicy: Always
+          volumeMounts:
+            - name: volume
+              mountPath: $JNLP_MOUNT_PATH
+      containers:
+        - name: $DRONE_REPO_NAME
+          image: $JNLP_REPO/$JNLP_ENV/$DRONE_REPO_NAME:$JNLP_TAG
+          imagePullPolicy: Always
+          env:
+            - name: JAVA_OPTS
+              value: $JNLP_JAVA_OPTS -Dspring.profiles.active=$JNLP_ACTIVE_PROFILE
+          ports:
+            - containerPort: $JNLP_CONTAINER_PORT
+              name: port
+          volumeMounts:
+            - name: volume
+              mountPath: $JNLP_MOUNT_PATH 
+          livenessProbe:
+            tcpSocket:
+              port: $JNLP_CONTAINER_PORT
+            initialDelaySeconds: $JNLP_LIVENESS_INIT
+            periodSeconds: $JNLP_LIVENESS_PER
+          readinessProbe:
+            tcpSocket:
+              port: $JNLP_CONTAINER_PORT
+            initialDelaySeconds: $JNLP_READINESS_INIT
+            periodSeconds: $JNLP_READINESS_PER
+  volumeClaimTemplates:
+    - metadata:
+        name: volume
+      spec:
+        accessModes: ["ReadWriteOnce"]
+        storageClassName: $JNLP_STORAGE_CLASS #ceph-block
+        resources:
+          requests:
+            storage: $JNLP_STORAGE_CAPACITY
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: $DRONE_REPO_NAME-svc
+  namespace: $JNLP_ENV
+  labels:
+    app: $DRONE_REPO_NAME-svc
+spec:
+  type: NodePort
+  ports:
+    - port: $JNLP_CONTAINER_PORT
+      targetPort: $JNLP_CONTAINER_PORT
+  selector:
+    app: $DRONE_REPO_NAME
+---
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+  name: $DRONE_REPO_NAME-ingress
+  namespace: $JNLP_ENV
+spec:
+  rules:
+    - host: $JNLP_ENV-$DRONE_REPO_NAME$JNLP_DOMAIN
+      http:
+        paths:
+          - path: /
+            pathType: Prefix
+            backend:
+              service:
+                name: $DRONE_REPO_NAME-svc
+                port: 
+                  number: $JNLP_CONTAINER_PORT
+  ingressClassName: nginx