This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### This script attempts to calculate the skew of the population of pods across the nodes in a Kubernetes cluster. | |
### It takes taints into account, but does not consider pod labels. | |
NAMESPACE="app" | |
_all_nodes=$(kubectl get nodes | wc -l) | |
_all_nodes=$(( _all_nodes - 1 )) | |
for deployment_name in $(kubectl get -n ${NAMESPACE} deployment --template='{{range.items}}{{.metadata.name}}{{"\n"}}{{end}}'); do | |
_deployment=$(kubectl get -n app -o json deployment ${deployment_name} | jq -c '.') | |
_nodeTaintsPolicy=$(echo "${_deployment}" | jq -r '.spec.template.spec.topologySpreadConstraints[0].nodeAffinityPolicy') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test.com | |
test2.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am 76creates on github. | |
* I am 76creates (https://keybase.io/76creates) on keybase. | |
* I have a public key ASBhc_Ur9atjMnsbDFONVKYTsJu90f62NwnGEW7rDopLiAo | |
To claim this, I am signing this object: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This was initially created to calculate the cost of the static infrastructure only | |
# excluding some instance which were dynamic, you can use this to calculate your | |
# instance cost per month and to date cost filtered by regex expression, it does this | |
# for your instances region thus is precise when it comes to cost, tho it uses curent | |
# cost and does not have historical cost data | |
# INSTANCE_RE regex with which we filter instances of interest | |
INSTANCE_RE='^[0-9a-z]{8}-([0-9a-z]{4}-){3}' | |
# INSTANCE_RE_INVERT set to '.' if you want to match regualar, and to 'not' if you want to inverse regex capture | |
INSTANCE_RE_INVERT='not' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
tea "github.com/charmbracelet/bubbletea" | |
"github.com/charmbracelet/lipgloss" | |
"os" | |
) | |
type m struct { | |
s lipgloss.Style |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kd () { | |
kubectl config use-context $( | |
kubectl config get-contexts | awk 'NR == 2 { first=$1 } { if ($1 == "*") { if(getline == 1) { print $2 } else { print first }}}' | |
) | |
} | |
ku () { | |
kubectl config use-context $( | |
kubectl config get-contexts | awk 'BEGIN {previous=0} NR>1 { { if ($1 == "*") { if (previous!=0) {print previous} else { while (getline == 1){} print $2 } } } { previous=$2 } }' | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in order to do a redirection or any response including custom code/header/json body at the same time | |
// order in which they are arranged is important, one will overwrite another and you wont get proper | |
// response, bellow is the order which will allow you to set all 3 | |
// any custom header goes first | |
w.Header().Set( | |
"Location", | |
"http://localhost/something/else | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
If you ever wondered how overlaying works in python curses lib so did I! This is how it works: | |
''' | |
import curses | |
def start(stdscr): | |
# sets up no delay so keys dont overload CPU | |
stdscr.nodelay(False) | |
# no blinking cursor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
URL match > | |
^https?:\/\/([\w\-]+\.)+[a-z]+(\.[a-z]+)?(\/[\w_\-#\.%]+)*?\/?(\?(\w+\=[^&]+(\&\w+\=[^&]+)*))?[^\.]$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yum -y install epel-release | |
yum -y update | |
yum -y install nginx | |
# INSTALLING PYTHON 3.6 | |
yum -y install https://centos7.iuscommunity.org/ius-release.rpm | |
yum -y install python36u python36u-pip python36u-devel python36u-setuptools | |
# SETTING UP IPTABLES | |
iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT |