Introduction to GitOps Deployment to Kubernetes by @sakajunquality. 10 November 2018
About me Jun Sakata / @sakajunquality - Google Developers Expert, Cloud Software Engineer at Ubie inc. From Japan Loves: #kubernetes and #beer
Ubie Inc. - Medical Startup in Japan. - Most of the workloads are on Kubernetes. - Since Oct. 2018
Agenda - Concept of GitOps - Very Prototype of GitOps in Ubie - Future Perspectives
Google Cloud Platform - As the company is using GCP, services used in the slides are products of GCP. - But the whole story and idea, I believe, can be applied to any Cloud or On-Prem.
GitOps - Operations by Pull Request https://www.weave.works/blog/gitops-operations-by-pull-request
GitOps Basics - Two different types of git repository. - Application Repo: Application source code Config Repo: Declarative manifest for configuration Application Config
Concept of GitOps - All the manifest is managed declaratively in Git. - Any “apply” is through CI.
Concept of GitOps - In Other Words... - Manifest in the Git represents the current state of the infrastructure. - Any kind of manual “apply” is prohibited.
Very Prototype of GitOps in Ubie
Infrastructure in Ubie - Several services are running on Kubernetes cluster. - Frontend Several backend microservices - Kubernetes (in Ubie) = Google Kubernetes Engine. - All the workloads are on Google Cloud Platform. Migrated from Heroku on Oct. 2018.
My GitOps Philosophy in Ubie - Workflow itself should be simple. - Each components should be decoupled. - New application should be easily integrated. (as much as possible)
GitOps First Step - Commit and Push to the manifest repo manually. - Create an release Pull-Request manually. - Merge the Pull-Request to deploy.
GitOps First Step: Problems Obviously there are problems, - We make mistakes. - Difficult to make changes to manifest repo for engineers.
GitOps Second Step - Commit to the manifest repo and Create an release Pull-Request automatically. - Merge the Pull Request to deploy.
GitOps Second Step: GitOps App - App that subscribes event from CI (Cloud Build) through MQ (Cloud Pub/Sub), - Create an Release Pull-Request on Github. Notify the Pull-Request via Slack.
GitOps Second Step: GitOps App - Slack Notification After docker image is finished, Pull-Request url is notified via slack.
GitOps Second Step: GitOps App - Github Pull-Request Engineer just need to merge the Pull-Request.
GitOps Second Step: GitOps App - Rollback When you need to rollback, - Revert the merged Pull-Request. - Merge the reverted Pull-Request.
No manual changes to the manifest (in terms of application release)
GitOps App - Using custom app written in Go. - OSS exists though. - https://github.com/weaveworks/flux
Example in google/go-github is helpful to create a GitOps App https://github.com/google/go-github/blob/master/example/commitpr/main.go
Some Improvements from the Prototype - Support for pre/post jobs like migration. - Support for ad-hoc pre/post jobs. - Must consider rollback! - Deployment notification - Must be easy for developers. - Canary Release / Release Analytics Currently working on it...
Some Improvements from the Prototype After changes are merged to manifest repo, manifest just is applied through kubectl apply with CI (Cloud Build), there are other options, like more complex CI.
Conclusion - By GitOps, workflow for Kubernetes can be simple. - GitOps can be introduced step by step. - Let’s start simply :)
For more info I will publish an article with more detail, and share on my twitter: @sakajunquality