Skip to content

Instantly share code, notes, and snippets.

View zulhfreelancer's full-sized avatar

Zulhilmi Zainudin zulhfreelancer

View GitHub Profile
@zulhfreelancer
zulhfreelancer / how-to-install-mysql2-053-gem-on-ruby-278-homebrew-mysql-80-environment.md
Last active October 27, 2024 14:43
How to install mysql2 0.5.3 gem on Ruby 2.7.8 + Homebrew MySQL 8.0 environment

How to install mysql2 0.5.3 gem on Ruby 2.7.8 + Homebrew MySQL 8.0 environment

# this is installed via asdf
$ ruby -v
ruby 2.7.8p225 (2023-03-30 revision 1f4d455848) [x86_64-darwin24]

$ brew list --versions | grep mysql
mysql-client 9.0.1
[email protected] 8.0.39
@zulhfreelancer
zulhfreelancer / find-pod-by-uid.md
Last active October 3, 2024 02:29
How to find a pod by UID?

How to find a pod by UID?

Option #1

kubectl get pods -A -o json | jq -r '.items[] | select(.metadata.uid == "<UID>") | .metadata.name, .metadata.namespace'

Option #2

@zulhfreelancer
zulhfreelancer / run-psql-in-kubernetes.md
Created September 14, 2024 15:58
How to run a temporary psql container in Kubernetes for testing/debugging?

How to run a temporary psql container in Kubernetes for testing/debugging?

$ k run psql-client --rm -i --tty --image jbergknoff/postgresql-client --command /bin/sh
/ # which psql
/usr/bin/psql

/ # psql --version
psql (PostgreSQL) 12.3
@zulhfreelancer
zulhfreelancer / sort-htop-by-cpu-memory.md
Created September 10, 2024 06:34
How to sort `htop` by CPU or Memory?

How to sort htop by CPU or Memory?

Sort by CPU

htop -s PERCENT_CPU

Sort by Memory / RAM

@zulhfreelancer
zulhfreelancer / find-pods-image-pull-secrets.sh
Created August 19, 2024 04:00
Find pods that use specific image pull secret
# Replace the THE_SECRET_NAME
k get pods -A -o json | jq -r '.items[] | select(.spec.imagePullSecrets!=null) | select(.spec.imagePullSecrets[].name=="THE_SECRET_NAME") | {namespace: .metadata.namespace, name: .metadata.name}'
@zulhfreelancer
zulhfreelancer / list-clusterissuers.sh
Created August 15, 2024 07:09
List all DNS01 ClusterIssuers and provider names using `kubectl`
kubectl get clusterissuers -o json | jq -r '.items[] | select(.spec.acme != null) | select(.spec.acme.solvers[0] | keys[0]=="dns01") | {name: .metadata.name, provider: (.spec.acme.solvers[0].dns01 | keys[0])}'
@zulhfreelancer
zulhfreelancer / ipv4-brief-summary-linux.md
Created June 3, 2024 02:05
How to displays a brief summary of all IPv4 addresses assigned to the network interfaces Linux system?

How to displays a brief summary of all IPv4 addresses assigned to the network interfaces Linux system?

Command:

ip -4 -br a

Sample output:

@zulhfreelancer
zulhfreelancer / check-network-interface.md
Created June 3, 2024 01:55
How to check which network interface will be used to route/send packets for specific IP address?

How to check which network interface will be used to route/send packets for specific IP address?

# Install `ip` tool
apt update -y
apt install iproute2 -y

# Check
ip r get 8.8.8.8 fibmatch
@zulhfreelancer
zulhfreelancer / get-all-prometheus-metrics.md
Last active May 16, 2024 06:41
Get all Prometheus metrics and descriptions/help texts

Get all Prometheus metrics and descriptions/help texts

Requirement:

As JSON

curl -sg 'http://prom-server:prom-port/api/v1/metadata' | jq -r '.data'
@zulhfreelancer
zulhfreelancer / how-to-install-promtool.md
Created April 4, 2024 04:07
How to install promtool by Prometheus?

How to install promtool by Prometheus?

# Fetch latest version
TAG=$(curl -s https://api.github.com/repos/prometheus/prometheus/releases | jq -r '.[] | .tag_name' | head -n 1)
echo $TAG

# Remove the `v` prefix
VERSION=$(echo $TAG | sed 's/v//')
echo $VERSION