Skip to content

Instantly share code, notes, and snippets.

View koenighotze's full-sized avatar
🎯
Focusing

David Schmitz koenighotze

🎯
Focusing
View GitHub Profile
#!/usr/bin/env bash
# when a command fails, bash exits instead of continuing with the rest of the script
set -o errexit
# make the script fail, when accessing an unset variable
set -o nounset
# pipeline command is treated as failed, even if one command in the pipeline fails
set -o pipefail
# enable debug mode, by running your script as TRACE=1
if [[ "${TRACE-0}" == "1" ]]; then set -o xtrace; fi
@koenighotze
koenighotze / istio-dump.sh
Last active January 12, 2021 13:13
Dump virtual service mappings for all namespaces for a Istio service mesh
#!/usr/bin/env bash
for ns in $(kubectl get ns -o=jsonpath='{.items[*].metadata.name}' | sort); do
echo Namespace: $ns
kubectl get vs \
-n $ns ${ns}-master \
-o=jsonpath='{" Destination: "}{.spec.http[*].route[*].destination.host}{"\n Regex mapping:\n "}{range .spec.http[*].match[*]}{.uri.regex}{"\n "}{end}{"\n"}{"\n Prefix mapping:\n "}{range .spec.http[*].match[*]}{.uri.prefix}{"\n "}{end}' 2>/dev/null \
|| echo "No istio virtual services"
echo
echo
function kube_context() {
# could have used $?, but it was easier with a string compare
local ctx=$(kubectl config current-context 2>&1)
if [ "${ctx}" != "error: current-context is not set" ]; then
echo -n "<${ctx}> "
fi
}
function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1/"
@koenighotze
koenighotze / hint.sh
Last active October 3, 2021 12:42
Simple shell script for using https://devhints.io on the command line
#!/usr/bin/env bash
type wget >/dev/null 2>&1 || { echo >&2 "I require wget but it's not installed."; exit 1; }
type mdless >/dev/null 2>&1 || { echo >&2 "I require mdless but it's not installed."; exit 1; }
TOOL=${1:?Usage: hack.sh <toolname> [--refresh]}
REFRESH=${2:-no}
RAW_MD_URL="https://raw.github.com/hazeorid/devhints.io/gh-pages/${TOOL}.md"
@koenighotze
koenighotze / final.tf
Last active March 1, 2018 13:51
Terraform config for automagically configuring a simple EC2 with a LAMP stack
provider "aws" {
region = "eu-west-1"
}
resource "aws_instance" "stage1" {
instance_type = "t2.micro"
ami = "ami-a8d2d7ce"
vpc_security_group_ids = ["${aws_security_group.stage1-sec-group.id}"]
@koenighotze
koenighotze / first_ssh.tf
Created April 26, 2017 14:03
02_basic_ec2_including_ssh
provider "aws" {
region = "eu-west-1"
}
resource "aws_instance" "stage1" {
instance_type = "t2.micro"
ami = "ami-a8d2d7ce"
vpc_security_group_ids = ["${aws_security_group.stage1-sec-group.id}"]
@koenighotze
koenighotze / first.tf
Created April 26, 2017 13:18
01_basic_ec2_instance
provider "aws" {
region = "eu-west-1"
}
resource "aws_instance" "stage1" {
instance_type = "t2.micro"
ami = "ami-a8d2d7ce"
tags {
Name = "stage1"
@koenighotze
koenighotze / simple.tf
Created April 26, 2017 07:31
terraform simple resource
provider "aws" {
region = "eu-west-1"
}
resource "aws_instance" "simple" {
instance_type = "t2.micro"
ami = "ami-a8d2d7ce"
}
@koenighotze
koenighotze / setup.tf
Created April 26, 2017 06:18
terraform_provider
provider "aws" {
region = "eu-west-1"
}

Keybase proof

I hereby claim:

  • I am koenighotze on github.
  • I am koenighotze (https://keybase.io/koenighotze) on keybase.
  • I have a public key whose fingerprint is 1510 007A 7168 BB97 8C1A D04F F374 030E 538F 74DC

To claim this, I am signing this object: