Skip to content

Instantly share code, notes, and snippets.

Avatar

Dennis Webb denniswebb

  • Blue Sentry, Inc.
  • Memphis, TN
View GitHub Profile
View istio-libressl.yaml
# Prepare cluster
# helm install --name cert-manager --namespace=cert-manager jetstack/cert-manager --version v0.10.1
# kubectl label namespace cert-manager certmanager.k8s.io/disable-validation=true
# kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v0.10.1/cert-manager.yaml
# helm install istio.io/istio-init --name istio-init --namespace istio-system
# helm install istio.io/istio --name istio --namespace istio-system --set-string gateways.istio-ingressgateway.sds.enabled=true
# kubectl label ns default istio-injection=enabled
apiVersion: v1
kind: Service
@denniswebb
denniswebb / k8s-job-from-cron
Created Feb 17, 2018
Run Kubernetes CronJob on Demand
View k8s-job-from-cron
#!/usr/bin/env bash
usage () {
echo "Usage: $(basename "$0") <cronjob_name>"
exit 1
}
if [ -z "$1" ]; then usage; fi
kubectl get cronjob "$1" -ojson | jq '{ "apiVersion": "batch/v1", "kind": "Job", "metadata": {"name": .metadata.name }, "spec": .spec.jobTemplate.spec }' | kubectl apply -f -
@denniswebb
denniswebb / mfaup.sh
Created Feb 13, 2018
Creates MFA AWS Profile for base profile
View mfaup.sh
#!/usr/bin/env bash
token=$1
aws_account=132456
base_profile=work
mfa_profile=workmfa
username=denniswebb
creds=$(aws --profile ${base_profile} sts get-session-token --serial-number arn:aws:iam::${aws_account}:mfa/${username} --duration 129600 --token $token --query "Credentials.[AccessKeyId, SecretAccessKey, SessionToken]" --output text)
View circleci-api.md

Get all repos on CircleCI

curl "https://circleci.com/api/v1.1/projects?circle-token=$CIRCLE_TOKEN" | jq -r '.[] | .username + "/" + .reponame'

Set slack_webhook_url for a single repo

curl -XPUT --header "Content-Type: application/json" "https://circleci.com/api/v1.1/project/github/MyOrg/MyRepo/settings?circle-token=$CIRCLE_TOKEN" -d '{"slack_webhook_url":"https://hooks.slack.com/services/FSFDSFDS?DSFHJKHDFKJSDH"}'

Put it all together to setup webhooks for all of your repos

@denniswebb
denniswebb / k8s-secret-cp
Created Jan 26, 2018
Copy Kubernetes secret from 1 namespace to another
View k8s-secret-cp
#!/usr/bin/env bash
SECRET_NAME=$1
SRC_NS=$2
DST_NS=$3
kubectl -n ${SRC_NS} get secret ${SECRET_NAME} -o yaml | sed "/resourceVersion/d" | sed "/creationTime/d" | sed "/selfLink/d" | sed "/uid/d" | sed "s/namespace: ${SRC_NS}/namespace: ${DST_NS}/g" | kubectl apply -f -
@denniswebb
denniswebb / rancher.yaml
Created Jan 20, 2018
userdata for single host RancherOS
View rancher.yaml
#cloud-config
hostname: rancher-ergon
rancher:
console: debian
services:
rancher-server:
image: rancher/server
command: --db-host mysql.denniswebb.info
restart: always
ports:
@denniswebb
denniswebb / SplitAfterNSize
Created Dec 5, 2017
Golang function to split a string by size on a separator.
View SplitAfterNSize
func StringSplitAfterNSize(s, sep string, size int) (resp []string) {
rl := ""
for _, line := range strings.SplitAfter(s, sep) {
if len(rl+line) > size {
resp = append(resp, rl)
rl = ""
}
rl += line
}
if len(resp) > 0 && len(rl) == 0 {
View field_value_by_tag.go
package main
import "reflect"
func FieldValueByTag(s interface{}, tag, tagValue string) interface{} {
t := reflect.TypeOf(s)
for i := 0; i < t.NumField(); i++ {
if tagValue == t.Field(i).Tag.Get(tag) {
return reflect.ValueOf(s).FieldByName(t.Field(i).Name)
View github_repos.tf
variable "github_token" {}
provider "github" {
organization = "denniswebb"
token = "${var.github_token}"
}
module "datadog-openvpn" {
source = "modules/github"
@denniswebb
denniswebb / github.tf
Created Oct 3, 2017
Terraform module for creating GitHub repositories.
View github.tf
variable "repository_name" {}
variable "auto_init" {
default = true
}
variable "description" {
default = ""
}