Skip to content

Instantly share code, notes, and snippets.

View joshisa's full-sized avatar
🎯
Focusing

Sanjay Joshi joshisa

🎯
Focusing
View GitHub Profile
@joshisa
joshisa / app.js
Created October 7, 2021 14:10 — forked from StephenFluin/app.js
Sample Trello node.js Webhook Server
/**
* This is a sample webhook server that listens for webhook
* callbacks coming from Trello, and updates any cards that are
* added or modified so everyone knows they are "PRIORITY"
*
* To get started
* * Add your key and token below
* * Install dependencies via `npm install express request body-parser`
* * Run `node app.js` on a publicly visible IP
* * Register your webhook and point to http://<ip or domain>:3123/priority
@joshisa
joshisa / oc command lines
Created July 8, 2021 17:59 — forked from sudhirpandey/oc command lines
openshift command line with Go templating and others
#expose console from 443
oc create route reencrypt master --service kubernetes --port 443 -n default
#nested loops , tags count in IS
oc get is --template='{{range $i, $is:=.items}}{{ $total :=0 }}{{ range $index, $element :=$is.status.tags }}{{if eq $element.tag "latest"}}{{$is.metadata.name}}{{"\t"}}{{ $index }}{{end}}{{end}}{{"\n"}}{{end}}'
get complex labels
oc get nodes --template='{{ with $i := index .items 0 }}{{ index $i.metadata.labels "failure-domain.beta.kubernetes.io/region" }}{{ end }}'
#patchin resource limits
@joshisa
joshisa / kubectl-one-liners.md
Created May 21, 2021 17:09 — forked from mikejoh/kubectl-one-liners.md
Yet another kubectl one-liners

kubectl one-liners

Enable kubectl completion (needs the bash-completion package):

source <(kubectl completion bash)

Dry-run, outputs Service (--expose) and a Deployment in yaml:

kubectl run --image=apache \ 
--port=80 \
@joshisa
joshisa / README.md
Created March 5, 2020 17:34 — forked from joyrexus/README.md
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")
#!/bin/bash
# Scale DOWN all Turbonetes PODs to 0
function turbo_stop_all_pods {
turbo_stop_all_pods=$(kubectl get deploy -n turbonomic --no-headers=true | cut -d ' ' -f1 | xargs -I % kubectl scale --replicas=0 deployment/% -n turbonomic)
while true; do
if `kubectl get pods -n turbonomic | grep -v STATUS | wc -l` -gt 0 then
echo -e "turbo_STOP_all_pods: Waiting on Turbonetes POD(s) to TERMINATE, so far: \n`kubectl get pods -n turbonomic | grep -v NAME`"
elif
[[ "$counter" -gt 30 ]]; then;
echo "MAX Counter Reached! One or more PODs are stuck ##TERMINATING##, intervening to kill it/them"
Add the following in .zshrc:
...
plugins=(osx git zsh-autosuggestions zsh-syntax-highlighting zsh-nvm docker kubectl)
...
### Fix slowness of pastes with zsh-syntax-highlighting.zsh
pasteinit() {
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`?
@joshisa
joshisa / pcfusage.sh
Created September 26, 2019 14:47
Uses CF API and jq magic (to parse JSON responses) to create an CSV file with information about orgs, spaces, apps and services.
#!/bin/bash
PREFIX=dev
#set -e
usage_and_exit() {
cat <<EOF
Usage: pcfusage <PREFIX> <CMD>[ALL|test] <CSV>[yes/NO]
Examples:
pcfusage dev - defaults to ALL and NO
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
ingress.kubernetes.io/affinity: cookie
ingress.kubernetes.io/rewrite-target: /
ingress.kubernetes.io/add-base-url: 'true'
ingress.kubernetes.io/ssl-redirect: 'true'
ingress.kubernetes.io/session-cookie-hash: sha1
ingress.kubernetes.io/session-cookie-name: route
@joshisa
joshisa / loki_example_main.jsonnet
Created December 13, 2018 18:20
Loki Main jsonnet example
local base = import "../base.libsonnet";
//local k = import "k.libsonnet";
local promtail = import 'promtail/promtail.libsonnet';
base + promtail + {
_config+:: {
namespace: 'loki',
promtail_config: {
scheme: 'https',
hostname: 'logs-us-west1.grafana.net',
@joshisa
joshisa / test-aws-ebs-claim.yaml
Created November 27, 2018 18:34
aws-ebs-test-claim
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: ebs-test-claim
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Mi