Skip to content

Instantly share code, notes, and snippets.

View teymurgahramanov's full-sized avatar
🚀
Harder, Better, Faster, Stronger

Teymur Gahramanov teymurgahramanov

🚀
Harder, Better, Faster, Stronger
View GitHub Profile
@teymurgahramanov
teymurgahramanov / opencode.jsonc
Last active September 21, 2026 14:54
My OpenCode configuration file (Simplified)
{
"$schema": "https://opencode.ai/config.json",
"model": "openai/gpt-5.6-luna",
"small_model": "opencode/nemotron-3.5-lightning-free",
"default_agent": "build",
"subagent_depth": 1,
// Default deny; each safe capability is explicitly granted below.
"permission": {
"*": "deny",
@teymurgahramanov
teymurgahramanov / get-kube-volumes.sh
Last active September 4, 2023 14:20
Get the list of GlusterFS volumes, PVCs, and list of Helm Chart releases that use them
for pv in $(kubectl get pv -o custom-columns="NAME:.metadata.name" --no-headers); do
GLUSTERFS_PATH=$(kubectl get pv -A $pv -o yaml | yq .spec.glusterfs.path)
PVC_NAME=$(kubectl get pv $pv -o yaml | yq .spec.claimRef.name)
USED_BY=()
for chart in $(kubectl get deployments --all-namespaces -o=json | \
jq --arg pvc "$PVC_NAME" -r '.items[] | select(.spec.template.spec.volumes[]?.persistentVolumeClaim.claimName == $pvc) | .metadata.annotations."meta.helm.sh/release-name"'); do
USED_BY+=($chart)
done
echo "$GLUSTERFS_PATH,$PVC_NAME,${USED_BY[*]}"
done
@teymurgahramanov
teymurgahramanov / README.md
Last active February 14, 2024 06:46
Prometheus alerts based on resource labels via Alertmanager

Prometheus alerts based on resource labels via Alertmanager

Assume that you have several development teams which are work on the same Kubernetes cluster and each team need to get alerts only related to their projects. For example, team "A" should only get alerts if there are any unhealthy pods with labels team: A and app: app1 or app: app2

Requirements:

  • Appropriate labels on your pods
  • kube-state-metrics (tested with 2.4.2 version) with argument --metric-labels-allowlist=pods=[*]
  • Prometheus job for pods
  • Prometheus rule which will join pod labels from kube_pod_labels to metric e.g.
kubectl run troubleshoot-curl --image=curlimages/curl --rm -it --restart=Never -- curl -XPOST http://alertmanager.infra:9093/api/v1/alerts -d '[{"status": "firing","labels": {"alertname": "Test alert","env":"prod","service": "dummy","severity": "critical","instance": "1"},"annotations": {"summary": "This is a test alert.","description": "This is a description for test alert."},"generatorURL": "http://prometheus.example.com"}]'
@teymurgahramanov
teymurgahramanov / README.md
Last active November 18, 2022 13:40
Solution of empty database problem after gitlab-ctl pg-upgrade

Solution of empty database problem after gitlab-ctl pg-upgrade

Сase:

Unable to upgrade GitLab 13.X.X (Linux package) to 14.X.X because it does not support PostgreSQL version less than 12 (Current 11). Tried to upgrade PostgreSQL using gitlab-ctl pg-upgrade -V 12 as described in Upgrade packaged PostgreSQL server.

Expected behavior

This updates PostgreSQL to the default shipped version during package upgrades, unless specifically opted out.

Current behavior

gitlab-ctl pg-upgrade -V 12 finishes successfully but ends with an empty database and GitLab acts as if a fresh install.

@teymurgahramanov
teymurgahramanov / README.md
Last active October 25, 2022 19:47
Dynamic HTML Table with Jinja2

Dynamic HTML Table with Jinja2

The Jinja2 template snippet for generating HTML table, based on data retrieved from the database.

In this example, assumed that we have two lists:

  • db_data_columns for columns
  • db_data_rows for rows
@teymurgahramanov
teymurgahramanov / README.md
Last active October 18, 2022 12:29
Kubernetes dynamic secret for Image Registry using Helm and Gitlab

Kubernetes dynamic secret for Image Registry using Helm and Gitlab

Instead of manually creating secret for pulling images from Image Registry we can generate it using variables during pipeline.

For example assume that:

  • your template for secret is as example-helm-secret-template.yaml
  • you have $DOCKER_USER $DOCKER_PASSWORD variables.
  • you are using Gitlab Container Registry

Just add this override to helm install command:

@teymurgahramanov
teymurgahramanov / README.md
Last active October 14, 2022 12:06
Ansible change password of current user on fly

Ansible change password of current user on fly

You also can change other connection parameters in this way during playbook execution.

@teymurgahramanov
teymurgahramanov / README.md
Last active October 14, 2022 11:52
Ansible handler to reload and check systemd's service status

Ansible handler to reload and check systemd's service status

@teymurgahramanov
teymurgahramanov / README.md
Last active October 15, 2022 10:16
Bulk copy of Ansible templates

Bulk copy of Ansible templates

Snippet for copying Ansible templates along with other file types preserving directory structure defined under role's "templates".