Skip to content

Instantly share code, notes, and snippets.

View LucasRoesler's full-sized avatar

Lucas Roesler LucasRoesler

View GitHub Profile
@LucasRoesler
LucasRoesler / kind-faas-netes-certification.md
Created July 28, 2019 09:27
Running OpenFaaS Certifier for faas-netes in KinD
  1. Start the KinD env and disable auth. In the faas-netes project
make start-kind
export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"

helm upgrade openfaas --install ./chart/openfaas \
    --namespace openfaas  \
    --set basic_auth=false \
--set openfaasImagePullPolicy=IfNotPresent \
#!/usr/bin/env bash
# reset environment variables that could interfere with normal usage
export GREP_OPTIONS=
# put all utility functions here
# make a temporary file
git_extra_mktemp() {
mktemp -t "$(basename "$0")".XXX
}
@LucasRoesler
LucasRoesler / graceful_servers.go
Last active May 10, 2019 07:30
Two possible call signatures for gracefully starting and ending the health server
// ListenAndServeMonitoring starts up an HTTP server serving /metrics and /health.
//
// When the context is cancelled, the server will be gracefully shutdown.
func ListenAndServeMonitoring(ctx context.Context, addr string, healthHandler http.Handler) error {
srv := monitoringServer(addr, healthHandler)
go func() {
<-ctx.Done()
shutdownContext, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

#!/usr/bin/env bash
echo "[0] Install the OF namespaces"
kubectl apply -f https://raw.githubusercontent.com/openfaas/faas-netes/master/namespaces.yml
echo "[1] Setup basic auth"
kubectl -n openfaas create secret generic basic-auth \
--from-literal=basic-auth-user=admin \
--from-literal=basic-auth-password="tester"
echo "[2] update helm chart cache"
helm repo update
  1. Install openfaas using these images
  • Replace the gateway with theaxer/gateway:loggerhandler
  • Replace your provider with theaxer/faas-netes:loggerhandler or theaxer/swarm:loggerhandler

Export the base url to your gateway, e.g.

export gateway=http://localhost:31112
  1. install openfaas with my fork
kubectl apply -f https://raw.githubusercontent.com/openfaas/faas-netes/master/namespaces.yml
helm upgrade openfaas --install openfaas/openfaas \
    --namespace openfaas  \
    --set basic_auth=true \
    --set faasnetesd.image=theaxer/faas-netes:logger \
    --set faasnetesd.imagePullPolicy=IfNotPresent \
@LucasRoesler
LucasRoesler / of-kind.sh
Created February 17, 2019 18:22 — forked from burtonr/of-kind.sh
OpenFaaS on KinD quickstart
#!/bin/bash
echo "> Be KinD with OpenFaaS"
# First, check if docker is available
docker version | 2>/dev/null
if [ $? -ne 0 ]; then
echo "> Docker is required for running OpenFaaS on KinD"
echo "> Install with: 'curl -sLS https://get.docker.com | sudo sh'"
@LucasRoesler
LucasRoesler / raw-docker-logs.sh
Created February 11, 2019 13:56
read docker logs directly from the socket
#!/bin/bash
NAME=go-echo
curl -sN --unix-socket /var/run/docker.sock \
http://./services/$NAME/logs\?tail\=5\&stdout\=1\&stderr\=1\&timestamps\=1\&details\=1
@LucasRoesler
LucasRoesler / of-concurrency-tester.sh
Created February 1, 2019 09:45
Deploy the experimental of-gateway with ingress and basic auth, then run load tests using hey
#!/usr/bin/env bash
GATEWAY=of.dev.contiamo.io
PASSWORD=$(head -c 12 /dev/urandom | shasum| cut -d' ' -f1)
mkdir -p $HOME/Code
cat > "$HOME/Code/of-concurrency-test2.yaml" <<- EndOfMessage
basic_auth: true
functionNamespace: openfaas-fn
exposeServices: false
ingress: