Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Gitkube: Continuous Deployment to Kubernetes using Git Push

Gitkube: Continuous Deployment to Kubernetes using Git Push

A short demo on Gitkube and it's architecture as presented at ContainerDays 2018, Hamburg.

Shahidh K Muhammed

June 20, 2018
Tweet

More Decks by Shahidh K Muhammed

Other Decks in Technology

Transcript

  1. @shahidh_k Before <> After $ git push dev master $

    docker build -t registry.com/my-image:my-tag $ docker push registry.com/my-image:my-tag $ kubectl set image deployment/my-deployment container=registry.com/my-image:my-tag
  2. @shahidh_k Git hooks client-side > pre-push Exit can abort push

    server-side > pre-receive Exit can abort push > post-receive Cannot abort push Executable files in .git/hooks/ named <hook> .git/hooks/pre-receive
  3. @shahidh_k Architecture - Git remote agent on the cluster. Pre-receive

    hook: - Build docker image - Apply to k8s deployment - Configuration: - SSH keys - Dockerfile path - Sync configuration changes with the git-remote agent - K8s Operator git-remote k8s :: deployment,svc Exposed externally SSH-key based auth deployment $ git push dev master CRD configuration k8s :: CRD Deployments to update authorized-keys Dockerfile path controller k8s :: operator Apply changes $ kubectl ... remote.yaml </> your computer Kubernetes cluster
  4. @shahidh_k remote.yaml apiVersion: gitkube.sh/v1alpha1 kind: Remote metadata: name: dev spec:

    authorizedKeys: - "ssh-rsa your-ssh-public-key" deployments: - name: app containers: - name: app path: app dockerfile: app/Dockerfile Kubernetes CRD
  5. @shahidh_k remote.yaml apiVersion: gitkube.sh/v1alpha1 kind: Remote metadata: name: dev spec:

    authorizedKeys: - "ssh-rsa your-ssh-public-key" deployments: - name: app containers: - name: app path: app dockerfile: app/Dockerfile Access control
  6. @shahidh_k remote.yaml apiVersion: gitkube.sh/v1alpha1 kind: Remote metadata: name: dev spec:

    authorizedKeys: - "ssh-rsa your-ssh-public-key" deployments: - name: app containers: - name: app path: app dockerfile: app/Dockerfile app ├── Dockerfile ├── k8s.yaml └── src ├── app.py ├── requirements.txt └── server.py
  7. @shahidh_k Why Gitkube? git just works for AllTheThings™ git checkout

    <commit> git push dev my-branch:master • git push to apply changes to kubernetes objects. • Every developer is familiar with git. • Quick iteration time when used on dev/staging clusters • Simple permission system based on public keys • Very small surface area. Can easily be replaced with more sophisticated CI/CD pipelines when moving to production.