Skip to content

Instantly share code, notes, and snippets.

View microwaves's full-sized avatar

Stephano Zanzin Ferreira microwaves

View GitHub Profile
# Find ghost deleted files from processes
find /proc/*/fd -ls | grep '(deleted)'
# Truncate
: > "/proc/$pid/fd/$fd"
# Remove files older than 5 days
find /path/to/files* -mtime +5 -exec rm {} \;
#You can simulate a rerun by replacing the job with itself:
kubectl get job "your-job" -o json | kubectl replace --force -f -
#If you get errors due to auto-generated labels or selectors, you can delete or edit them with jq:
kubectl get job "your-job" -o json | jq 'del(.spec.selector)' | jq 'del(.spec.template.metadata.labels)' | kubectl replace --force -f -
@microwaves
microwaves / force_delete_namespace.sh
Created June 14, 2019 11:06
remove a namespace stuck on terminating
# In the Master's shell execute:
curl -k -H "Content-Type: application/json" -XPUT --cacert /srv/kubernetes/ca.crt -H "Authorization: Bearer <token>" --data-binary @ns.json https://localhost/api/v1/namespaces/namespace-name/finalize
# The bearer token can be found in the file below, under 'admin':
sudo cat /srv/kubernetes/known_tokens.csv
# Content for ns.json:
{
"kind": "Namespace",
"apiVersion": "v1",
@microwaves
microwaves / gist:b504a7621dc9361e73ac1c71fdc5c3db
Created June 12, 2019 15:31
List prometheus alerts with extended output
amtool --alertmanager.url http://localhost:9093 -o extended alert
@microwaves
microwaves / delete-evicted.sh
Created May 21, 2019 15:54
Delete Evicted Pods in K8S
kubectl get pods -a --all-namespaces -o json | jq '.items[] | select(.status.reason!=null) | select(.status.reason | contains("Evicted")) | "kubectl delete pods \(.metadata.name) -n \(.metadata.namespace)"' | xargs -n 1 bash -c
@microwaves
microwaves / zshrc
Last active May 10, 2019 13:38
fly fancyness for your shell
# fly login
function flo() {
fly login -t $1 -n $2 -c $3 -u $4 -p $5 -k
}
# fly get-pipeline
function fgp() {
fly -t $1 get-pipeline -p $2
}

Keybase proof

I hereby claim:

  • I am microwaves on github.
  • I am szfs (https://keybase.io/szfs) on keybase.
  • I have a public key ASAJex2jmtsD-uxoDKhXWe0ukKV_Q9J7CwKSO__rOSHjbwo

To claim this, I am signing this object:

# To create a k8s configuration description out of whatever command you issue to kubectl, without executing the operation.
kubectl create service externalname --external-name=foo foo -o yaml --dry-run