In this article we'll look at the various package management tools available to build and deploy your containers into Kubernetes. We look at the following package management tools for Kubernetes: Helm Charts, Gitkube and Skaffold
See how to setup a Kubernetes cluster in one of our other articles: Part I: Create a Google Kubernetes Engine (GKE) cluster with Terraform
Kubernetes (K8S) by itself with a few apps running on it - is not a complex thing to master. However, when the number of instances grow and you come to the point when you need to update and deploy apps this is when you start facing challenges. Luckily package management tools have been developed to help you efficiently your container lifecycle on your Kubernetes cluster.
When you deploy your first container into K8S, start with the slimmest, most practical base image like Alpine and then install and configure on top as often as images like centos or Ubuntu have unneed packages installed. Also, inside your container use a non-root user and make the file system read-only. This will improve security, and make it harder for someone to hack into your container.
It is bad practice to run more than one process in a single container. K8S manages containers based on whether a process is healthy or not. With several processes running inside one container, you will not know which process is causing trouble. Use one container per process and put containers with dependable processes in the same Pod.
Command to get the cluster state:
$ kubectl cluster-info
When your Kubernetes is configured it’s time to think about building an application, handling new versions, possible rollouts to the previous version and handling clusters all together. Not all package management tools are the same, some handle the workflow, when other's can offer alternate ways of defining application configuration. We will let you pick the one best suited for your use case.
Just like official web site suggests, Helm helps you manage Kubernetes applications - Helm Charts helps you define, install, and upgrade even the most complex Kubernetes application. However, it’s not only manages applications on K8S, Helm takes care of creating the manifests and versioning them so that rollbacks can be performed across all objects and not just deployments.
Helm Charts are packages that can contain configmap, ingress, deployment, secrets, service or set of services that reside in their own directory and even has own package description file, called a Chart.yaml file. Charts can be published or collected as a chart repo.
Helm is primarily intended as a tool to deploy manifests and manage them in a production environment. With two major components: the Helm CLI and Tiller Server. CLI to helps managing charts and repos and Tiller Server interacting with the CLI to deploy and manage these charts.
Installing Helm from Homebrew:
$ brew install kubernetes-helm $ helm init
Then with a simple command you can install Jenkins onto a k8s cluster using Helm:
$ helm init $ helm install stable/jenkins
Helm: architecture diagram
Gitkube is a building and deploying tool for your Docker images on Kubernetes using git push. It means that - as long as you have dockerfile with your source code repo, you can deploy using gitkube command.
After a easy initial setup, developer can simply keep pushing their repos to build and deploy to Kubernetes automatically. Gitkube philosophy is to simplify application deployment workflow making it as native and familiar as possible. Git is a part of every developers toolkit. When you combine Git and Kubernetes, you’ll get seamless process of deploying apps while keeping the operational part to a minimum for the DevOps/SREs.
Gitkube: architecture diagram
Following are the steps to get you application on K8S and installation of gitkube:
$ git clone https://github.com/hasura/gitkube-example $ cd gitkube-example $ kubectl create -f k8s.yaml $ cat ~/.ssh/id_rsa.pub | awk '$0=" - "$0' >> "remote.yaml" $ kubectl create -f remote.yaml $ kubectl get remote example -o json | jq -r '.status.remoteUrl' $ git remote add example [remoteUrl] $ git push example master ## edit code ## commit and push
Skaffold is another great tool that handles application building workflow as well as pushing and deploying to Kubernetes.
This awesome tool will build the docker image locally, push it to a registry and rollout the deployment using the skaffold CLI tool. It will also stream logs from your containers and watch the directory. As result all rebuilds and redeployments will happen whenever the code inside the directory has been changed.
All the hard lifting is done with CLI and functions like the build, push, deploy pipelines are configurable using a .yaml file. Skaffold is very flexible, relevantly easy to set up tool with ability to manage different build-push-deploy pipelines.
Skaffold: architecture diagram
Here are the steps to deploy an example Go application that prints hello-world:
$ git clone https://github.com/GoogleCloudPlatform/skaffold $ cd examples/getting-started ## edit skaffold.yaml to add docker repo $ skaffold dev ## open new terminal: edit code
We’ve chosen Helm. This great tool saves us ton of time and effort, with Helm charts are easy to create, share, version, and publish. With growing community you get large Helm chart repository full of high-quality charts for everything from Apache to Zookeeper.
Thank you for reading!
Subscribe to Pactosystems Blog
Get the latest posts delivered right to your inbox