From d2b68ac345cce74e5baf4a36b175d4cf64d0580b Mon Sep 17 00:00:00 2001 From: sux26 Date: Sun, 14 Feb 2021 15:17:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=9F=E4=BA=A7=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E9=83=A8=E7=BD=B2=E6=96=87=E4=BB=B6=EF=BC=8C=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=96=87=E4=BB=B6=E5=90=8D=E7=A7=B0=E8=BF=9E=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E6=94=B9=E4=B8=BA=E4=B8=8B=E5=88=92=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile-pro | 2 + config-pro | 17 ++++++ pro.yaml | 101 +++++++++++++++++++++++++++++++++ src/main/resources/logback.xml | 2 +- 4 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 Dockerfile-pro create mode 100644 config-pro create mode 100644 pro.yaml diff --git a/Dockerfile-pro b/Dockerfile-pro new file mode 100644 index 0000000..c0f9f42 --- /dev/null +++ b/Dockerfile-pro @@ -0,0 +1,2 @@ +FROM harbor.dcos.xixian.unicom.local/eshop/jdk8_springboot_agent:v1.6 +ADD target/biz_service_ebtp_project-0.0.1.jar /app.jar \ No newline at end of file diff --git a/config-pro b/config-pro new file mode 100644 index 0000000..cfa151b --- /dev/null +++ b/config-pro @@ -0,0 +1,17 @@ +apiVersion: v1 +clusters: +- cluster: + insecure-skip-tls-verify: true + server: https://10.172.48.16:44039 + name: demok8s +contexts: +- context: + cluster: demok8s + user: cluster-admin + name: default +current-context: default +kind: Config +users: +- name: cluster-admin + user: + token: 2c00232d4e3b1498008315e8ab14283c diff --git a/pro.yaml b/pro.yaml new file mode 100644 index 0000000..c82c163 --- /dev/null +++ b/pro.yaml @@ -0,0 +1,101 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: biz-service-ebtp-project #[1] Deployment名称,可填写微服务名称 + namespace: default + labels: + app: biz-service-ebtp-project +spec: + replicas: 3 + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 1 + selector: + matchLabels: + app: biz-service-ebtp-project #[2] 选择器匹配时标签名称,可填写微服务名称 + template: + metadata: + labels: + app: biz-service-ebtp-project #[3] 模板名称,可填写微服务名称 + annotations: + prometheus.io/port: '18012' # [4] prometheus自动发现pod的端口,也是该微服务server.port参数 + prometheus.io/jl-pod: 'true' #[5] 开启prometheus自动发现pod的功能,自动发现所带标签为test-pod的pod,yy-pod sd-pod ji-pod + spec: + volumes: + - name: log + persistentVolumeClaim: + claimName: log-pvc + readOnly: false + containers: + - name: biz-service-ebtp-project #[6] 必选,容器名称,可填写微服务名称 + image: harbor.dcos.xixian.unicom.local/eshop/biz-service-ebtp-project:latest #[7] 镜像名称,请把biz-service-ebtp-project替换为服务名称 + args: ["java","-Djava.security.egd=file:/dev/./urandom","-javaagent:/pinpoint/tianyan-springboot-agent/pinpoint-bootstrap-1.8.0.jar","-Dpinpoint.agentId=$(MY_POD_IP)","-Dpinpoint.applicationName=$(APP_NAME)","-Dpinpoint.licence=$(AGENT_LICENCE_DEV)","-jar","/app.jar"] + volumeMounts: + - name: log + mountPath: /log + ports: + - containerPort: 18012 #[8] 容器需要监听的端口号,与配置文件中的server.port参数相同,与参数[4]相同 + livenessProbe: # 存活检测,不通过则重启容器 + failureThreshold: 3 #探测失败3次重启容器 + httpGet: + port: 18012 #[9] 与参数[4]相同 + path: /actuator/prometheus + scheme: HTTP + initialDelaySeconds: 300 #启动容器后,初始化延迟的时间,也就是告诉监测从多久之后开始运行,单位是秒。默认为0秒。最小值为0。 + periodSeconds: 60 #执行探测的频率(以秒为单位)。默认为10秒。最小值为1。 + successThreshold: 1 #连续失败的最小成功次数,失败后将被视为成功。默认值为1。对于活动和启动探针,必须为1。最小值为1。 + timeoutSeconds: 2 #探测超时的秒数。默认为1秒。最小值为1。 + # readinessProbe: # 就绪检测,不通过则不加入svc + # failureThreshold: 1 + # httpGet: + # path: /get + # port: 18012 + # scheme: HTTP + # periodSeconds: 5 #执行探测的频率(以秒为单位)。默认为10秒。最小值为1 + # successThreshold: 1 #连续失败的最小成功次数,失败后将被视为成功。默认值为1。对于活动和启动探针,必须为1。最小值为1。 + # timeoutSeconds: 2 #探测超时的秒数。默认为1秒。最小值为1。 + resources: + requests: + cpu: 500m + memory: 1Gi + limits: + cpu: 1000m + memory: 2Gi + env: # 此处添加环境变量 + - name: APP_NAME #[10] 微服务名称 + value: biz-service-ebtp-project + - name: AGENT_LICENCE_DEV #天眼pinpoint生产环境licence,请勿修改 + value: 527BFA7B28577578 + - name: MY_POD_IP #自动获取pod ip作为agent id,请勿修改 + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: APOLLO_CONFIGSERVICE #获取apollo配置的地址,请勿修改 + value: http://10.238.25.112:6001 + + +--- +kind: Service +apiVersion: v1 +metadata: + name: biz-service-ebtp-project-svc # [11] service的名字,格式为“服务名-svc” + namespace: default + labels: + app: biz-service-ebtp-project-svc # [12] service的标签,可与参数[11]相同 + annotations: + lb.cke.tg.unicom/target-vports: 18012-18012 #[13] 内部端口-外部端口映射 内部端口为server.port,即与参数[4]相同 + prometheus.io/port: '18012' #[13] prometheus自动发现service的端口,也是该微服务所使用的端口,与参数[4]相同 + prometheus.io/test-svc: 'true' #[14] 开启prometheus自动发现service的功能,自动发现所带标签为test-svc的service +spec: + ports: + - port: 18012 #[15] 与参数4相同 + targetPort: 18012 #[16] 与参数4相同 + selector: + app: biz-service-ebtp-project #[17] 该service对应Deployment的名字,与参数[1]相同 +status: + loadBalancer: {} +--- + + + diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 8baf38a..da621b2 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -2,7 +2,7 @@ - + ${logback.appname}