automate deploy to Kubernetes.

gem install k8s-deploy -v 0.0.4


K8s deploy


💣 Important — this gem is not production ready.

This gem provides bunch of useful Rake tasks to automate deploy to Kubernetes cluster in Google Container Engine.



Add gem to your Gemfile:

gem 'k8s-deploy'


Invoke the following command from your terminal:

gem install k8s-deploy


  1. You need to put k8s-deploy.yml file into your project root.
  2. Add require 'k8s-deploy/tasks' to your Rakefile.
  3. Check available tasks with rake -T command.
Example of k8s-deploy.yml
production: # environment name
  git_branch: master
  dockerfile: ./Dockerfile
  container_registry: gcr.io
  gcloud_project_name: your-gcloud-project-name
  kubernetes_context: your-cluster-context
  kubernetes_deployment_name: your-deployment-name
  kubernetes_template_name: your-template-name
  kubernetes_docker_image_name: your-dcoker-image-name

You could add as many environments as you need (production, staging, test, etc.) to k8s-deploy.yml.

Example of Rakefile
require 'k8s-deploy/tasks'
Example of rake -T output
rake k8s:production:check                         # Check production ready for deploy
rake k8s:production:check:gcloud                  # Check production GCloud
rake k8s:production:check:git                     # Check production GIT
rake k8s:production:configuration                 # Show production configuration
rake k8s:production:deploy                        # Deploy to production
rake k8s:production:deploy:build                  # Build container for production
rake k8s:production:deploy:deployment_patch       # Deployment patch for production
rake k8s:production:deploy:push                   # Push container for production
rake k8s:production:deploy:rollback               # Rollback last deployment to production
rake k8s:production:deploy:scale[replicas_count]  # Scale deployment production
rake k8s:production:status                        # Show production K8s status
rake k8s:production:status:deployment             # Show production K8s Deployment status
rake k8s:production:status:docker_image           # Show production K8s Deployment status
rake k8s:production:status:pods                   # Show production K8s Pods status


All tasks have next structure:

rake k8s:<environment>:<main-task>:<sub-task>

Main tasks

Show configuration for environment:

rake k8s:<environment>:configuration

Show status of running Deployment & Pods:

rake k8s:<environment>:status

Check GCloud/K8s configuration and GIT (branch, uncommitted changes, etc.):

rake k8s:<environment>:check

Build new Docker image, push to registry, patch Deployment:

rake k8s:<environment>:deploy

Rollback Deployment to previous state.

rake k8s:<environment>:rollback

Scale Deployment to desired number of replicas.

rake k8s:<environment>:scale[1]


The project uses the MIT License. See LICENSE.md for details.