Skip to content

Instantly share code, notes, and snippets.

View caruccio's full-sized avatar
😐
state = not in mood

Mateus Caruccio caruccio

😐
state = not in mood
View GitHub Profile
@caruccio
caruccio / caddy-insecure-tls-reverse-proxy.md
Last active May 17, 2024 12:32
Caddy insecure tls reverse proxy

This example shows how to access an insecure tls server using a reverse proxy

$ cat insecure-proxy.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: prom-proxy
@caruccio
caruccio / aws-assume-role
Created May 17, 2024 11:53
AWS Assume Role
#!/bin/bash
#
# Install:
# $ echo 'source ~/bin/aws-assume-role' >> ~/.bashrc
#
# Usage:
# $ aws-assume-role [name]
#
# Prerequisite:
# Create an IAM role like this in the account you what access:
@caruccio
caruccio / kubectl-color
Last active October 31, 2024 22:34
Example kubectl plugin
#!/bin/bash
reset="$(tput sgr0)"
bold="$(tput bold)"
red="$(tput setaf 1)"
green="$(tput setaf 2)"
yellow="$(tput setaf 3)"
gray="$(tput setaf 8)"
magenta="$(tput setaf 13)"
@caruccio
caruccio / kubectl-top_node_pod
Created May 12, 2024 12:20
kubectl top pods in a node
#!/bin/bash
function usage()
{
echo Usage: $0 '[--cpu/-c|--memory/-m]' nodes...
echo Sort by memory is the default
exit ${1:-0}
}
node_names=()
@caruccio
caruccio / kubectl-count_objects
Last active May 12, 2024 12:21
Count all objects in a clusters
#!/bin/bash
kubectl api-resources --verbs=list -o name --namespaced=false | while read kind; do
echo -n "$kind: "
kubectl get --ignore-not-found -A $kind | wc -l
done 2>/dev/null
kubectl api-resources --verbs=list -o name --namespaced=true | while read kind; do
echo -n "$kind: "
kubectl get --ignore-not-found -A $kind | wc -l
@caruccio
caruccio / kubectl-evict
Created May 12, 2024 12:17
kube tl evitc <pods...>
#!/bin/bash
function usage()
{
echo Usage: $0 '[--namespace NS/-n NS] [--all/-a|POD...]'
exit $1
}
all_pods=false
pod_names=()
@caruccio
caruccio / kubectl-pfz
Last active September 27, 2024 01:25
Kubectl port-forward with fzf service selector
#!/bin/bash
#
# Install `fzf` and copy this file to your $PATH and use like this:
#
# $ kubectl pfz -n default --open-url mysvc
#
function usage()
{
echo Usage: $0 '[--namespace NS/-n NS] [-o|--open-url] [service...]'
@caruccio
caruccio / kubectl-top_node_pod
Last active May 10, 2024 14:30
Kubectl "top pods-" on a given node
#!/bin/bash
function usage()
{
echo Usage: $0 '[--cpu/-c|--memory/-m]' nodes...
echo Sort by memory is the default
exit ${1:-0}
}
node_names=()
@caruccio
caruccio / kubecfg
Created May 10, 2024 14:27
Use local kubeconfig on dir change
#!/bin/bash
COLOR_LIGHT_GREEN="$(tput setaf 10)"
COLOR_RESET="$(tput sgr0)"
function kubecfg()
{
if [ $# -eq 0 ]; then
echo $KUBECONFIG
return
@caruccio
caruccio / latest-version.md
Last active March 18, 2024 16:22
Print all latest patch-level version

How to get the latest patch-level version from a list of distinct versions using bash and awk. This idea was taken from https://stackoverflow.com/a/21103864/1006369

Supose you have the following list of versions:

v1.22.8
v1.22.9
v1.22.10   <-- latest v1.22 series
v1.23.1