This gem provides a bunch of useful Rake tasks to automate deployment to the Kubernetes cluster in Google Kubernetes Engine (GKE):
- Show configuration for the environment.
- Show the status of running Deployment & Pods.
- Check GCloud/K8s configuration and GIT (branch, uncommitted changes, etc.).
- Build a new Docker image, push it to the registry, and patch Deployment.
- Rollback Deployment to the previous state.
- Scale Deployment to the desired number of replicas.
Add the gem to your Gemfile:
gem 'k8s-deploy'
Invoke the following command from your terminal:
gem install k8s-deploy
- Put the
k8s-deploy.yml
configuration file into your project root. - Add
require 'k8s-deploy/tasks'
line to your Rakefile. - Check available tasks with
rake -T
command.
production: # environment name
git_branch: main
dockerfile: ./Dockerfile
docker_platform: linux/amd64
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
.
require 'k8s-deploy/tasks'
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>
Show configuration for the environment:
rake k8s:<environment>:configuration
Show the status of running Deployment & Pods:
rake k8s:<environment>:status
Check GCloud/K8s configuration and GIT (branch, uncommitted changes, etc.):
rake k8s:<environment>:check
Build a new Docker image, push it to the registry, and patch Deployment:
rake k8s:<environment>:deploy
Rollback Deployment to the previous state.
rake k8s:<environment>:rollback
Scale Deployment to the desired number of replicas.
rake k8s:<environment>:scale[1]
Bug reports and pull requests are welcome on GitHub at https://github.com/syngenta/k8s-deploy.
Please, check our Contribution guide for more details.
This project adheres to the Code of Conduct. We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
The project uses the MIT License. See LICENSE for details.