Skip to content

Instantly share code, notes, and snippets.

View zulhfreelancer's full-sized avatar

Zulhilmi Zainudin zulhfreelancer

View GitHub Profile
@zulhfreelancer
zulhfreelancer / install-docker.md
Last active May 11, 2024 22:28
Install Docker oneliner script

Just install Docker

$ curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh

Install Docker and Rancher Server

$ curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh && sudo docker run -d --restart=unless-stopped -p 8080:8080 rancher/server

@zulhfreelancer
zulhfreelancer / show-all-docker-build-logs.md
Created June 1, 2023 08:25
How to show all `docker build` logs?

How to show all docker build logs?

docker build -t YOUR-USER-NAME/YOUR-REPO:<YOUR-IMAGE-TAG> --no-cache --progress=plain .
@zulhfreelancer
zulhfreelancer / nginx-controller-certificate-signed-by-unknown-authority-error.md
Created June 27, 2023 04:42
How to fix Nginx ingress controller "certificate signed by unknown authority" error?

Problem

How to fix Nginx ingress controller "certificate signed by unknown authority" error?

Error:

"Internal error occurred: failed calling webhook \"validate.nginx.ingress.kubernetes.io\": failed to call webhook: Post \"https://nginx-ingress-ingress-nginx-controller-admission.default.svc:443/networking/v1/ingresses?timeout=10s\": x509: certificate signed by unknown authority"
@zulhfreelancer
zulhfreelancer / server-public-ip.md
Last active May 8, 2024 01:54
How to quickly get server's public IP address?

How to quickly get server's public IP address?

The curl / wget way

$ curl http://icanhazip.com
# or
$ wget -qO- http://icanhazip.com | xargs echo
@zulhfreelancer
zulhfreelancer / yaml-to-json-yq.md
Last active April 26, 2024 21:23
How to convert YAML to JSON using yq?

How to convert YAML to JSON using yq?

FYI, I'm using yq version 4 by mikefarah

Command:

cat <YAML-FILE-NAME> | yq e -j
@zulhfreelancer
zulhfreelancer / kubectl-jq-select-not-null.sh
Last active April 17, 2024 02:50
kubectl/jq - How to select/filter not `null` objects?
# List all deleted pods
kubectl get pods -o json | jq -r '.items[] | select(.metadata.deletionTimestamp != null)'
@zulhfreelancer
zulhfreelancer / query-prometheus-from-cli.md
Last active April 4, 2024 04:13
How to query Prometheus from local CLI / Terminal

How to query Prometheus from local CLI / Terminal

Requirements

promtool - see installation steps here

Command

promtool query instant '' '' | jq
@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
@zulhfreelancer
zulhfreelancer / kubectl-apply-stdin.md
Last active March 22, 2024 14:17
How to run "kubectl apply -f" with inline YAML as stdin?
$ kubectl apply -f - <<EOF
<-- insert YAML content here -->
EOF

OR

$ cat file.yaml | kubectl apply -f -
@zulhfreelancer
zulhfreelancer / kubectl-jq-filter-nodes-by-label.md
Created March 20, 2024 01:46
How to filter Kubernetes nodes by label using kubectl and jq

How to filter Kubernetes nodes by label using kubectl and jq

# Get all control-plane nodes
kubectl get nodes -o json | jq -r '.items[] | select(.metadata.labels."node-role.kubernetes.io/control-plane"=="true").metadata.name'

# Get all worker nodes
kubectl get nodes -o json | jq -r '.items[] | select(.metadata.labels."node-role.kubernetes.io/control-plane"!="true").metadata.name'