Skip to content

Instantly share code, notes, and snippets.

View rogerwelin's full-sized avatar
:shipit:
Gopher

Roger Welin rogerwelin

:shipit:
Gopher
View GitHub Profile

eBPF works lite the JVM, running code instructions in an isolated environment in kernel-space. Compile C to BPF. If the code is safe the BPF program will be loaded into the kernel. Sharing data between the kernel and user-space: BPF maps.

BPF Program Types

  • Tracing - help understand what's happening in the system
  • Networking - inspect and manipulate the network traffic in your system. can let you filter packets coming from the network interface, or even reject those packets completely

View possible tracepoints you can attach BPF programs at: /sys/kernel/debug/tracing/events/

var Version = "dev"
type Message struct {
Msg string `json:"msg"`
Version string `json:"version"`
}
func pingHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
fmt.Fprintf(w, "pong")
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
@rogerwelin
rogerwelin / argo.sh
Last active November 25, 2020 22:05
$ kind create cluster --config kind-config.yaml
# install the Nginx ingress
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/kind/deploy.yaml
# install ArgoCD
$ kubectl create namespace argocd
$ kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
# use port-forwarding to access the ArgoCD UI
FROM golang:1.14 as build
ARG version
WORKDIR /build
COPY . .
RUN CGO_ENABLED=0 go build -ldflags "-X main.Version=$version"
FROM scratch
WORKDIR /app
EXPOSE 8080
COPY --from=build /build/hello-argocd-app .

Controllers - execute business logic.
Resources - provide storage and resources.
Webhooks - defaulting, validation, conversion.

Resource stores stuff --> Controller does stuff.

Resources (example Foo resource) are stored in ETCD by the apiserver. Async watch notifications on object create / delete / update from Foo Resource in ETCD to Foo Controller.

  • Request comes in to Request API - apiserver stores it in ETCD
  • after object is stored apiserver sends watch events to clients watching that Resource type
package main
import (
"fmt"
"net/http"
"sync"
)
type HttpResult struct {
Url string
@rogerwelin
rogerwelin / go-git.go
Last active January 20, 2021 21:52
use go-git & memfs to push files to remote
package main
import (
"fmt"
billy "github.com/go-git/go-billy/v5"
memfs "github.com/go-git/go-billy/v5/memfs"
git "github.com/go-git/go-git/v5"
config "github.com/go-git/go-git/v5/config"
http "github.com/go-git/go-git/v5/plumbing/transport/http"
package main
import (
"io/ioutil"
"gopkg.in/yaml.v2"
)
type config struct {
APIVersion string `yaml:"apiVersion"`
package logger
import (
"log"
"os"
"github.com/fatih/color"
)
var (