woodcockjosh
4/12/2019 - 4:32 PM

3 stage deployment pipeline with kubernetes and gitlabs

Stage 1: Local deployment - Local kubernetes cluster
    developer
      git commit
      git push local master

    gitlab.local
      post recieve hook
      docker build -t dockerhub.local/app-name:git-revision
      docker push dockerhub.local/app-name:git-revision
      update helm chart values with git-revision for docker image
      helm install
      helm upgrade
		
    developer
      does more testing done on local kubernetes

------------------------------------------------------------------------------------------------------------

Stage 2: Dev deployment - Dev kubernetes cluster
    developer
      git push origin branch-name
	  
    gitlab.com via post receive hook
      creates pull request if it doesn't exist
      runs tests
      builds docker image with commit revision

    developer
      merge pull request
      
        gitlab.com : via post receive hook
          create new-semantic-version
          docker build -t dev-registry.cryptexlabs.com/app-name:new-semantic-version
          update helm chart values with new-semantic-version for docker image
          git commit new helm chart with new-semantic-version
          git push origin master
          git tag new-semantic-version
          git push new-semantic-version
          docker push dev-registry.cryptexlabs.com/app-name:new-semantic-version
          helm install
          helm upgrade
	
    developer
      does more testing done on dev kubernetes

        If tag has bugs
          developer
            deletes git tag
            deletes docker tag

------------------------------------------------------------------------------------------------------------

Stage 3: Prod - Prod kubernetes cluster
    user
      update release-version in gitlab pipeline
      initiate manual deployment
      
    gitlab.com via manual trigger
      save current-version as last-version
      pull helm chart for release-version
      docker pull release-version from dev docker registry
      docker tag -t registry.gitlab.com/cryptex-labs/app-name:release-version
      docker push registry.gitlab.com/cryptex-labs/app-name:release-version
      helm install
      helm upgrade
      delete all image tags between release-version and last-version so that only prod deployments stay in git and dev-docker registry
        aws ecr batch-delete-image --repository-name dev-registry.cryptexlabs.com --image-ids imageTag=${outdated-tag}