Published on August 10, 2017
3 min read
How to get started with our auto deploy feature using Google Kubernetes Engine.
For up-to-date information on GitLab's native integration with Google Kubernetes Engine, please visit the announcement blog post: GitLab + Google Cloud Platform = simplified, scalable deployment.
Once you write your code the next question is, "How do you deploy it?" There are plenty of ways to do it but none of them is perfect. You need to configure external tools, write your own scripts and maybe even do manual command execution every time you want a new version deployed. At GitLab we believe deployment should be an essential part of workflows, like code review and CI. Several months ago we shipped an amazing feature, auto deploy, that should take care of code deployment for you. Finally, I found some time to give it a try.
Originally released in 8.15 and heavily improved since then, auto deploy should deploy your application as part of a CI/CD pipeline within the GitLab user interface. It means you can set up an application to be deployed automatically every time a new commit lands into the master
branch.
As per the documentation, the feature will package your application into a Docker image that then will be deployed to Kubernetes. GitLab has a container registry feature so the Docker image will be stored within GitLab too.
Setup of the GitLab auto deploy feature is a matter of clicking on the "Set up auto deploy" button and applying the "Kubernetes" template to your .gitlab-ci.yml
file. However, before this, you need to configure your GitLab project with valid credentials so it can access your cluster. Which brings us to the point that you need your Kubernetes cluster first.
The documentation states, "Google Kubernetes Engine is a managed environment for deploying containerized applications." It runs Kubernetes and you can create your cluster with a few clicks in the web interface.
There are a few other Kubernetes hosting solutions available on the market and you might prefer a different one, but as a newcomer I decided to go with Google for a few reasons:
It took me some time to figure out the sequence of events and actions to make it work. This is the result:
.gitlab-ci.yml
As a result, I have a Ruby application that is built and deployed to staging automatically once I push code to the master branch. Additionally, I can manually deploy any pipeline to production with a single click.
For those who are new to Kubernetes but want to try GitLab auto deploy in action, I made a quick start guide.
Cover image by Joseph Barrientos on Unsplash
Find out which plan works best for your team
Learn about pricingLearn about what GitLab can do for your team
Talk to an expert