@leverege/build-tools 2.65.1 → 2.66.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/package.json +3 -3
  2. package/src/clone-cnpg-from-snapshot.mjs +5 -3
  3. package/src/helm-charts/cnpg-operator/cnpg-cleanup-cronjob.yaml.ovh +67 -0
  4. package/src/helm-charts/cnpg-operator/cnpg-cleanup-script.sh +73 -0
  5. package/src/helm-charts/cnpg-operator/gitignore +1 -0
  6. package/src/helm-charts/cnpg-operator/helmup-1.26.0-rc1.plugin +28 -0
  7. package/src/helm-charts/cnpg-operator/helmup.plugin +2 -3
  8. package/src/helm-charts/elasticsearch8/helmup.plugin +1 -1
  9. package/src/helm-charts/prom-operator/helmup.plugin +1 -1
  10. package/src/helm-charts/prom-operator/prometheus-stack.yaml.ovh +1 -1
  11. package/src/helm-charts/prom-operator/rules/awesome-base/elasticsearch-rules.yaml +219 -0
  12. package/src/helm-charts/prom-operator/rules/awesome-base/etcd-exporter.yaml +153 -0
  13. package/src/helm-charts/prom-operator/rules/awesome-base/google-cadvisor.yaml +108 -0
  14. package/src/helm-charts/prom-operator/rules/{new-awesome.yaml → awesome-base/kubestate-exporter.yaml} +2 -1
  15. package/src/helm-charts/prom-operator/rules/awesome-base/prometheus-rules.yaml +318 -0
  16. package/src/helm-charts/prom-operator/rules/awesome-base/redis-rules.yaml +142 -0
  17. package/src/helm-charts/prom-operator/rules/awesome-base/traefik-rules.yaml +43 -0
  18. package/src/helm-charts/prom-operator/rules/cadvisor-rules.yaml +109 -0
  19. package/src/helm-charts/prom-operator/rules/elasticsearch-rules.yaml +213 -95
  20. package/src/helm-charts/prom-operator/rules/etcd-rulte.yaml +153 -0
  21. package/src/helm-charts/prom-operator/rules/kubestate-rules.yaml +412 -0
  22. package/src/helm-charts/prom-operator/rules/prometheus-rules.yaml +312 -73
  23. package/src/helm-charts/prom-operator/rules/redis-rules.yaml +136 -75
  24. package/src/helm-charts/prom-operator/rules/traefik-rules.yaml +48 -21
  25. package/src/helm-charts/prom-operator/stackdriver-exporter.yaml.ovh +21 -1
  26. package/src/helm-charts/redis/helmup.plugin +1 -1
  27. package/src/helm-charts/traefik/helmup.plugin +1 -1
  28. package/src/helm-charts/velero/helmup.plugin +1 -1
  29. package/src/helm-charts/velero/{velero-local.yaml → values-local.yaml} +1 -1
  30. package/src/helmup.sh +43 -10
  31. package/src/templates/cloudBuildSteps.hbs +6 -2
  32. package/src/helm-charts/cnpg-operator/cnpg-cleanup-snapshot-cronjob.yaml +0 -73
  33. package/src/helm-charts/prom-operator/rules/awesome-k8s.yaml +0 -326
  34. package/src/helm-charts/prom-operator/rules/kubernetes-rules.yaml +0 -109
@@ -1,27 +1,54 @@
1
+ # https://samber.github.io/awesome-prometheus-alerts/rules#traefik
1
2
  apiVersion: monitoring.coreos.com/v1
2
3
  kind: PrometheusRule
3
4
  metadata:
4
- name: traefik-rules
5
+ name: embedded-exporter-v2
5
6
  namespace: prometheus
6
-
7
7
  spec:
8
8
  groups:
