Browse Source

DDDDDDDDD

yangxg 4 years ago
parent
commit
77036dbb06

+ 0 - 1
Dockerfile-elasticsearch

@@ -1 +0,0 @@
-FROM docker.elastic.co/elasticsearch/elasticsearch:7.6.2

+ 0 - 1
Dockerfile-kibana

@@ -1 +0,0 @@
-FROM docker.elastic.co/kibana/kibana:7.6.2

+ 0 - 8
build/Dockerfile

@@ -1,8 +0,0 @@
-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"]

+ 0 - 110
deploy-tmp-elasticsearch.yaml

@@ -1,110 +0,0 @@
----
-apiVersion: apps/v1
-kind: StatefulSet
-metadata:
-  name: elasticsearch
-  namespace: qa
-spec:
-  serviceName: elasticsearch
-  replicas: 3
-  selector:
-    matchLabels:
-      app: elasticsearch
-  template:
-    metadata:
-      labels:
-        app: elasticsearch
-    spec:
-      terminationGracePeriodSeconds: 180
-      initContainers:
-        - name: init
-          image: hub.evbj.easou.com/dev/busybox
-          command: ["/bin/sh", "-c"]
-          args:
-            - chmod 777 -R /data;
-              sysctl -w vm.max_map_count=262144;
-              ulimit -n 65536
-          imagePullPolicy: Always
-          volumeMounts:
-            - name: volume
-              mountPath: /data
-          securityContext:
-            privileged: true
-      containers:
-        - name: elasticsearch
-          image: docker.elastic.co/elasticsearch/elasticsearch:7.6.2
-          resources:
-            limits:
-              cpu: 1000m
-            requests:
-              cpu: 100m
-          ports:
-            - containerPort: 9200
-              name: rest
-              protocol: TCP
-            - containerPort: 9300
-              name: inter-node
-              protocol: TCP
-          volumeMounts:
-            - name: volume
-              mountPath: /data/elasticsearch
-          env:
-            - name: cluster.name
-              value: k8s-es-logs
-            - name: node.name
-              valueFrom:
-                fieldRef:
-                  fieldPath: metadata.name
-            - name: cluster.initial_master_nodes
-              value: "es-0,es-1,es-2"
-            - name: discovery.zen.minimum_master_nodes
-              value: "2"
-            - name: discovery.seed_hosts
-              value: "elasticsearch"
-            - name: ES_JAVA_OPTS
-              value: "-Xms2048m -Xmx2048m"
-            - name: network.host
-              value: "0.0.0.0"
-  volumeClaimTemplates:
-    - metadata:
-        name: volume
-      spec:
-        accessModes: [ "ReadWriteOnce" ]
-        storageClassName: rbd
-        resources:
-          requests:
-            storage: 100Gi
----
-apiVersion: v1
-kind: Service
-metadata:
-  name: elasticsearch-svc
-  namespace: qa
-  labels:
-    app: elasticsearch-svc
-spec:
-  selector:
-    app: elasticsearch-svc
-  clusterIP: None
-  ports:
-    - port: 9200
-      name: rest
-    - port: 9300
-      name: inter-node
----
-apiVersion: extensions/v1beta1
-kind: Ingress
-metadata:
-  name: kibana-ingress
-  namespace: qa
-  annotations:
-    kubernetes.io/ingress.class: nginx
-spec:
-  rules:
-    - host: qa-elasticsearch.ieasou.cn
-      http:
-        paths:
-          - path: /
-            backend:
-              serviceName: elasticsearch-svc
-              servicePort: 80

+ 0 - 65
deploy-tmp-kibana.yaml

@@ -1,65 +0,0 @@
----
-apiVersion: v1
-kind: Service
-metadata:
-  name: kibana-svc
-  namespace: qa
-  labels:
-    app: kibana-svc
-spec:
-  ports:
-    - port: 80
-      name: client
-      targetPort: 5601
-  type: NodePort
-  selector:
-    app: kibana
----
-apiVersion: apps/v1
-kind: StatefulSet
-metadata:
-  name: kibana
-  namespace: qa
-  labels:
-    app: kibana
-spec:
-  serviceName: kibana
-  selector:
-    matchLabels:
-      app: kibana
-  template:
-    metadata:
-      labels:
-        app: kibana
-    spec:
-      terminationGracePeriodSeconds: 180
-      containers:
-        - name: kibana
-          image: docker.elastic.co/kibana/kibana:7.6.2
-          resources:
-            limits:
-              cpu: 1000m
-            requests:
-              cpu: 1000m
-          env:
-            - name: ELASTICSEARCH_HOSTS
-              value: http://elasticsearch:9200
-          ports:
-            - containerPort: 5601
----
-apiVersion: extensions/v1beta1
-kind: Ingress
-metadata:
-  name: kibana-ingress
-  namespace: qa
-  annotations:
-    kubernetes.io/ingress.class: nginx
-spec:
-  rules:
-    - host: qa-kibana.ieasou.cn
-      http:
-        paths:
-          - path: /
-            backend:
-              serviceName: kibana-svc
-              servicePort: 80

