conferences | speakers | series

The clusterfuck hidden in the Kubernetes code base

home

The clusterfuck hidden in the Kubernetes code base
FOSDEM 2019

In this talk we explore the devastating effects using object oriented antipatterns in go while building programs in a monorepo. We look at how we got here in Kubernetes, and how (several years later) we are still working on cleaning up the mess. We explore brilliant refactoring techniques developed because of the original mistakes in Kubernetes.

Unknown to most, Kubernetes was originally written in Java. If you have ever looked at the source code, or vendored a library you probably have already noticed a fair amount of factory patterns and singletons littered throughout the code base. Furthermore Kubernetes is built around various primitives referred to in the code base as “Objects”. In the Go programming language we explicitly did not ever build in a concept of an “Object”. We look at examples of this code, and explore what the code is truly attempting to do. We then take it a step further by offering idiomatic Go examples that we could refactor the pseudo object oriented Go code to.

If the anti patterns weren’t enough we also observe how Kubernetes has over 20 main() functions in a monolithic “build” directory. We learn how Kubernetes successfully made vendoring even more challenging than it already was, and discuss the pitfalls with this design. We look at what it would take to begin undoing the spaghetti code that is the various Kubernetes binaries built from github.com/kubernetes/kubernetes

The audience walks away feeling empathetic that they aren’t alone in their journey to writing idiomatic Go and is now equipped with strong refactoring techniques developed by some of the world’s top engineers for the Kuberentes project.

Speakers: Kris Nova