Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Aaron Schlesinger arschles

🏠
Working from home
View GitHub Profile
@arschles
arschles / ctx.go
Created Aug 26, 2016
Golang 1.7 Contexts
View ctx.go
package main
import (
"context"
"log"
"net/http"
"sync"
"time"
)
View logs.txt
ENG000656:workflow-manager-api aaronschlesinger$ kd logs -f deis-database-sr5al
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
@arschles
arschles / auth_middleware.go
Last active Apr 21, 2016
rudimentary auth middleware
View auth_middleware.go
func WithAuth(tokenToCheck, tokenHeaderName string, next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get(tokenHeaderName) != tokenToCheck {
http.Error(w, "not authorized", http.StatusUnauthorized)
return
}
next.ServeHTTP(w, r)
})
}
@arschles
arschles / controller_logs.txt
Last active Apr 11, 2016
deis-controller flapping
View controller_logs.txt
ENG000656:workflow-e2e aaronschlesinger$ kd logs -f deis-controller-rbexd
system information:
Django Version: 1.9.3
Python 3.5.1
Django checks:
System check identified no issues (2 silenced).
Health Checks:
Checking if database is alive
Database is alive!
Database Migrations:
@arschles
arschles / router_consensus.md
Last active Mar 29, 2016
router consensus protocol
View router_consensus.md

Internal update protocol

  1. When the leader gets a new configuration, it assigns a monotonically increasing version number to it and stores it in a k8s annotation (similar to how the leader election algorithm uses annotations). The version # will be for router-internal use only.
  2. When the leader gets a new configuration, it increments the version, stores it in the annotation, then sends the version along with the new configuration to all other router replicas. Each replica only responds when it has finished updating both its config and version number. If any replica doesn't respond within a reasonable timeout, the leader terminates it.
  3. When a non-leader comes online with a version #, it compares its local known value with that in the annotation. If they don't match, it requests the most up to date version number and config from the leader
  4. When a non-leader comes online with no version, it requests the most up to date version and config from the leader.
  5. If a non-leader gets one or more configurat
@arschles
arschles / deis-demo-notes-2016-01-07.md
Last active Apr 4, 2016
Deis v2 Alpha Demo Notes - January 7, 2016
View deis-demo-notes-2016-01-07.md

We're going to overview the entire process of installing a new Deis cluster on an existing Kubernetes cluster, creating and configuring your app, deploying code, and scaling up.

0: Prerequisites

  • A working Kubernetes cluster on Google Container Engine (Deis, of course, works anywhere Kubernetes can be installed, but the installation instructions in step 1 are tailored to GKE)
  • The Kubernetes client CLI (kubectl) installed on the PATH, and configured to talk to the aforementioned cluster
  • An alias called kd to kubectl --namespace=deis (alias kd="kubectl --namespace=deis" will create it in most shells). This alias will be useful since the Helm Deis chart installs all of the components into the deis namespace
  • The Helm CLI installed on the PATH. Helm is our open source Kubernetes package manager. Find it at https://github.com/helm/helm
  • Ensure you have no installed Helm repository called deis (helm repo remove deis if you do)
  • Ensure no `d
@arschles
arschles / setup_guide.md
Created Dec 29, 2015
k8s setup guide for Deis v2
View setup_guide.md
Name Cloud? Local? Level of Configurability Ease of setup
kube-up.sh on 1.1 Yes Yes High Medium
micro-kube No (technically, I think you can with some extra work, since Vagrant supports spinning up cloud VMs. Instructions not in the micro-kube README though) Yes Low High
GKE Yes No Low High
Digital Ocean using Terraform Yes No Medium  Easy
@arschles
arschles / rm-docker-containers.sh
Created Dec 15, 2015
remove all exited docker containers
View rm-docker-containers.sh
sudo docker ps -a | grep Exited | cut -d ' ' -f 1 | xargs docker rm
@arschles
arschles / monorepo.md
Last active Jan 27, 2020
Why We Should Use Monolithic Repositories
View monorepo.md

I think we should have all our code in a monolithic repository.

I've detailed the big benefits to having one, addressed possible issues to having one, and mentioned a few risks to not moving to a monorepo below.

Benefits To Adopting a Monolithic Repo

Golang package dependencies

  1. Single vendor/ dir at the top level of deis/deis
  2. All internal packages use the same external dependencies
View routes.go
package main
import "github.com/gorilla/mux"
func main() {
r := mux.NewRouter()
r.HandleFunc("/reservations/{key}", func1).Methods("POST")
r.HandleFunc("/values/{key}/{lock_id}", func2).Queries("release", "").Methods("POST")
r.HandleFunc("/values/{key}", func3).Methods("PUT")
You can’t perform that action at this time.