kdeploy - Automating kubernetes and docker deploying
I recently coded kdeploy, which is small tool that helps you to deploy your docker image to your kubernetes cluster by providing a manifest file and running kdeploy.
Intro to kdeploy
kdeploy is small tool written in python that utilizes kubernetes and docker libs to build & publish images to your docker repository and deploy them to kubernetes cluster. Aim is to have your development environment very simple, fast and with little to no tinkering to get your small dockerized app up and running.
Problem with development env
Coding on your own laptop and trying your code out should be fun and easy. Majority of developers don’t want to deal with publishing, building and doing pipelines for their small app they developed in their spare time. Preparing scripts that will deploy an app, copying them around from project to project is cumbersome. Let’s say I coded small flask app and I just want it up and running as soon as possible, without figuring out kubernetes deployment, services and fixing the secrets for docker repo etc. I just want to specify what is name of my app, it should run in pod and it needs exposed port 80 as service, thats it. Here comes kdeploy that gives you just that.
Overview of kdeploy
So let’s quickly overview what kdeploy needs as requirement to run and what it does.
Requirements
python - obviously
kubernetes cluster configured - you should have your kubernetes cluster configured and be able to run kubectl on it, to manipulate it.
docker repository configured - you should have your docker credentials setup and be able to login to your docker repository that you want to store your app to.
Process
Once you have kdeploy installed locally, you should have manifest.yaml in your folder and just run: kdeploy
What it kdeploy does is:
Finds
Dockerfile
in folder you ran kdeployReads
manifest.yaml
file to make sure what is the name of this app and how do you want it deployed (Either as Pod, CronJob or maybe a Deployment with replicas…). It will also figure out if you need a service if you provided exposed port etc.Builds docker image locally and tags it with app name
Pushes image to your docker repository with appropriate tag and version
Checks if you have secret set for kubernetes to be able to pull this docker image
Generates kubernetes files for deploying the app
Deploys app to your kubernetes
Demo
Here is simple example how would you deploy a very simple html serving app:
Try it yourself
You are welcome to follow instructions for installation and usage on my github: https://github.com/krmeljalen/kdeploy
Final words
I basically swapped all my personal projects to kdeploy. I used to have bunch of bash scripts that did similar things and I just got to a point where I wanted to change something in that deploy process and would need to update bunch of repos for it. kdeploy solved this issue for me. There will probably be more updates to kdeploy as I might need more features, but for majority of my projects, kdeploy already covers them. There are just few projects that need specific kubernetes files, but for those, kdeploy also supports path to kubernetes yaml specifying. This means, even if I want to have this one project very special and need to setup some persistent volumes and whatnot, I still can use kdeploy for it.