Introducing Kubes: The Kubernetes Deployment Tool
Kubes is a deployment tool that makes it easier and more fun to work with Kubernetes. Kubes automates 3 main steps.
- Build a Docker image.
- Create the YAML files that declare the Kubernetes resources.
- Run
kubectl apply
to create the resources on the cluster.
It boils everything down to one single command:
kubes deploy
Quick Start
To get started, install kubes:
gem install kubes
Then simply create an empty directory and run kubes init
in it.
$ mkdir demo
$ cd demo
# ECR here but can be GCR, ACR, etc
$ REPO=111111111111.dkr.ecr.us-west-2.amazonaws.com/demo
$ kubes init --app demo --repo $REPO
exist
create Dockerfile
exist
create .kubes/config.rb
create .kubes/config/env/dev.rb
create .kubes/config/env/prod.rb
exist
create .kubes/resources/base/all.yaml
create .kubes/resources/base/deployment.yaml
create .kubes/resources/shared/namespace.yaml
create .kubes/resources/web/deployment.yaml
create .kubes/resources/web/deployment/dev.yaml
create .kubes/resources/web/deployment/prod.yaml
create .kubes/resources/web/service.yaml
Initialized .kubes folder
Updated .gitignore
Kubes init creates a starter template structure with a simple Dockerfile that runs the httpd webserver. Note, if your project already has a Dockerfile, then kubes uses the existing Dockerfile instead.
Kubes Deploy
To deploy it’s one simple command:
$ kubes deploy
=> docker build -t 111111111111.dkr.ecr.us-west-2.amazonaws.com/demo:kubes-2020-08-15T17-46-02 -f Dockerfile .
=> docker push 111111111111.dkr.ecr.us-west-2.amazonaws.com/demo:kubes-2020-08-15T17-46-02
Pushed 111111111111.dkr.ecr.us-west-2.amazonaws.com/demo:kubes-2020-08-15T17-46-02 docker image.
Compiled .kubes/resources files to .kubes/output
Deploying kubes resources
=> kubectl apply -f .kubes/output/shared/namespace.yaml
namespace/demo created
=> kubectl apply -f .kubes/output/web/service.yaml
service/web created
=> kubectl apply -f .kubes/output/web/deployment.yaml
deployment.apps/web created
$
As you can see, kubes builds the docker image, generates the YAML files, and then runs kubectl
in the correct order.
Kubes also prints out the underlying docker
and kubectl
commands so it’s clear what it’s doing. If you wish, you can run the commands directly also. Or you can also run the 3 steps individually. See Kubes Run in Separate Steps.
Conveniences
There are more conveniences that kubes offers:
Command | Description |
---|---|
kubes get | List all the resources defined and created by kubes from the .kubes folder. It also lists the pods associated with the deployment. |
kubes exec | Hops into the first deployment’s pod’s container. If there are multiple containers, you can specify the container with -c. This avoids having to manually copy and paste the pod name with kubectl exec -ti . |
kubes logs | Shows the logs for the deployment pods. |
Much More
There much more features and customizations that kubes provides. Here are some of them:
- Ordering: When deploying, kubes runs
kubectl apply
for each Kubernetes resource in the correct order. When deleting, kubes will also runkubectl delete
in the correct reverse order. - Layering: Use the same Kubernetes YAML to build multiple environments like dev and prod with layering.
- CLI Args and Hooks: You can customize the CLI args. You can also run hooks before and after kubectl commands.
- Kustomize Support: If you’re a kustomization user, you can use it with Kubes.
For more details check out the Kubes Intro Docs
Summary
Kubes is a Kubernetes deployment tool that saves you precious finger-typing energy. It automates the process and provides many additional conveniences. It also prints out the underlying the kubectl commands, so you know what’s happening. By reducing the Kubernetes mental overhead, you can focus on your code and app development. Learn more on the official kubes.guru site.
Thanks for reading this far. If you found this article useful, I'd really appreciate it if you share this article so others can find it too! Thanks 😁 Also follow me on Twitter.
Got questions? Check out BoltOps.
You might also like
More tools:
-
Kubes
Kubes: Kubernetes Deployment Tool
Kubes is a Kubernetes Deployment Tool. It builds the docker image, creates the Kubernetes YAML, and runs kubectl apply. It automates the deployment process and saves you precious finger-typing energy.
-
Jets
Jets: The Ruby Serverless Framework
Ruby on Jets allows you to create and deploy serverless services with ease, and to seamlessly glue AWS services together with the most beautiful dynamic language: Ruby. It includes everything you need to build an API and deploy it to AWS Lambda. Jets leverages the power of Ruby to make serverless joyful for everyone.
-
Lono
Lono: The CloudFormation Framework
Building infrastructure-as-code is challenging. Lono makes it much easier and fun. It includes everything you need to manage and deploy infrastructure-as-code.