9
- - name: Traefik Alerts
10
- rules:
11
- - alert: TraefikConfigReloadFailed
12
- expr: traefik_config_last_reload_failure > 0
13
- for: 1m
14
- labels:
15
- severity: warning
16
- annotations:
17
- summary: "Traefik config failed to reload"
18
- description: "New config file for Traefik is invalid or Traefik encountered an error"
19
-
20
- # - alert: TraefikHighHttp4xxError
21
- # expr: sum(rate(traefik_service_requests_total{code=~"4.*"}[3m])) by (service) / sum(rate(traefik_service_requests_total[3m])) by (service) * 100 > 10
22
- # for: 5m
23
- # labels:
24
- # severity: error
25
- # annotations:
26
- # summary: "Traefik high HTTP 4xx error rate on {{ $labels.service }}"
27
- # description: "Traefik backend 4xx error rate is above 10% (currently at {{ $value }}%)"
9
+ - name: EmbeddedExporterV2-rules
10
+ rules:
11
+ - alert: TraefikServiceDown
12
+ expr: count(traefik_service_server_up) by (service) == 0
13
+ for: 0m
14
+ labels:
15
+ severity: critical
16
+ annotations:
17
+ summary: Traefik service down (instance {{ $labels.instance }})
18
+ description: |-
19
+ All Traefik services are down
20
+ VALUE = {{ $value }}
21
+ LABELS = {{ $labels }}
22
+ # - alert: TraefikHighHttp4xxErrorRateService
23
+ # expr: sum(rate(traefik_service_requests_total{code=~"4.*"}[3m])) by (service) / sum(rate(traefik_service_requests_total[3m])) by (service) * 100 > 5
24
+ # for: 1m
25
+ # labels:
26
+ # severity: critical
27
+ # annotations:
28
+ # summary: Traefik high HTTP 4xx error rate service (instance {{ $labels.instance }})
29
+ # description: |-
30
+ # Traefik service 4xx error rate is above 5%
31
+ # VALUE = {{ $value }}
32
+ # LABELS = {{ $labels }}
33
+ - alert: TraefikHighHttp5xxErrorRateService
34
+ expr: sum(rate(traefik_service_requests_total{code=~"5.*"}[3m])) by (service) / sum(rate(traefik_service_requests_total[3m])) by (service) * 100 > 5
35
+ for: 1m
36
+ labels:
37
+ severity: critical
38
+ annotations:
39
+ summary: Traefik high HTTP 5xx error rate service (instance {{ $labels.instance }})
40
+ description: |-
41
+ Traefik service 5xx error rate is above 5%
42
+ VALUE = {{ $value }}
43
+ LABELS = {{ $labels }}
44
+ #
45
+ # legacy leverege alert
46
+ #
47
+ - alert: TraefikConfigReloadFailed
48
+ expr: traefik_config_last_reload_failure > 0
49
+ for: 1m
50
+ labels:
51
+ severity: warning
52
+ annotations:
53
+ summary: "Traefik config failed to reload"
54
+ description: "New config file for Traefik is invalid or Traefik encountered an error"
@@ -7,7 +7,25 @@ fullnameOverride: "prometheus-stack-stackdriver-metrics"
7
7
  stackdriver:
8
8
  projectId: "${PROJECT_NAME}"
9
9
  metrics:
10
- typePrefixes: "pubsub.googleapis.com/subscription/oldest_unacked_message_age,pubsub.googleapis.com/subscription/num_undelivered_messages,pubsub.googleapis.com/subscription/pull_ack_request_count,pubsub.googleapis.com/subscription/streaming_pull_ack_request_count,pubsub.googleapis.com/topic/message_sizes,pubsub.googleapis.com/topic/send_request_count,firebasedatabase.googleapis.com/io/database_load,firebasedatabase.googleapis.com/network/sent_bytes_count,firebasedatabase.googleapis.com/network/active_connections"
10
+ typePrefixes: >
11
+ pubsub.googleapis.com/subscription/oldest_unacked_message_age,
12
+ pubsub.googleapis.com/subscription/num_undelivered_messages,
13
+ pubsub.googleapis.com/subscription/pull_ack_request_count,
14
+ pubsub.googleapis.com/subscription/streaming_pull_ack_request_count,
15
+ pubsub.googleapis.com/topic/message_sizes,
16
+ pubsub.googleapis.com/topic/send_request_count,
17
+ firebasedatabase.googleapis.com/io/database_load,
18
+ firebasedatabase.googleapis.com/network/sent_bytes_count,
19
+ firebasedatabase.googleapis.com/network/active_connections,
20
+ container.googleapis.com/accelerator/duty_cycle,
21
+ container.googleapis.com/accelerator/memory_usage,
22
+ container.googleapis.com/accelerator/request_count,
23
+ agent.googleapis.com/memory/bytes_used,
24
+ agent.googleapis.com/cpu/utilization,
25
+ storage.googleapis.com/network/received_bytes_count,
26
+ storage.googleapis.com/network/sent_bytes_count,
27
+ monitoring.googleapis.com/uptime_check/check_passed,
28
+ quota.googleapis.com/allocation/usage
11
29
 
12
30
  # https://artifacthub.io/packages/helm/prometheus-community/prometheus-stackdriver-exporter?modal=values&path=serviceMonitor
13
31
  serviceMonitor:
@@ -15,6 +33,8 @@ serviceMonitor:
15
33
  namespace: prometheus
16
34
  interval: "30s"
17
35
  relabelings:
36
+ # Legacy labelmap used to preserve compatibility with pre-operator Grafana dashboards
37
+ # Can be removed once legacy Prometheus stack is deprecated
18
38
  - action: labelmap
19
39
  regex: __meta_kubernetes_pod_label_(.+)
20
40
  - action: labelmap
@@ -4,7 +4,7 @@ showInstalling "Redis"
4
4
 
5
5
  OCI_CHART="oci://registry-1.docker.io/bitnamicharts/redis"
6
6
 
7
- [ -z "$REDIS_CHART_VERSION" ] && REDIS_CHART_VERSION="20.11.3"
7
+ [ -z "$REDIS_CHART_VERSION" ] && REDIS_CHART_VERSION="20.11.5"
8
8
 
9
9
  helm upgrade --install redis $OCI_CHART \
