Implementing a simple K8s admission controller in Go

What is an admission controller? In a nutshell, Kubernetes admission controllers are plugins that govern and enforce how the cluster is used. They can be thought of as a gatekeeper that intercept (authenticated) API requests and may change the request object or deny the request altogether. The admission control process has two phases: the mutating phase is executed first, followed by the validating phase. Kubernetes admission Controller Phases: An admission controller is a piece of software that intercepts requests to the Kubernetes API server before the persistence of the object (the k8s resource such as Pod, Deployment, Service, etc…) in the etcd database, but after the request is authenticated and authorized....

March 1, 2021 · 8 min · Me

How to setup simple load balancing with IPVS, demo with docker

A few days ago, I was reading about the Kubernetes network model, especially about services and the kube-proxy component, and I discovered that kube-proxy has three modes, which are userspace, iptables and ipvs. The userspace mode is too old and slow, nowaday nobody recommends to use it, the iptables mode is the default mode for kube-proxy with this mode kube-proxy use iptables rules to forward packets that are destined for services to a backend for that services, and the last one is ipvs I did not know what it was so I read about it....

April 6, 2020 · 5 min · Me

How BigCache avoids expensive GC cycles and speeds up concurrent access in Go

A few days ago, I read an article about BigCache and I was interested to know how they avoided these 2 problems: concurrent access expensive GC cycles I went to their repository and read the code to understand how they achieved it. I think it’s amazing so I would like to share it with you. ‘Fast, concurrent, evicting in-memory cache written to keep big number of entries without impact on performance....

October 29, 2019 · 6 min · Me

Implementation of Dijkstra using heap in Go

Simple implementation of Dijkstra using heap in Go. What is Dijkstra? MEGA SHORT DESCRIPTION: Dijkstra’s algorithm to find the shortest path between a and b. It picks the unvisited node with the lowest distance, calculates the distance through it to each unvisited neighbor, and updates the neighbor’s distance if smaller. Mark all nodes unvisited. Create a set of all the unvisited nodes called the unvisited set, in our case we are going to use a set for visited nodes, not for unvisited nodes....

July 21, 2019 · 6 min · Me

Golang: capturing logs and send an email

In my company we have an ETL wrote in Golang to process the integrations with our partners, each integration is executed in an unique and isolate POD using cronjob k8s, each one print a bunch of data and metrics for each step executed using log the package in the standard library, all these logs are useful to monitor the integrations with different tools. In my team now we want to receive an email when some integration is failed with the logs of the process, so for that, we use a feature of log to change the output destination for the standard logger called SetOutput....

June 30, 2019 · 3 min · Me