Skip to content

Instantly share code, notes, and snippets.

View sebnyberg's full-sized avatar
🇸🇪

Sebastian Nyberg sebnyberg

🇸🇪
View GitHub Profile
@sebnyberg
sebnyberg / .bashrc
Last active May 5, 2023 09:08
Basic .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
FROM golang:1.15 as protobuilder
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update \
&& apt-get -y upgrade \
&& apt-get -y install --no-install-recommends \
curl \
unzip \
gcc \
g++ \
@sebnyberg
sebnyberg / ingress.yaml
Created September 15, 2020 15:36
Example ingress protected with AD
# Source: airflow/templates/webserver/webserver-ingress.yaml
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: someapp
annotations:
cert-manager.io/cluster-issuer: "letsencrypt-prod"
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/auth-signin: "https://$host/oauth2/start?rd=$escaped_request_uri"
nginx.ingress.kubernetes.io/auth-url: "https://$host/oauth2/auth"
@sebnyberg
sebnyberg / ingress.yaml
Last active September 15, 2020 15:35
Example ingress protected with AD
# Source: airflow/templates/webserver/webserver-ingress.yaml
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: someapp
annotations:
cert-manager.io/cluster-issuer: "letsencrypt-prod"
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/auth-signin: "https://$host/oauth2/start?rd=$escaped_request_uri"
nginx.ingress.kubernetes.io/auth-url: "https://$host/oauth2/auth"
@sebnyberg
sebnyberg / release.sh
Created September 14, 2020 11:22
Fluxctl release script
#!/bin/bash
#
# release.sh: wait for an image to become available before issuing a flux release
#
set -o errexit
set -o xtrace
# complain to STDERR and exit with error
die() { echo "$*" >&2; exit 2; }
@sebnyberg
sebnyberg / .bashrc
Last active September 13, 2020 12:19
BashRC snippet for printing kubectl config info
color_red="\033[0;31m"
color_yellow="\033[0;33m"
color_green="\033[0;32m"
color_ochre="\033[38;5;95m"
color_blue="\033[0;34m"
color_white="\033[0;37m"
color_reset="\033[0m"
kube_info() {
local current_context=$(kubectl config current-context)
@sebnyberg
sebnyberg / placeholders.go
Created June 2, 2020 13:04
go test -bench=.
package placeholders
import (
"fmt"
"strings"
)
func Original(columns []string) string {
questionMarks := []string{}
for _, _ = range columns {
@sebnyberg
sebnyberg / helmfile.yaml
Last active June 1, 2020 14:07
oauth2-proxy example
repositories:
- name: stable
url: https://kubernetes-charts.storage.googleapis.com
releases:
- name: {{ requiredEnv "SERVICE_NAME" }}-oauth2-proxy
namespace: {{ requiredEnv "NAMESPACE" }}
cleanupOnFail: true
chart: stable/oauth2-proxy
# kubeContext: somecontext
@sebnyberg
sebnyberg / go_cpu_memory_profiling_benchmarks.sh
Last active March 6, 2023 11:10 — forked from arsham/go_cpu_memory_profiling_benchmarks.sh
Go cpu and memory profiling benchmarks. #golang #benchmark
FILENAME=$(basename $(pwd))
go test -run=. -bench=. -cpuprofile=cpu.out -benchmem -memprofile=mem.out -trace trace.out
go tool pprof -pdf $FILENAME.test cpu.out > cpu.pdf && open cpu.pdf
go tool pprof -pdf --alloc_space $FILENAME.test mem.out > alloc_space.pdf && open alloc_space.pdf
go tool pprof -pdf --alloc_objects $FILENAME.test mem.out > alloc_objects.pdf && open alloc_objects.pdf
go tool pprof -pdf --inuse_space $FILENAME.test mem.out > inuse_space.pdf && open inuse_space.pdf
go tool pprof -pdf --inuse_objects $FILENAME.test mem.out > inuse_objects.pdf && open inuse_objects.pdf
go tool trace trace.out
go-torch $FILENAME.test cpu.out -f ${FILENAME}_cpu.svg && open ${FILENAME}_cpu.svg
@sebnyberg
sebnyberg / minio-with-ingress.yaml
Last active May 24, 2020 21:47
MinIO on AKS with ingress
repositories:
- name: stable
url: https://kubernetes-charts.storage.googleapis.com
releases:
- name: miniotest
namespace: minio
cleanupOnFail: true
chart: stable/minio
kubeContext: mycluster-admin