修改k8s部署文件

This commit is contained in:
ajaxfan
2021-03-23 17:40:48 +08:00
parent 7efb907b0d
commit 9722e78831
2 changed files with 222 additions and 43 deletions

View File

@ -5,6 +5,7 @@ metadata:
namespace: default
labels:
app: biz-service-ebtp-project
spec:
replicas: 3
strategy:
@ -19,62 +20,70 @@ spec:
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的podyy-pod sd-pod ji-pod
prometheus.io/port: '18012'
prometheus.io/jl-pod: 'true'
spec:
volumes:
- name: log
persistentVolumeClaim:
claimName: log-pvc
readOnly: false
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- biz-service-ebtp-project
topologyKey: "kubernetes.io/hostname"
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"]
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)", "-Dspring.profiles.active=pro", "-jar", "/app.jar"]
volumeMounts:
- name: log
mountPath: /log
ports:
- containerPort: 18012 #[8] 容器需要监听的端口号与配置文件中的server.port参数相同与参数[4]相同
livenessProbe: # 存活检测,不通过则重启容器
failureThreshold: 3 #探测失败3次重启容器
httpGet:
port: 18012 #[9] 与参数[4]相同
livenessProbe:
failureThreshold: 3
httpGet:
port: 18012 #[11] pod存活检测端口,修改为该微服务配置文件中server.port的端口号,与参数[5]相同
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:
initialDelaySeconds: 300
periodSeconds: 60
successThreshold: 1
timeoutSeconds: 2
readinessProbe:
failureThreshold: 1
httpGet:
port: 18012 #[12] pod就绪检测端口,修改为该微服务配置文件中server.port的端口号,与参数[5]相同
path: /actuator/prometheus
scheme: HTTP
periodSeconds: 5
successThreshold: 2
timeoutSeconds: 2
resources:
requests:
cpu: 1000m
memory: 2Gi
env: # 此处添加环境变量
- name: APP_NAME #[10] 微服务名称
value: biz-service-ebtp-project
- name: AGENT_LICENCE_DEV #天眼pinpoint生产环境licence请勿修改
limits:
cpu: 3000m
memory: 6Gi
env:
- name: APP_NAME
value: biz-ebtp-project
- name: AGENT_LICENCE
value: 527BFA7B28577578
- name: MY_POD_IP #自动获取pod ip作为agent id请勿修改
- name: APOLLO_CONFIGSERVICE
value: http://apollo-configservice:8080
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: APOLLO_CONFIGSERVICE #获取apollo配置的地址请勿修改
value: http://10.238.25.112:6001
---
kind: Service
apiVersion: v1
@ -82,20 +91,15 @@ metadata:
name: biz-service-ebtp-project-svc # [11] service的名字格式为“服务名-svc”
namespace: default
labels:
app: biz-service-ebtp-project-svc # [12] service的标签可与参数[11]相同
service: 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
prometheus.io/jl-svc: 'true'
spec:
ports:
- port: 18012 #[15] 与参数4相同
targetPort: 18012 #[16] 与参数4相同
selector:
app: biz-service-ebtp-project #[17] 该service对应Deployment的名字与参数[1]相同
status:
loadBalancer: {}
---
---