aaaaa

发布于:2025-08-04 ⋅ 阅读:(12) ⋅ 点赞:(0)

docker pull registry.cn-beijing.aliyuncs.com/duanshuaixing-dockerhub/infra:nemo-infra-24.01.01.framework

apiVersion: v1kind: Secretmetadata: name: kubernetes-etcd-sladata: server.crt: server.key: —kind: ConfigMapapiVersion: v1metadata: name: etcd-sla-configmapdata: crontab-list: | * * * * * bash -vx /tmp/sla.sh >/opt/sla.log 2>&1 sla.sh: | <<! ********************************************************** * Author : duanshuaixing * Email : duanshuaixing@gmail.com * Last modified : 2021-10-30 20:48 * Filename : sla.sh * Description : 检查etcd集群sla * ******************************************************* ! #!/bin/bash ETCD_CLUSTER_NAME=kubernetes-etcd ETCD_MEMBER=https://10.10.12.139:2379,https://10.10.12.141:2379,https://10.10.12.142:2379 ETCD_CERT=/opt/etcd-key/server.crt ETCD_CERT_KEY=/opt/etcd-key/server.key Check_time=date +%Y/%m/%d-%T mkdir -p /opt/sla >/opt/sla/metrics send_message_dingtalk(){ HTTP_PROXY_ENABLED=false HTTP_PROXY=httpproxy:3128 DINGTALK_TOKEN=xxxxxxxx if [ “$HTTP_PROXY_ENABLED” = true ];then curl --proxy HTTPPROXY"HTTP_PROXY "HTTPPROXY"DINGTALK_TOKEN" -H ‘Content-Type: application/json’ -d “{“actionCard”: {“text”: “KaTeX parse error: Can't use function '\"' in math mode at position 8: context\̲"̲,},\"msgtype\":…DINGTALK_TOKEN” -H ‘Content-Type: application/json’ -d “{“actionCard”: {“text”: “KaTeX parse error: Can't use function '\"' in math mode at position 8: context\̲"̲,},\"msgtype\":…HTTP_PROXY_ENABLED” = true ];then curl --proxy $HTTP_PROXY KaTeX parse error: Can't use function '\"' in math mode at position 63: …ion/json" -d "{\̲"̲msg_type\":\"te…context”}}” else curl KaTeX parse error: Can't use function '\"' in math mode at position 63: …ion/json" -d "{\̲"̲msg_type\":\"te…context"}}" fi } check_sla(){ timeout -k 5s 30s /usr/local/bin/etcdctl --cert $ETCD_CERT --key $ETCD_CERT_KEY --endpoints $ETCD_MEMBER --insecure-skip-tls-verify member list --write-out=table timeout -k 5s 30s /usr/local/bin/etcdctl --cert $ETCD_CERT --key $ETCD_CERT_KEY --endpoints $ETCD_MEMBER --insecure-skip-tls-verify endpoint status --write-out=table timeout -k 5s 30s /usr/local/bin/etcdctl --cert $ETCD_CERT --key $ETCD_CERT_KEY --endpoints $ETCD_MEMBER --insecure-skip-tls-verify endpoint health --write-out=table #timeout -k 5s 30s etcdctl --cert $ETCD_CERT --key $ETCD_CERT_KEY --endpoints $ETCD_MEMBER --insecure-skip-tls-verify put /infrae2e/e2e “infra e2e test” timeout -k 5s 30s /usr/local/bin/etcdctl --cert $ETCD_CERT --key $ETCD_CERT_KEY --endpoints $ETCD_MEMBER --insecure-skip-tls-verify get /infrae2e/e2e if [ KaTeX parse error: Can't use function '\"' in math mode at position 57: …_avail{cluster=\̲"̲ETCD_CLUSTER_NAME"} 1" >> /opt/sla/metrics else echo "SLA_etcd_avail{cluster=“KaTeX parse error: Can't use function '\"' in math mode at position 18: …CD_CLUSTER_NAME\̲"̲} 0" >> /opt/sl…ETCD_CLUSTER_NAME 请及时处理!” #send_message_dingtalk #send_message_feishu fi } check_sla—apiVersion: monitoring.coreos.com/v1kind: ServiceMonitormetadata: labels: app.kubernetes.io/managed-by: Helm team: infra name: etcd-slaspec: endpoints: - interval: 90s port: etcd-sla path: /metrics jobLabel: etcd-sla selector: matchLabels: app: etcd-sla—apiVersion: v1kind: Servicemetadata: labels: app: etcd-sla cluster: etcd-sla name: etcd-sla namespace: srespec: ports: - port: 80 protocol: TCP targetPort: 80 name: etcd-sla selector: app: etcd-sla—apiVersion: apps/v1kind: Deploymentmetadata: labels: app: etcd-sla cluster: etcd-sla name: etcd-sla namespace: srespec: replicas: 3 selector: matchLabels: app: etcd-sla cluster: etcd-sla template: metadata: labels: app: etcd-sla cluster: etcd-sla spec: tolerations: - key: “node-role.kubernetes.io/control-plane” operator: “Exists” effect: “NoSchedule” affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: node-role.kubernetes.io/control-plane operator: Exists podAntiAffinity: requiredDuringSchedulingIgnoredDuringExecution: - labelSelector: matchExpressions: - key: cluster operator: In values: - etcd-sla topologyKey: “kubernetes.io/hostname” containers: - image: duanshuaixing02/databases-backup:v002 name: metrics imagePullPolicy: IfNotPresent command: [“python”] args: - “-c” - | import os os.chdir(’/opt/sla/’) import


网站公告

今日签到

点亮在社区的每一天
去签到