Originally, this was just samples of stuff I have been playing with in Python. This is now primarily a testing and experimenting application for Kubernetes cluster administration, particularly as preparation to sit for the Cerified Kubernetes Administrator (CKA) exam.
The original project was all about a little framework for building
command-line utility tools. I got tired of constantly re-inventing my
own boilerplate code, and I didn't like any of the frameworks out there.
I was inspired by some libraries like click
, but they were too much.
So this is just enough framework for my needs.
While the demo was originally just some basic python modules, when I started consulting at Taos Mountain they encouraged me to learn Google Cloud and Docker. To help me learn that, I converted this little framework's sample app into docker containers, then a docker-compose stack.
I now have this running in Kubernetes. It should run in pretty much any K8s cluster. Some of my favorites for local development on my Macbook Pro:
- Kubernetes on Vagrant boxes
- minikube
- Rancher Desktop
My current personal preference is using an elegant vagrant setup from TechieCamp.
The application includes
a tiny REST server
that returns a simple JSON list of fruits, so I can play with the
requests
library. (I'm planning to do more with this later, like
migrate from Falcon to FastAPI.) Some fake user info comes in as a
secret. (The secrets stuff needs more work to be interesting, it just
let me get rid of some redundant example functionality.)
The REST server is used by a sample app, greet.py.
I also have an adaptation of my
toolkit
utility container. When it starts as part of the cluster, the entrypoint
is set to sleep for one day. This lets you open a shell on the machine
(via kubectl exec
) and look around, run the python app, debug, or
whatever. It could also be started as an ephemeral/debugging container
in the fruit
server pod.
-
Start up a kubernetes environment.
-
Vagrant kubeadm Kubernetes, from TechieCamp
- Install Vagrant by HashiCorp
git clone https://github.com/techiescamp/vagrant-kubeadm-kubernetes.git
cd vagrant-kubeadm-kubernetes
vagrant up
-
-
(OPTIONAL) Build the images and push to your own registry. You can pull from mine, but you can't push to it; this is left as an exercise for the reader. If you do this, of course you'll need to adjust the other files.
-
Deploy the resources using
make
. Look in theMakefile
for step-by-step isntructions. This will deploy:- Local-path Persistent Volume and a Persistent Volume Claim for the apps to use the storage
- The
fruit
server Deployment and Services - The
greet
application Deployment, ConfigMaps, and Secrets
-
Start the client cron job. (There is also a single-pod version, 'greet-pod.yaml' that will start and sleep for 1 day.)
kubectl apply -f greet-cronjob.yaml
VKK has a dashboard; see their README.md file for instructions, you'll
need to use kubectl proxy
. I like to use the Rancher Desktop Dashboard
if you're using Rancher Desktop. You could also use k9s
, minikube dashboard
, or a lot of other tools.
A flexible framework for python script command-line applications. Easy to subclass, test, etc. - for my personal use but use it if you want.
Once upon a time, an organizational policy made getting libraries installed on
all the Jenkins clients difficult, the installed packages were a mess, and I
couldn't use virtual environments. I came up with a crazy hack of the python
sys.path to allow me to use local library-ish modules rather than rely on
them being installed in site-packages or running pip install -e ...
. This
made the application somewhat self-contained: it could be downloaded from a
repository and run with a stock python installation. It sucked hard, but it
solved an immediate problem.
Now, the Dockerfile copies the "app_utils" package directory, which contains the framework and some utility code, including my custom initialize_logging() function. It sets up a slightly more complex logging than the basic, but nothing too complex. It can act as a pseudo-singleton, and can be extended pretty easily. The location of log files is configurable.
(N.B. Today I would just use somethng like icecream and/or loguru instead.)
This is a super scaled-down version of the AppFramework, just enough framework to have a nice command-line application.
- Type hints
- Playing with DBs
- More Secrets stuff and Ingress
- Deployment using ArgoCD by a Jenkins job