Visualising SQL Server in Kubernetes

This article looks at using a repo on GitHub called KubeDiagrams to visualise objects in Kubernetes.

Visualising SQL Server in Kubernetes

Summary

KubeDiagrams is a repo on GitHub that enables you to generate Kubernetes architecture diagrams from Kubernetes manifest files.

image_pdfimage_print

This article on visualising SQL Server in Kubernetes initially appeared on Andrew Pruski’s blog. It has been republished with the author’s credit and consent. 

The other day, I came across an interesting repo on GitHub, KubeDiagrams.

What this repo does is generate Kubernetes architecture diagrams from Kubernetes manifest files…nice! 

Deploying applications to Kubernetes can get complicated fast…especially with stateful applications such as SQL Server.

So having the ability to easily generate diagrams is really helpful…because we all should be documenting everything, right? 🙂

Plus, I’m rubbish at creating diagrams!

So let’s have a look at how this works. First, install the dependencies via pip: 

And install graphviz: 

Great, now pull down the repo: 

And we’re good to go! So here’s an example manifest file to deploy a SQL Server statefulset to Kubernetes: 

I’m using Docker Desktop here (hence the provisioner: docker.io/hostpath in the storage class). What this will create is a namespace, storage class, headless service for the statefulset, the statefulset itself, three persistent volume claims, and a load balanced service to connect to SQL.

Quite a lot of objects for a simple SQL Server deployment, right? (Ahh, I know it’s a statefulset, but you know what I mean.)

So let’s point KubeDiagrams at the manifest: 

And here’s the output!

Pretty cool, eh?

I noticed a couple of quirks. The docs say it’ll work with any version 3 install of Python. I had 3.8 installed but had to upgrade to 3.9.

Also, I had to add namespace: mssql to the PVCs in the statefulset, otherwise KubeDiagrams threw a warning: 

But other than those, it works really well and is a great way to visualise objects in Kubernetes.

Massive thank you to the creator, Philippe Merle.