Skip to content

Instantly share code, notes, and snippets.

!In the mood

Mateus Caruccio caruccio

!In the mood
Block or report user

Report or block caruccio

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
caruccio /
Created May 7, 2019 — forked from so0k/
Playing with kubectl output

Kubectl output options

Let's look at some basic kubectl output options.

Our intention is to list nodes (with their AWS InstanceId) and Pods (sorted by node).

We can start with:

kubectl get no
caruccio /
Created Apr 9, 2019
Read shell options with positional arguments

This example shows how to read options and positional arguments from a bash script (same principle can be applied for other shells).

# some global var we want to overwrite with options
ARGS=() ### this array holds any positional arguments, i.e., arguments not started with dash

while [ $# -gt 0 ]; do
caruccio /
Last active Jun 25, 2019
Reload shell config in-place
## Ever had to add something to your shell's config files (i.e. .bashrc)
## and open a new shell? Well, that may be fine, but you can achieve the
## same result, plus without having to open a new window/tab
## or execute a child process.
## Idea taken from
## lets check if any command `hello` exists
$ hello
bash: hello: command not found
caruccio /
Last active Sep 26, 2018
Spread parameters
$ function spread_parameter {
local p="$1"
local IFS=","
eval "echo $(echo "$p\ {$*}")"
$ spread_parameter --include '*.jpg' '*.gif' '*.svg'
--include *.jpg --include *.gif --include *.svg
caruccio /
Created Aug 24, 2018
kubectl namespace switcher
# Switch kubernetes namespaces withou touching ~/.kube/config
# Example:
# $ on kube-system
# kube-system Active 1y
# $ k get pod
caruccio /
Created Mar 25, 2018
Remove stale dockershim containers
#!/usr/bin/env python
## If you see messages like this on your kubelet journal:
## Mar 25 22:36:44 ip-10-0-3-67.ec2.internal dockerd-current[28612]: time="2018-03-25T22:36:44.419126265Z" level=error msg="Handler for GET /v1.24/containers/60532fa8184bdf41e52788194faa1253f1168e3ad4f54f7c159192fe66c4bb1d/json returned error: No such container: 60532fa8184bdf41e52788194faa1253f1168e3ad4f54f7c159192fe66c4bb1d"
## use this script to remove dockershim container files from /var/lib/dockershim/sandbox
import os, glob, subprocess
caruccio /
Last active Aug 19, 2019
Migrate EBS Volume based PVs across AWS availability zones
set -eu
PVNAME=$(oc -n $NAMESPACE get pvc $PVCNAME --template={{.spec.volumeName}})
VOLUMEID=$(oc -n $NAMESPACE get pv $PVNAME --template={{.spec.awsElasticBlockStore.volumeID}} | cut -d/ -f 4)

Keybase proof

I hereby claim:

  • I am caruccio on github.
  • I am caruccio ( on keybase.
  • I have a public key ASD6Us-tApW2y3pqe9q7ruqypYAF289oNQQXUWVX5fcE0go

To claim this, I am signing this object:

caruccio /
Created Jul 26, 2017
Converting text to single char

Check ou this trick to convert any text into a sequence of chars of the same length

$ MESSAGE="Some arbitrary message to convert into dashes"
$ echo "$MESSAGE" | tr "$MESSAGE" -

I like to use it to "underlinize" titles on my scripts

caruccio / mariadb-galera-persistent-template.yml
Last active May 24, 2017
MariaDB Galera Cluster Openshift Template
View mariadb-galera-persistent-template.yml
# Source:
kind: Template
apiVersion: v1
name: mariadb-galera-persistent
description: MariaDB Galera cluster persistent (NFS)
iconClass: icon-mariadb
tags: database,mysql,replication,mariadb,galera,nfs
You can’t perform that action at this time.