0

Introducing Kubes: The Kubernetes Deployment Tool

 3 years ago
source link: https://blog.boltops.com/2020/08/15/introducing-kubes-the-kubernetes-deployment-tool
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Kubes is a deployment tool that makes it easier and more fun to work with Kubernetes. Kubes automates 3 main steps.

  1. Build a Docker image.
  2. Create the YAML files that declare the Kubernetes resources.
  3. 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 run kubectl 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.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK