Skip to content

Instantly share code, notes, and snippets.

View drnic's full-sized avatar
🏆
Platinum Status Level

Dr Nic Williams drnic

🏆
Platinum Status Level
View GitHub Profile
@drnic
drnic / Procfile
Last active February 9, 2020 01:03
Deploy https://jupyter.org/ Jupyter Lab to Cloud Foundry
web: jupyter lab --ip 0.0.0.0 --port $PORT --no-browser
{
"drnic": {"joined": 2012},
"bob": {"joined": 2020}
}
$ kaf generate-secret.yaml
$ k get secret my-internal-secret -n kubecf -ojsonpath='{.data.password}' | base64 --decode
CDVIqCF7LY6dLyEGq10BrzaZfRWGDl8dxSV4vuVz8eDGga8AoP84SEc22Ben25mM

Now rotate secret:

$ kaf rotate-my-internal-secret.yaml
stern -n kube-system -l k8s-app=pi-temperature -s 10m

example

#!/bin/bash
set -u
up() {
INSTANCE_TYPE=${INSTANCE_TYPE:-n1-standard-1}
(
set -x
gcloud compute instances create k3s-1 \
@drnic
drnic / .gitignore
Last active November 8, 2019 02:46
Kubernetes the Hard Way, the Easy Way
kubectl
NAME READY STATUS RESTARTS AGE
cf-operator-7db586b9c6-28pxq 1/1 Running 0 79m
kwt-net 1/1 Running 0 37m
scf-adapter-v1-0 5/5 Running 0 65m
scf-api-v1-0 17/17 Running 11 65m
scf-bits-v1-0 7/7 Running 0 65m
scf-bosh-dns-6b95f54976-7kq9z 1/1 Running 0 66m
scf-bosh-dns-6b95f54976-99qq2 1/1 Running 0 66m
scf-cc-worker-v1-0 5/5 Running 6 65m
scf-database-v1-0 5/5 Running 0 66m
#
# source <(curl https://tinyurl.com/kubectl-aliases -L)
#
# This command is used a LOT both below and in daily life
alias k=kubectl
# Execute a kubectl command against all namespaces
alias kca='f(){ kubectl "$@" --all-namespaces; unset -f f; }; f'
@drnic
drnic / serviceaccount-docker-github.yaml
Created September 20, 2019 10:56
Sample Kubernetes serviceaccount including GitHub (remember to use Personal Auth Token, not Username/Password if you've got 2FA enabled) and Docker Hub. Used for a kpack demonstration.
---
apiVersion: v1
kind: Secret
metadata:
name: dockerhub
annotations:
build.pivotal.io/docker: index.docker.io
type: kubernetes.io/basic-auth
stringData:
username: <username/email>
@drnic
drnic / buildpack-sidecar-walkthru.md
Last active June 19, 2019 14:56
Walk thru for CAB call to create a buildpack for etcd proxy and run it as a Cloud Foundry sidecar

Distributing sidecars with buildpacks

Slides are at https://speakerdeck.com/drnic/distributing-cloud-foundry-sidecars-with-buildpacks

What are sidecars? How to use them in Cloud Foundry? - by Tim Downey

Intro to sidecars from last CAB

  • until recently a running app container only ran and monitored a single process
  • You could manually fork off child processs but they weren’t monitored (static file buildpack starts nginx and also starts cat-ting logs to stdout
  • Secondary processes inside containers are now first class citizens