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
caruccio / kubectl.md
Created May 7, 2019 — forked from so0k/kubectl.md
Playing with kubectl output
View kubectl.md

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
caruccio / getopts.md
Created Apr 9, 2019
Read shell options with positional arguments
View getopts.md

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
force=false
help=false
log=info
ARGS=() ### this array holds any positional arguments, i.e., arguments not started with dash

while [ $# -gt 0 ]; do
@caruccio
caruccio / bash-reload.sh
Last active Jun 25, 2019
Reload shell config in-place
View bash-reload.sh
## 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 https://learn.hashicorp.com/vault/getting-started/install
## lets check if any command `hello` exists
$ hello
bash: hello: command not found
@caruccio
caruccio / spread.sh
Last active Sep 26, 2018
Spread parameters
View spread.sh
$ function spread_parameter {
local p="$1"
shift
local IFS=","
eval "echo $(echo "$p\ {$*}")"
}
$ spread_parameter --include '*.jpg' '*.gif' '*.svg'
--include *.jpg --include *.gif --include *.svg
@caruccio
caruccio / on.sh
Created Aug 24, 2018
kubectl namespace switcher
View on.sh
# Switch kubernetes namespaces withou touching ~/.kube/config
# Example:
#
# $ on kube-system
# NAME STATUS AGE
# kube-system Active 1y
# $ k get pod
#
on()
@caruccio
caruccio / remove-stale-containers.py
Created Mar 25, 2018
Remove stale dockershim containers
View remove-stale-containers.py
#!/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
caruccio / migrate-pv-to-zone.sh
Last active Aug 19, 2019
Migrate EBS Volume based PVs across AWS availability zones
View migrate-pv-to-zone.sh
#!/bin/bash
set -eu
NAMESPACE=$1
PVCNAME=$2
TARGETZONE=$3
DEPLOYMENTOBJ=$4
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)
View keybase.md

Keybase proof

I hereby claim:

  • I am caruccio on github.
  • I am caruccio (https://keybase.io/caruccio) on keybase.
  • I have a public key ASD6Us-tApW2y3pqe9q7ruqypYAF289oNQQXUWVX5fcE0go

To claim this, I am signing this object:

@caruccio
caruccio / underlinize.md
Created Jul 26, 2017
Converting text to single char
View underlinize.md

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
caruccio / mariadb-galera-persistent-template.yml
Last active May 24, 2017
MariaDB Galera Cluster Openshift Template
View mariadb-galera-persistent-template.yml
# Source: https://github.com/getupcloud/openshift-mariadb-galera/blob/master/mariadb-galera-persistent-template.yml
---
kind: Template
apiVersion: v1
metadata:
name: mariadb-galera-persistent
annotations:
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.