+ 0 - 144
deploy-tmp-zookeeper.yaml

@@ -1,144 +0,0 @@
----
-apiVersion: apps/v1
-kind: StatefulSet
-metadata:
-  name: zookeeper
-  namespace: qa
-spec:
-  selector:
-    matchLabels:
-      app: zookeeper
-  serviceName: zookeeper-hs
-  replicas: 3
-  updateStrategy:
-    type: RollingUpdate
-  podManagementPolicy: OrderedReady
-  template:
-    metadata:
-      labels:
-        app: zookeeper
-    spec:
-      terminationGracePeriodSeconds: 180
-      affinity:
-        podAntiAffinity:
-          requiredDuringSchedulingIgnoredDuringExecution:
-            - labelSelector:
-                matchExpressions:
-                  - key: "app"
-                    operator: In
-                    values:
-                      - zookeeper
-              topologyKey: "kubernetes.io/hostname"
-      containers:
-        - name: kubernetes-zookeeper
-          imagePullPolicy: Always
-          image: "leolee32/kubernetes-library:kubernetes-zookeeper1.0-3.4.10"
-          resources:
-            requests:
-              memory: "1Gi"
-              cpu: "0.5"
-          ports:
-            - containerPort: 2181
-              name: client
-            - containerPort: 2888
-              name: server
-            - containerPort: 3888
-              name: leader-election
-          command:
-            - sh
-            - -c
-            - "start-zookeeper \
-          --servers=3 \
-          --data_dir=/data/zookeeper \
-          --data_log_dir=/data/zookeeper/log \
-          --conf_dir=/opt/zookeeper/conf \
-          --client_port=2181 \
-          --election_port=3888 \
-          --server_port=2888 \
-          --tick_time=2000 \
-          --init_limit=10 \
-          --sync_limit=5 \
-          --heap=512M \
-          --max_client_cnxns=60 \
-          --snap_retain_count=3 \
-          --purge_interval=12 \
-          --max_session_timeout=40000 \
-          --min_session_timeout=4000 \
-          --log_level=INFO"
-          readinessProbe:
-            exec:
-              command:
-                - sh
-                - -c
-                - "zookeeper-ready 2181"
-            initialDelaySeconds: 10
-            timeoutSeconds: 5
-          livenessProbe:
-            exec:
-              command:
-                - sh
-                - -c
-                - "zookeeper-ready 2181"
-            initialDelaySeconds: 10
-            timeoutSeconds: 5
-          volumeMounts:
-            - name: volume
-              mountPath: /data/zookeeper
-      securityContext:
-        runAsUser: 1000
-        fsGroup: 1000
-  volumeClaimTemplates:
-    - metadata:
-        name: volume
-        annotations:
-          volume.alpha.kubernetes.io/storage-class: anything
-      spec:
-        accessModes: [ "ReadWriteOnce" ]
-        storageClassName: rbd
-        resources:
-          requests:
-            storage: 5Gi
----
-apiVersion: v1
-kind: Service
-metadata:
-  name: zookeeper-hs
-  namespace: qa
-  labels:
-    app: zookeeper
-spec:
-  ports:
-    - port: 2888
-      name: server
-    - port: 3888
-      name: leader-election
-  clusterIP: None
-  selector:
-    app: zookeeper
----
-apiVersion: v1
-kind: Service
-metadata:
-  name: zookeeper-cs
-  namespace: qa
-  labels:
-    app: zookeeper
-spec:
-  type: NodePort
-  ports:
-    - port: 2181
-      name: client
-      nodePort: 31812
-  selector:
-    app: zookeeper
----
-apiVersion: policy/v1beta1
-kind: PodDisruptionBudget
-metadata:
-  name: zookeeper-pdb
-  namespace: qa
-spec:
-  selector:
-    matchLabels:
-      app: zookeeper
-  maxUnavailable: 1

