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 \
| #!/bin/sh | |
| # Quick Migration Script to convert a PostMan Collection OpenAPI 3.x into a compatible IBM APIC Import | |
| # Author: Sanjay Joshi (joshisa(AT)us.ibm.com) | |
| # Version: 0.5 | |
| # Orig Date: Dec. 11, 2024 | |
| # Latest Edit Date: Jan 8, 2025 | |
| # EXAMPLE | |
| # COLLECTIONID: 18514645-20754862-8c19-45c8-9844-dda0967e4deb | |
| # POSTMAN COLLECTION WEB URL: https://www.postman.com/metaverse9000/book-store/collection/9urcs5u/collection-simple-book-api?ctx=info |
| /** | |
| * 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 |
| #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 |
| #!/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`? |
| #!/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 |
| 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', |