10
10
  --values redis/values.yaml \
@@ -17,7 +17,7 @@ TRAEFIK_NAMESPACE="traefik"
17
17
 
18
18
  addHelmRepo traefik https://helm.traefik.io/traefik
19
19
 
20
- [ -z "$TRAEFIK_CHART_VERSION" ] && TRAEFIK_CHART_VERSION="34"
20
+ [ -z "$TRAEFIK_CHART_VERSION" ] && TRAEFIK_CHART_VERSION="35"
21
21
  helm upgrade --install traefik traefik/traefik \
22
22
  --namespace $TRAEFIK_NAMESPACE --create-namespace \
23
23
  --values traefik/values.yaml \
@@ -25,7 +25,7 @@ velero schedule delete --all --confirm &> /dev/null
25
25
  helm upgrade \
26
26
  --install velero vmware-tanzu/velero \
27
27
  --namespace velero --create-namespace \
28
- --values velero/velero-local.yaml \
28
+ --values velero/values-local.yaml \
29
29
  --version $VELERO_CHART_VERSION $HELM_WHAT \
30
30
  --set configuration.backupStorageLocation[0].bucket="$GCE_BUCKET" \
31
31
  --set configuration.backupStorageLocation[0].config.serviceAccount="$GCE_SA_EMAIL" \
@@ -71,7 +71,7 @@ resources:
71
71
  cpu: 250m
72
72
  memory: 128Mi
73
73
  limits:
74
- cpu: 300m
74
+ cpu: 500m
75
75
  memory: 256Mi
76
76
 
77
77
  # Annotations to add to the Velero deployment's. Optional.
package/src/helmup.sh CHANGED
@@ -696,13 +696,17 @@ kind: VolumeSnapshotClass
696
696
  metadata:
697
697
  name: cnpg-snapshotclass
698
698
  driver: pd.csi.storage.gke.io
699
- deletionPolicy: Delete
699
+ deletionPolicy: Retain
700
700
  EOSNAPSC
701
701
 
702
702
  sleep 2 # hold up processing for a moment to allow IAM mods to propagate
703
703
  }
704
704
 
705
- function installCronCnpgCleanupSnapshot() {
705
+ # this function is a little convoluted in the way it attempts to install the
706
+ # scripts and yaml necessary for the CNPG cleanup activities - the idea is to
707
+ # be able to update the scripts without touching anything else since the target
708
+ # directory is the cnpg-operator setup
709
+ function installCnpgCleanupCronjob() {
706
710
  CNPG_OPERATOR_DIR="cnpg-operator"
707
711
  if [ ! -d "$CNPG_OPERATOR_DIR" ];
708
712
  then
@@ -713,23 +717,52 @@ CNPG_OPERATOR_MISSING
713
717
  exit 1
714
718
  fi
715
719
 
716
- CNPG_CLEANUP_CRONJOB_YAML="cnpg-cleanup-snapshot-cronjob.yaml"
717
- CNPG_CLEANUP_CRONJOB="$CNPG_OPERATOR_DIR/$CNPG_CLEANUP_CRONJOB_YAML"
718
- if [ ! -f "$CNPG_CLEANUP_CRONJOB" ];
720
+ # create the destination bucket for k8s cronjob scripts
721
+ BUCKET_SUFFIX="k8s-cronjobs"
722
+ makeUniformBucketWithCors $BUCKET_SUFFIX
723
+
724
+ CNPG_CLEANUP_CRONJOB_OVH="cnpg-cleanup-cronjob.yaml.ovh"
725
+ CNPG_CLEANUP_CRONJOB="$CNPG_OPERATOR_DIR/$CNPG_CLEANUP_CRONJOB_OVH"
726
+ CNPG_CLEANUP_SCRIPT_BASH="cnpg-cleanup-script.sh"
727
+ CNPG_CLEANUP_SCRIPT="$CNPG_OPERATOR_DIR/$CNPG_CLEANUP_SCRIPT_BASH"
728
+ if [ ! -f "$CNPG_CLEANUP_SCRIPT" ];
719
729
  then
720
730
  cat<<CNPG_FETCH_CLEANUP_CRONJOB_YAML
721
- `color y "Missing $CNPG_CLEANUP_CRONJOB_YAML - grabbing a copy from build-tools"`
731
+ `color y "Missing $CNPG_CLEANUP_SCRIPT_BASH - updating local cron setup scripts"`
722
732
 
723
733
  CNPG_FETCH_CLEANUP_CRONJOB_YAML
724
734
  CNPG_OP_ROOT="$(build-tools --reporoot)/src/helm-charts/cnpg-operator"
725
- cp $CNPG_OP_ROOT/$CNPG_CLEANUP_CRONJOB_YAML $CNPG_CLEANUP_CRONJOB
735
+ cp $CNPG_OP_ROOT/$CNPG_CLEANUP_CRONJOB_OVH $CNPG_CLEANUP_CRONJOB
736
+ cp $CNPG_OP_ROOT/$CNPG_CLEANUP_SCRIPT_BASH $CNPG_CLEANUP_SCRIPT
726
737
  fi
727
738
 
739
+ # copy / update the script in the bucket referenced in the cronjob
740
+ printf "\ngsutil cp $CNPG_CLEANUP_SCRIPT gs://$GCP_PROJECT_ID-$BUCKET_SUFFIX\n"
741
+ gsutil cp $CNPG_CLEANUP_SCRIPT gs://$GCP_PROJECT_ID-$BUCKET_SUFFIX
742
+
743
+ local CNPG_NAMESPACE="cnpg-operands"
744
+ local CNPG_CLEANUP_SA="cnpg-cleanup-sa"
745
+
746
+ gcloud iam service-accounts create "$CNPG_CLEANUP_SA" \
747
+ --project="$GCP_PROJECT_ID" \
748
+ --description="Used for cronjob cleanup with Workload Identity" \
749
+ --display-name="CNPG Cleanup SA" &> $DEVNULL
750
+ warnOnError $? "the GCP SA $CNPG_CLEANUP_SA may already exist"
751
+
752
+ gcloud projects add-iam-policy-binding "$GCP_PROJECT_ID" \
753
+ --project="$GCP_PROJECT_ID" \
754
+ --member="serviceAccount:$CNPG_CLEANUP_SA@$GCP_PROJECT_ID.iam.gserviceaccount.com" \
755
+ --role="roles/storage.objectViewer"
756
+
757
+ bindWorkloadIdentity "$CNPG_CLEANUP_SA" "$CNPG_NAMESPACE"
758
+
759
+ CNPG_CLEANUP_CRONJOB_YAML="$CNPG_OPERATOR_DIR/$(basename $CNPG_CLEANUP_CRONJOB_OVH .ovh)"
760
+ overwhelm -g # allow ovh -> yaml to occur
728
761
  cat<<CNPG_CLEANUP_CRONJOB_APPLY
729
- `color g "Creating cronjob =>"``color y " kubectl apply -f $CNPG_CLEANUP_CRONJOB"`
762
+ `color g "Creating cronjob =>"``color y " kubectl apply -f $CNPG_CLEANUP_CRONJOB_YAML"`
730
763
 
731
764
  CNPG_CLEANUP_CRONJOB_APPLY
732
- kubectl apply -f $CNPG_CLEANUP_CRONJOB
765
+ kubectl apply -f $CNPG_CLEANUP_CRONJOB_YAML
733
766
  }
734
767
 
735
768
  function ensureCnpgSecret() {
@@ -1001,7 +1034,7 @@ CATBACKUP
1001
1034
  ;;
1002
1035
 
1003
1036
  "cnpg-cronjob")
1004
- installCronCnpgCleanupSnapshot
1037
+ installCnpgCleanupCronjob
1005
1038
  ;;
1006
1039
 
1007
1040
  "cronZombieKiller"|"zombie-killer")