+ 0 - 93
drone.elasticsearch.yml

@@ -1,93 +0,0 @@
-kind: pipeline
-type: kubernetes
-name: elasticsearch
-
-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/qa/elasticsearch
-      tag: v1.0
-  #    build_args:
-  #      - 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: qa
-      JNLP_REPLICAS: 1
-      JNLP_TAG: v1.0
-      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
-      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解析记录,生成访问域名
-      - 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 qa/kibana:v1.0 Success"
-      description: "${DRONE_BUILD_LINK} qa/elasticsearch:v1.0 部署完成"
-      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 qa/elasticsearch:v1.0 Failure"
-      description: "${DRONE_BUILD_LINK} 部署失败,请检查配置!"
-      msg_url: ${DRONE_BUILD_LINK}
-      btn_txt: "否"
-    when:
-      status:
-        - failure

+ 0 - 93
drone.kibana.yml

@@ -1,93 +0,0 @@
-kind: pipeline
-type: kubernetes
-name: kibana
-
-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/qa/kibana
-      tag: v1.0
-  #    build_args:
-  #      - 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: qa
-      JNLP_REPLICAS: 1
-      JNLP_TAG: v1.0
-      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
-      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解析记录,生成访问域名
-      - 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 qa/kibana:v1.0 Success"
-      description: "${DRONE_BUILD_LINK} qa/kibana:v1.0 部署完成"
-      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 qa/kibana:v1.0 Failure"
-      description: "${DRONE_BUILD_LINK} 部署失败,请检查配置!"
-      msg_url: ${DRONE_BUILD_LINK}
-      btn_txt: "否"
-    when:
-      status:
-        - failure

+ 0 - 79
k8s-deploy.sh

@@ -1,79 +0,0 @@
-#!/bin/bash -c
-app_names=("zookeeper" "kibana" "elasticsearch")
-envs=("qa" "pro")
-
-#当前目录
-DEPLOY_HOME=$(
-  cd $(dirname $0)
-  pwd
-)
-
-echo "----------------------------------"
-echo "选择要部署的应用:"
-echo "(0) zookeeper"
-echo "(1) kibana"
-echo "(2) elasticsearch"
-echo "----------------------------------"
-while [ 1 ]; do
-  read input1
-  if ! [[ $input1 =~ ^[0-9](,[0-9])*$ ]]; then
-    echo "请输入[0-2]之间的数字:"
-    continue
-  fi
-
-  if [  $input1 -ge 0 -a $input1 -le 2 ]; then
-    currApp=${app_names[$input1]}
-    break
-  else
-    echo "请输入[0-2]之间的数字:"
-  fi
-done
-
-echo "----------------------------------"
-echo "运行环境:"
-echo "(0) qa"
-echo "(1) pro"
-echo "----------------------------------"
-while [ 1 ]; do
-  read input1
-  if ! [[ $input1 =~ ^[0-9](,[0-9])*$ ]]; then
-    echo "请输入[0-1]之间的数字:"
-    continue
-  fi
-
-  if [ $input1 != 1 -o $input1 -lt 0 -o $input1 -gt 2 ]; then
-    ENV=${envs[$input1]}
-    break
-  else
-    echo "请输入[0-1]之间的数字:"
-  fi
-done
-
-echo "----------------------------------"
-echo "最终要部署的应用${currApp}"
-echo "环境${ENV}"
-echo "----------------------------------"
-
-cd $DEPLOY_HOME || exit
-rm -rf .tmp && mkdir .tmp && cd .tmp || exit
-
-git config --global user.email "yangxg_yang@easou.cn"
-git config --global user.name "${USER}"
-git config --global credential.helper store
-
-
-git clone http://yangxg:yangtxy1256@gogs.ieasou.cn/yangxg/${currApp}.git ${currApp} && cd ${currApp} || exit
-cp -f ../../deploy-tmp-${currApp}.yaml deploy-tmp.yaml
-cp -f ../../drone.${currApp}.yml .drone.yml
-cp -f ../../Dockerfile-${currApp} Dockerfile
-
-git add deploy-tmp.yaml
-git add .drone.yml
-git add Dockerfile
-echo "git commit"
-git commit --allow-empty -m "deploy $ENV/${currApp}:1.0"
-echo "git push"
-git push origin master
-
-cd $DEPLOY_HOME || exit
-rm -rf .tmp