Microblog



February 20, 2024 | 00:00

Kubernetes Downward API

Sometimes you want to expose information about the constraints the container is running without duplicating values or have the application reach out to the Kubernetes API. The Downward API helps with this problem where you can inject pod information to the container via env variables. For example, let’s imagine we want to set the GOMAXPROCS depending on the CPU limit: apiVersion: v1 kind: Pod metadata: name: my-app spec: containers: - name: my-app image: golang resources: requests: memory: "32Mi" cpu: "125m" limits: memory: "64Mi" cpu: "250m" env: - name: GOMAXPROCS valueFrom: resourceFieldRef: containerName: my-app resource: limits. Read more

January 22, 2024 | 00:00

journald RateLimitBurst

Whilst reading An overview of Cloudflare’s logging pipeline, it mentioned that it uses Journald for managing logs on the Linux VM, it mentioned both RateLimitBurst and RateLimitInterval. RateLimitBurst: Number of messages processed in a burst. RateLimitInterval: The window during which the rate limit is applied. For example, the configuration below says that we can log 5 messages every 10 seconds, any more will be dropped. RateLimitBurst=5 RateLimitInterval=10s Why would we want to rate limit logs: Read more

September 13, 2021 | 06:38

What is MTU

Maximum transmission unit (MTU) is the max number of bytes of a data packet that a device can accept. The max size of MTU size is 1500 bytes. What happens when the packet is larger than MTU If the packet is larger than a specified MTU for a specific device it will be dropped off or fragmented into chunks. The packet is fragmented by the sender and adds certain fields in the IP header to indicate that the packet is fragmented. Read more
#TIL | #Go

July 3, 2021 | 11:38

go tool dist list

Imagine that you want to cross-compile your Go binary from your Mac for a Linux machine that runs on arm64 architecture. With Go, it’s a matter of specifying the GOOS and GOARCH environment variables for go build command. GOOS=linux GOARCH=arm64 go build main.go You don’t always know/remember what values for GOOS and GOARCH or you are not even sure if Go supports the target you desire. This is where the command go tool dist list comes in handy, when you run it it will list all the GOOS/GOARCH combinations available for the Go version that you are running. Read more

August 16, 2020 | 19:17

Deploy long-running tasks on Kubernetes

Whilst reading this extremly detailed and well written article about how graceful shutdowns work on Kubernetes. It touched on the subject of long running tasks. When we update the deployment inside of Kubernetes, it will start by deleting a pod with the old version of the image, and starts a new pod with the new version. The pod can be attached to a service it might be the case that the pod is removed from the service before the process/pod has finished. Read more

August 1, 2020 | 21:38

Docker Export vs Docker Save

Docker Export The export takes a snapshot of the container file system and export it’s as a tarball, all container layers are flattened. Any metadata about the entry point is lost, such as ENTRYPOINT and CMD. You can run docker import to create a Docker image from that tarball. Docker Save Creates a tarball on the image and not the container so all the layers are saved, and any metadata around it such as ENTRYPOINT. Read more
#TIL | #Go

July 21, 2020 | 20:03

Go Trace Shortcut

You can use the go trace tool to look at the CPU traces to see how your program is behaving for example. package main import ( "fmt" "os" "runtime/trace" ) func main() { f, err := os.Create("trace.out") if err != nil { panic(err) } defer f.Close() err = trace.Start(f) if err != nil { panic(err) } trace.Stop() fmt.Println("hello") } When you run the program you will see a new file trace. Read more

July 14, 2020 | 07:04

Systemd Drop In

At work, I was debugging an issue where it was failing to update the systemd configuration to the new installation path. By default, systemd service definitions go under /etc/systemd/system/name.service. There are cases where you as an administrator have no control over the service generated. So how do you override a service configuration without overriding the original service or the service definition from scratch? Systemd has a functionality called drop-in units where you can write parts of the service definition and it will override it. Read more