Skip to content

Instantly share code, notes, and snippets.

View dmitri-lerko's full-sized avatar

dmitri-lerko

View GitHub Profile
@dmitri-lerko
dmitri-lerko / rules.yaml
Created October 25, 2021 14:57
Dynamic prometheus alert rules based on team label
# List of kube_*_labels metrics - not all of these are useful for alerting.
# kube_certificatesigningrequest_labels
kube_certificatesigningrequest_labels * on (certificatesigningrequest) group_right(label_team) (
...insert expression here
)
# kube_cronjob_labels
kube_cronjob_labels * on (cronjob, namespace) group_right(label_team) (
...insert expression here
)
@dmitri-lerko
dmitri-lerko / Code.gs
Created January 5, 2021 20:50
Auto-populate a column with timestamp when a new row is added
function onEdit(e) {
var row = e.range.getRow();
var col = e.range.getColumn();
if(col === 2 && e.source.getActiveSheet().getName() === "help_requests") {
if(e.source.getActiveSheet().getRange(row, 1).getValue() == "") {
e.source.getActiveSheet().getRange(row, 1).setValue(new Date());
}
}
}
@dmitri-lerko
dmitri-lerko / label_all_gcs_buckets_with_its_own_name.learn
Created June 6, 2020 23:06
Labels all GCS buckets on a project with label bucket:bucket_name for Cost allocation purposes
for bucket in $(gsutil ls -p project_name); do gsutil label ch -l "bucket:$(echo $bucket | cut -c 6- | sed 's/.$//' | sed 's/\./_/g')" $bucket; done
#
# POD linkerd-web-54f586f959-6mjrt (1 of 1)
#
# HELP request_total Total count of HTTP requests.
# TYPE request_total counter
request_total{direction="inbound",tls="no_identity",no_tls_reason="not_provided_by_remote"} 1756
request_total{authority="linkerd-controller-api.linkerd.svc.cluster.local:8085",direction="outbound",dst_control_plane_ns="linkerd",dst_deployment="linkerd-controller",dst_namespace="linkerd",dst_pod="linkerd-controller-789b557586-4pmbb",dst_pod_template_hash="789b557586",dst_service="linkerd-controller-api",dst_serviceaccount="linkerd-controller",tls="true",server_id="linkerd-controller.linkerd.serviceaccount.identity.linkerd.cluster.local"} 536
request_total{authority="linkerd-controller-api.linkerd.svc.cluster.local:8085",direction="outbound",dst_control_plane_ns="linkerd",dst_deployment="linkerd-controller",dst_namespace="linkerd",dst_pod="linkerd-controller-789b557586-lwfvt",dst_pod_template_hash="789b557586",dst_service="linkerd-controller-api",dst_serviceaccount="linkerd-controller
@dmitri-lerko
dmitri-lerko / postmortem-actions.md
Created August 28, 2019 13:13
Google SRE's Postmortem actions
  • Investigate this incident: what happened to cause this incident and why? Determining the root causes is your ultimate goal. Examples: logs analysis, diagramming the request path, reviewing headdumps
  • Mitigate this incident: what immediate actions can we take to resolve and manage this specific event? Examples: rolling back, cherry-picking, pushing configs, communicating with affected users
  • Repair damage from this incident: how can we resolve immediate or collateral damage from this incident? Examples: restoring data, fixing machines, removing traffic re-routes
  • Detect future incidents: how can we the time to accurately detect a similar failure? Examples: monitoring, alerting, plausibility checks on input/output
  • Mitigate future incidents: how can we decrease the severity and/or duration of future incidents like this? How can we reduce the percentage of users affected by this class of failure next time it happens? *Examples: graceful degradation, dropping non-critical resu
@dmitri-lerko
dmitri-lerko / APIs
Last active November 28, 2017 17:19
CKA Preparation
Extra verbosity to see underlying APIs:
kubectl --v=99 get pods busybox
Namespaces:
kubectl get ns
kubectl create ns linux
kubectl get ns/linux -o yaml
kubectl delete ns/linux
Specify PODs namespace: