Slide 1

Slide 1 text

Git based application deployment patterns for Kubernetes Git ❤ K8s

Slide 2

Slide 2 text

Shahidh K Muhammed @shahidh_k

Slide 3

Slide 3 text

Git ● Distributed version control system ● Manage source code ● Any text files can be tracked ● Collaboration

Slide 4

Slide 4 text

Git - Source of Truth ● Infrastructure as Code ○ Terraform, CloudFormation ● System Configuration as Code ○ Ansible ○ Chef ○ Puppet ● Application Configuration as Code ○ Kubernetes ○ Hasura ● Application Source Code

Slide 5

Slide 5 text

Ops ● Configure, build, test, deploy ● CI/CD ● Monitor, fix ● Upgrades ● Rollbacks ● Automation

Slide 6

Slide 6 text

GitOps ● Stable surface (tooling abstraction) for developers ● Things change under this surface ● Git as the boundary ● Everything should be declarative ● Driving DevOps through Git ● Reduced toolset, Complete extensibility ● Everything as Code - Kuberentes

Slide 7

Slide 7 text

Approach ● Stable surface (tooling abstraction) for developers ● Without restricting the ability of the operators to interface with infrastructure or to enforce controls and release processes. ● "Below" this stable surface operators change plumbing ● "Above" this surface developers use consistent tooling

Slide 8

Slide 8 text

Git as the boundary ● For a developer, Git is the perfect tool for creating a "stable" boundary. ● Git-hooks on the client-side/server-side ● Webhook integrations offered by centralised git-hosting providers (github, bitbucket etc) ● Constraint: ○ git-hooks and webhooks can only make use of information inside the git repository ○ or the environment that the git-hook/webhook runs in ● Key constraint: Everything must become declarative.

Slide 9

Slide 9 text

Everything must become declarative Declarative tools ❤ Git

Slide 10

Slide 10 text

Git push to deploy ● Comfortable and known workflow for developers ● Given everything is declarative, Git is the only tool a developer need to drive DevOps tasks

Slide 11

Slide 11 text

GitOps - particular way of driving DevOps with Git

Slide 12

Slide 12 text

GitOps - Benefits ● Reduced toolset ○ Developers only need to use git for all DevOps tasks ● Complete extensibility ○ git-hooks and webhooks allow for infinite customisation and tooling to be implemented by operators without affecting the developer workflow in the slightest

Slide 13

Slide 13 text

GitOps - a checklist Developers ● Declarative microservice runtime: Dockerfile ● Declarative environment configuration: Kubernetes PodSpec ● Declarative stateful actions: Jobs as containers, migration files

Slide 14

Slide 14 text

GitOps - a checklist Operators ● Programmable git-remote/webhook listener on the cluster ● Declarative infrastructure requirements: CloudFormation, Terraform ● Declarative deployment: Kubernetes DeploymentSpec ● Declarative tests - run as jobs in a pipeline triggered by a webhook or git-hooks ● Implement CI/CD tasks automation in git-hooks ● Implement deployment of stateful tasks like database migrations ● Monorepo or a config repo - configuration, integration tests for the application are stored ● Store secrets/tokens as references to actual values on the Kubernetes cluster, or a vault

Slide 15

Slide 15 text

Everything as Code

Slide 16

Slide 16 text

GitOps on Kubernetes ● Setting up a git-remote that can receive git events or webhooks: Gitkube.sh: git push to your kubernetes cluster to build and deploy docker images ● Synchronising state in git repo with state on a kubernetes cluster: Flux: A controller running on a kubernetes cluster that synchronises the declarative spec in the git repo with the state of the kubernetes cluster ● Setting up git-hooks for running stateful migrations: Hasura: A CLI that sets up git-hooks on the local and remote git that can apply configuration, database migrations and can build/deploy docker images via git events.

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

Gitkube - Architecture

Slide 19

Slide 19 text

Demo ● Gitkube ● GitOps at Hasura: ○ Deploying applications ○ Changing subdomain ○ Add a new domain ○ Database migrations

Slide 20

Slide 20 text

Shahidh K Muhammed @shahidh_k Thanks for listening! Questions?