@@ -1,4 +1,8 @@
1
1
  steps:
2
+ - name: 'gcr.io/cloud-builders/docker'
3
+ entrypoint: 'bash'
4
+ args: ['-c', 'docker pull {{imageName}}:latest || exit 0']
5
+
2
6
  - name: 'gcr.io/cloud-builders/docker'
3
7
  args:
4
8
  - 'build'
@@ -6,8 +10,8 @@ steps:
6
10
  - '-t'
7
11
  - '{{imageName}}:{{imageVersion}}'
8
12
  - '--cache-from'
9
- - '{{imageName}}:{{imageVersion}}'
13
+ - '{{imageName}}:latest'
10
14
  - '.'
11
15
 
12
16
  images:
13
- - '{{imageName}}:{{imageVersion}}'
17
+ - '{{imageName}}:{{imageVersion}}'
@@ -1,73 +0,0 @@
1
- apiVersion: v1
2
- kind: ServiceAccount
3
- metadata:
4
- name: cnpg-cleanup-sa
5
- namespace: cnpg-operands
6
- ---
7
- apiVersion: rbac.authorization.k8s.io/v1
8
- kind: Role
9
- metadata:
10
- name: cnpg-cleanup-role
11
- namespace: cnpg-operands
12
- rules:
13
- - apiGroups: ["postgresql.cnpg.io"]
14
- resources: ["backups"]
15
- verbs: ["get", "list", "delete"]
16
- ---
17
- apiVersion: rbac.authorization.k8s.io/v1
18
- kind: RoleBinding
19
- metadata:
20
- name: cnpg-cleanup-rolebinding
21
- namespace: cnpg-operands
22
- subjects:
23
- - kind: ServiceAccount
24
- name: cnpg-cleanup-sa
25
- namespace: cnpg-operands
26
- roleRef:
27
- kind: Role
28
- name: cnpg-cleanup-role
29
- apiGroup: rbac.authorization.k8s.io
30
- ---
31
- apiVersion: batch/v1
32
- kind: CronJob
33
- metadata:
34
- name: cnpg-cleanup-snapshot
35
- namespace: cnpg-operands
36
- spec:
37
- schedule: "0 13 * * *" # 13 UTC is ~8AM EST
38
- successfulJobsHistoryLimit: 2
39
- jobTemplate:
40
- spec:
41
- template:
42
- spec:
43
- serviceAccountName: cnpg-cleanup-sa
44
- restartPolicy: Never
45
- containers:
46
- - name: cnpg-cleanup-snapshots
47
- image: bitnami/kubectl:latest
48
- command:
49
- - "/bin/bash"
50
- - "-c"
51
- - |
52
- echo "Starting CNPG Cleanup"
53
- CURRENT_DATE=$(date +%s)
54
- RETENTION_DAYS=21
55
- SNAPSHOTS_JSON=$(kubectl get backups.postgresql.cnpg.io -n cnpg-operands -o json)
56
- echo "$SNAPSHOTS_JSON" | jq -c '.items[]' | while read -r snapshot
57
- do
58
- NAME=$(echo "$snapshot" | jq -r '.metadata.name')
59
- CREATION_TIMESTAMP=$(echo "$snapshot" | jq -r '.metadata.creationTimestamp')
60
- if [[ "$NAME" != *"-backup-"* ]];
61
- then
62
- echo "Skipping manual snapshot: $NAME"
63
- continue
64
- fi
65
- SNAPSHOT_DATE=$(date -d "$CREATION_TIMESTAMP" +%s)
66
- AGE=$(( (CURRENT_DATE - SNAPSHOT_DATE) / 86400 ))
67
- if [ "$AGE" -gt "$RETENTION_DAYS" ];
68
- then
69
- echo "Deleting snapshot: $NAME (Age: $AGE days)"
70
- kubectl delete backups.postgresql.cnpg.io "$NAME" -n cnpg-operands 2> /dev/null
71
- fi
72
- done
73
- echo "Cleanup complete."
@@ -1,326 +0,0 @@
1
- # https://samber.github.io/awesome-prometheus-alerts/rules#kubernetes
2
- apiVersion: monitoring.coreos.com/v1
3
- kind: PrometheusRule
4
- metadata:
5
- name: awesome-k8s-rules
6
- namespace: prometheus
7
-
8
- spec:
9
- groups:
10
- - name: Awesome Kubernetes
11
- rules:
12
- - alert: KubernetesNodeNotReady
13
- expr: kube_node_status_condition{condition="Ready",status="true"} == 0
14
- for: 10m
15
- labels:
16
- severity: critical
17
- annotations:
18
- summary: Kubernetes Node not ready (instance {{ $labels.instance }})
19
- description: "Node {{ $labels.node }} has been unready for a long time\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
20
-
21
- - alert: KubernetesNodeMemoryPressure
22
- expr: kube_node_status_condition{condition="MemoryPressure",status="true"} == 1
23
- for: 2m
24
- labels:
25
- severity: critical
26
- annotations:
27
- summary: Kubernetes Node memory pressure (instance {{ $labels.instance }})
28
- description: "Node {{ $labels.node }} has MemoryPressure condition\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
29
-
30
- - alert: KubernetesNodeDiskPressure
31
- expr: kube_node_status_condition{condition="DiskPressure",status="true"} == 1
32
- for: 2m
33
- labels:
34
- severity: critical
35
- annotations:
36
- summary: Kubernetes Node disk pressure (instance {{ $labels.instance }})
37
- description: "Node {{ $labels.node }} has DiskPressure condition\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
38
-
39
- - alert: KubernetesNodeNetworkUnavailable
40
- expr: kube_node_status_condition{condition="NetworkUnavailable",status="true"} == 1
41
- for: 2m
42
- labels:
43
- severity: critical
44
- annotations:
45
- summary: Kubernetes Node network unavailable (instance {{ $labels.instance }})
46
- description: "Node {{ $labels.node }} has NetworkUnavailable condition\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
47
-
48
- - alert: KubernetesNodeOutOfPodCapacity
49
- expr: sum by (node) ((kube_pod_status_phase{phase="Running"} == 1) + on(uid, instance) group_left(node) (0 * kube_pod_info{pod_template_hash=""})) / sum by (node) (kube_node_status_allocatable{resource="pods"}) * 100 > 90
50
- for: 2m
51
- labels:
52
- severity: warning
53
- annotations:
54
- summary: Kubernetes Node out of pod capacity (instance {{ $labels.instance }})
55
- description: "Node {{ $labels.node }} is out of pod capacity\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
56
-
57
- # - alert: KubernetesContainerOomKiller
58
- # expr: (kube_pod_container_status_restarts_total - kube_pod_container_status_restarts_total offset 10m >= 1) and ignoring (reason) min_over_time(kube_pod_container_status_last_terminated_reason{reason="OOMKilled"}[10m]) == 1
59
- # for: 0m
60
- # labels:
61
- # severity: warning
62
- # annotations:
63
- # summary: Kubernetes Container oom killer (instance {{ $labels.instance }})
64
- # description: "Container {{ $labels.container }} in pod {{ $labels.namespace }}/{{ $labels.pod }} has been OOMKilled {{ $value }} times in the last 10 minutes.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
65
-
66
- - alert: KubernetesJobFailed
67
- expr: kube_job_status_failed > 0
68
- for: 0m
69
- labels:
70
- severity: warning
71
- annotations:
72
- summary: Kubernetes Job failed (instance {{ $labels.instance }})
73
- description: "Job {{ $labels.namespace }}/{{ $labels.job_name }} failed to complete\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
74
-
75
- - alert: KubernetesJobNotStarting
76
- expr: kube_job_status_active == 0 and kube_job_status_failed == 0 and kube_job_status_succeeded == 0 and (time() - kube_job_status_start_time) > 600
77
- for: 0m
78
- labels:
79
- severity: warning
80
- annotations:
81
- summary: Kubernetes Job not starting (instance {{ $labels.instance }})
82
- description: "Job {{ $labels.namespace }}/{{ $labels.job_name }} did not start for 10 minutes\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
83
-
84
- - alert: KubernetesCronjobSuspended
85
- expr: kube_cronjob_spec_suspend != 0
86
- for: 0m
87
- labels:
88
- severity: warning
89
- annotations:
90
- summary: Kubernetes CronJob suspended (instance {{ $labels.instance }})
91
- description: "CronJob {{ $labels.namespace }}/{{ $labels.cronjob }} is suspended\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
92
-
93
- - alert: KubernetesPersistentvolumeclaimPending
94
- expr: kube_persistentvolumeclaim_status_phase{phase="Pending"} == 1
95
- for: 2m
96
- labels:
97
- severity: warning
98
- annotations:
99
- summary: Kubernetes PersistentVolumeClaim pending (instance {{ $labels.instance }})
100
- description: "PersistentVolumeClaim {{ $labels.namespace }}/{{ $labels.persistentvolumeclaim }} is pending\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
101
-
102
- - alert: KubernetesVolumeOutOfDiskSpace
103
- expr: kubelet_volume_stats_available_bytes / kubelet_volume_stats_capacity_bytes * 100 < 10
104
- for: 2m
105
- labels:
106
- severity: warning
107
- annotations:
108
- summary: Kubernetes Volume out of disk space (instance {{ $labels.instance }})
109
- description: "Volume is almost full (< 10% left)\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
110
-
111
- # - alert: KubernetesVolumeFullInFourDays
112
- # expr: predict_linear(kubelet_volume_stats_available_bytes[6h:5m], 4 * 24 * 3600) < 0
113
- # for: 0m
114
- # labels:
115
- # severity: critical
116
- # annotations:
117
- # summary: Kubernetes Volume full in four days (instance {{ $labels.instance }})
118
- # description: "Volume under {{ $labels.namespace }}/{{ $labels.persistentvolumeclaim }} is expected to fill up within four days. Currently {{ $value | humanize }}% is available.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
119
-
120
- - alert: KubernetesPersistentvolumeError
121
- expr: kube_persistentvolume_status_phase{phase=~"Failed|Pending", job="kube-state-metrics"} > 0
122
- for: 0m
123
- labels:
124
- severity: critical
125
- annotations:
126
- summary: Kubernetes PersistentVolume error (instance {{ $labels.instance }})
127
- description: "Persistent volume {{ $labels.persistentvolume }} is in bad state\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
128
-
129
- - alert: KubernetesStatefulsetDown
130
- expr: kube_statefulset_replicas != kube_statefulset_status_replicas_ready > 0
131
- for: 1m
132
- labels:
133
- severity: critical
134
- annotations:
135
- summary: Kubernetes StatefulSet down (instance {{ $labels.instance }})
136
- description: "StatefulSet {{ $labels.namespace }}/{{ $labels.statefulset }} went down\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
137
-
138
- # - alert: KubernetesHpaScaleInability
139
- # expr: (kube_horizontalpodautoscaler_spec_max_replicas - kube_horizontalpodautoscaler_status_desired_replicas) * on (horizontalpodautoscaler,namespace) (kube_horizontalpodautoscaler_status_condition{condition="ScalingLimited", status="true"} == 1) == 0
140
- # for: 2m
141
- # labels:
142
- # severity: warning
143
- # annotations:
144
- # summary: Kubernetes HPA scale inability (instance {{ $labels.instance }})
145
- # description: "HPA {{ $labels.namespace }}/{{ $labels.horizontalpodautoscaler }} is unable to scale\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
146
-
147
- - alert: KubernetesHpaMetricsUnavailability
148
- expr: kube_horizontalpodautoscaler_status_condition{status="false", condition="ScalingActive"} == 1
149
- for: 0m
150
- labels:
151
- severity: warning
152
- annotations:
153
- summary: Kubernetes HPA metrics unavailability (instance {{ $labels.instance }})
154
- description: "HPA {{ $labels.namespace }}/{{ $labels.horizontalpodautoscaler }} is unable to collect metrics\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
155
-
156
- # - alert: KubernetesHpaScaleMaximum
157
- # expr: (kube_horizontalpodautoscaler_status_desired_replicas >= kube_horizontalpodautoscaler_spec_max_replicas) and (kube_horizontalpodautoscaler_spec_max_replicas > 1) and (kube_horizontalpodautoscaler_spec_min_replicas != kube_horizontalpodautoscaler_spec_max_replicas)
158
- # for: 2m
159
- # labels:
160
- # severity: info
161
- # annotations:
162
- # summary: Kubernetes HPA scale maximum (instance {{ $labels.instance }})
163
- # description: "HPA {{ $labels.namespace }}/{{ $labels.horizontalpodautoscaler }} has hit maximum number of desired pods\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
164
-
165
- - alert: KubernetesHpaUnderutilized
166
- expr: max(quantile_over_time(0.5, kube_horizontalpodautoscaler_status_desired_replicas[1d]) == kube_horizontalpodautoscaler_spec_min_replicas) by (horizontalpodautoscaler) > 3
167
- for: 0m
168
- labels:
169
- severity: info
170
- annotations:
171
- summary: Kubernetes HPA underutilized (instance {{ $labels.instance }})
172
- description: "HPA {{ $labels.namespace }}/{{ $labels.horizontalpodautoscaler }} is constantly at minimum replicas for 50% of the time. Potential cost saving here.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
173
-
174
- - alert: KubernetesPodNotHealthy
175
- expr: sum by (namespace, pod) (kube_pod_status_phase{phase=~"Pending|Unknown|Failed"}) > 0
176
- for: 15m
177
- labels:
178
- severity: critical
179
- annotations:
180
- summary: Kubernetes Pod not healthy (instance {{ $labels.instance }})
181
- description: "Pod {{ $labels.namespace }}/{{ $labels.pod }} has been in a non-running state for longer than 15 minutes.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
182
-
183
- - alert: KubernetesPodCrashLooping
184
- expr: increase(kube_pod_container_status_restarts_total[1m]) > 3
185
- for: 2m
186
- labels:
187
- severity: warning
188
- annotations:
189
- summary: Kubernetes pod crash looping (instance {{ $labels.instance }})
190
- description: "Pod {{ $labels.namespace }}/{{ $labels.pod }} is crash looping\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
191
-
192
- - alert: KubernetesReplicasetReplicasMismatch
193
- expr: kube_replicaset_spec_replicas != kube_replicaset_status_ready_replicas
194
- for: 10m
195
- labels:
196
- severity: warning
197
- annotations:
198
- summary: Kubernetes ReplicaSet replicas mismatch (instance {{ $labels.instance }})
199
- description: "ReplicaSet {{ $labels.namespace }}/{{ $labels.replicaset }} replicas mismatch\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
200
-
201
- - alert: KubernetesDeploymentReplicasMismatch
202
- expr: kube_deployment_spec_replicas != kube_deployment_status_replicas_available
203
- for: 10m
204
- labels:
205
- severity: warning
206
- annotations:
207
- summary: Kubernetes Deployment replicas mismatch (instance {{ $labels.instance }})
208
- description: "Deployment {{ $labels.namespace }}/{{ $labels.deployment }} replicas mismatch\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
209
-
210
- - alert: KubernetesStatefulsetReplicasMismatch
211
- expr: kube_statefulset_status_replicas_ready != kube_statefulset_status_replicas
212
- for: 10m
213
- labels:
214
- severity: warning
215
- annotations:
216
- summary: Kubernetes StatefulSet replicas mismatch (instance {{ $labels.instance }})
217
- description: "StatefulSet does not match the expected number of replicas.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
218
-
219
- - alert: KubernetesDeploymentGenerationMismatch
220
- expr: kube_deployment_status_observed_generation != kube_deployment_metadata_generation
221
- for: 10m
222
- labels:
223
- severity: critical
224
- annotations:
225
- summary: Kubernetes Deployment generation mismatch (instance {{ $labels.instance }})
226
- description: "Deployment {{ $labels.namespace }}/{{ $labels.deployment }} has failed but has not been rolled back.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
227
-
228
- - alert: KubernetesStatefulsetGenerationMismatch
229
- expr: kube_statefulset_status_observed_generation != kube_statefulset_metadata_generation
230
- for: 10m
231
- labels:
232
- severity: critical
233
- annotations:
234
- summary: Kubernetes StatefulSet generation mismatch (instance {{ $labels.instance }})
235
- description: "StatefulSet {{ $labels.namespace }}/{{ $labels.statefulset }} has failed but has not been rolled back.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
236
-
237
- - alert: KubernetesStatefulsetUpdateNotRolledOut
238
- expr: max without (revision) (kube_statefulset_status_current_revision unless kube_statefulset_status_update_revision) * (kube_statefulset_replicas != kube_statefulset_status_replicas_updated)
239
- for: 10m
240
- labels:
241
- severity: warning
242
- annotations:
243
- summary: Kubernetes StatefulSet update not rolled out (instance {{ $labels.instance }})
244
- description: "StatefulSet {{ $labels.namespace }}/{{ $labels.statefulset }} update has not been rolled out.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
245
-
246
- - alert: KubernetesDaemonsetRolloutStuck
247
- expr: kube_daemonset_status_number_ready / kube_daemonset_status_desired_number_scheduled * 100 < 100 or kube_daemonset_status_desired_number_scheduled - kube_daemonset_status_current_number_scheduled > 0
248
- for: 10m
249
- labels:
250
- severity: warning
251
- annotations:
252
- summary: Kubernetes DaemonSet rollout stuck (instance {{ $labels.instance }})
253
- description: "Some Pods of DaemonSet {{ $labels.namespace }}/{{ $labels.daemonset }} are not scheduled or not ready\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
254
-
255
- - alert: KubernetesDaemonsetMisscheduled
256
- expr: kube_daemonset_status_number_misscheduled > 0
257
- for: 1m
258
- labels:
259
- severity: critical
260
- annotations:
261
- summary: Kubernetes DaemonSet misscheduled (instance {{ $labels.instance }})
262
- description: "Some Pods of DaemonSet {{ $labels.namespace }}/{{ $labels.daemonset }} are running where they are not supposed to run\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
263
-
264
- # Threshold should be customized for each cronjob name.
265
- - alert: KubernetesCronjobTooLong
266
- expr: time() - kube_cronjob_next_schedule_time > 3600
267
- for: 0m
268
- labels:
269
- severity: warning
270
- annotations:
271
- summary: Kubernetes CronJob too long (instance {{ $labels.instance }})
272
- description: "CronJob {{ $labels.namespace }}/{{ $labels.cronjob }} is taking more than 1h to complete.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
273
-
274
- - alert: KubernetesJobSlowCompletion
275
- expr: kube_job_spec_completions - kube_job_status_succeeded - kube_job_status_failed > 0
276
- for: 12h
277
- labels:
278
- severity: critical
279
- annotations:
280
- summary: Kubernetes Job slow completion (instance {{ $labels.instance }})
281
- description: "Kubernetes Job {{ $labels.namespace }}/{{ $labels.job_name }} did not complete in time.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
282
-
283
- - alert: KubernetesApiServerErrors
284
- expr: sum(rate(apiserver_request_total{job="apiserver",code=~"(?:5..)"}[1m])) by (instance, job) / sum(rate(apiserver_request_total{job="apiserver"}[1m])) by (instance, job) * 100 > 3
285
- for: 2m
286
- labels:
287
- severity: critical
288
- annotations:
289
- summary: Kubernetes API server errors (instance {{ $labels.instance }})
290
- description: "Kubernetes API server is experiencing high error rate\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
291
-
292
- - alert: KubernetesApiClientErrors
293
- expr: (sum(rate(rest_client_requests_total{code=~"(4|5).."}[1m])) by (instance, job) / sum(rate(rest_client_requests_total[1m])) by (instance, job)) * 100 > 1
294
- for: 2m
295
- labels:
296
- severity: critical
297
- annotations:
298
- summary: Kubernetes API client errors (instance {{ $labels.instance }})
299
- description: "Kubernetes API client is experiencing high error rate\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
300
-
301
- - alert: KubernetesClientCertificateExpiresNextWeek
302
- expr: apiserver_client_certificate_expiration_seconds_count{job="apiserver"} > 0 and histogram_quantile(0.01, sum by (job, le) (rate(apiserver_client_certificate_expiration_seconds_bucket{job="apiserver"}[5m]))) < 7*24*60*60
303
- for: 0m
304
- labels:
305
- severity: warning
306
- annotations:
307
- summary: Kubernetes client certificate expires next week (instance {{ $labels.instance }})
308
- description: "A client certificate used to authenticate to the apiserver is expiring next week.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
309
-
310
- - alert: KubernetesClientCertificateExpiresSoon
311
- expr: apiserver_client_certificate_expiration_seconds_count{job="apiserver"} > 0 and histogram_quantile(0.01, sum by (job, le) (rate(apiserver_client_certificate_expiration_seconds_bucket{job="apiserver"}[5m]))) < 24*60*60
312
- for: 0m
313
- labels:
314
- severity: critical
315
- annotations:
316
- summary: Kubernetes client certificate expires soon (instance {{ $labels.instance }})
317
- description: "A client certificate used to authenticate to the apiserver is expiring in less than 24.0 hours.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"
318
-
319
- - alert: KubernetesApiServerLatency
320
- expr: histogram_quantile(0.99, sum(rate(apiserver_request_duration_seconds_bucket{verb!~"(?:CONNECT|WATCHLIST|WATCH|PROXY)"} [10m])) WITHOUT (subresource)) > 1
321
- for: 2m
322
- labels:
323
- severity: warning
324
- annotations:
325
- summary: Kubernetes API server latency (instance {{ $labels.instance }})
326
- description: "Kubernetes API server has a 99th percentile latency of {{ $value }} seconds for {{ $labels.verb }} {{ $labels.resource }}.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"