Setting Up Your Own Private GitLab On Azure

GitLab
Azure is Microsoft’s business cloud and GitLab is a pre-configured offering on the Azure Marketplace. Don’t get surprised to hear that Microsoft and Azure have embraced open source software like Ubuntu, Red Hat Enterprise Linux, and GitLab. You can now spin up a pre-configured GitLab VM in just a few clicks on Azure. Let’s get started.

Let’s Get started

To start First you need Azure account.

You can open an Azure account for free. You get credits you can use to try out paid Azure services, and even after you’ve used them you can still keep the account and use the free Azure services. Your credit card won’t be charged, unless you decide to pay-as-you-go. This is a great way to try out Azure and cloud computing.

Working with Azure

Once your account is ready and able to login to portal.azure.com you will see the Dashboard which gives you a quick overview of Azure resources:

Working With Azure
From the Dashboard you can build VMs, create SQL Databases, author websites, and perform lots of other cloud tasks. Today we want to try GitLab which is part of the Azure Marketplace. The Marketplace is an online store for pre-configured applications and services optimized for the cloud by software vendors like GitLab. Click on the + New icon and in the search box type “GitLab”:

Search Gitlab

Create new VM

Azure Marketplace offerings are always changing but let’s click “GitLab Community Edition”. GitLab CE is freely available under the MIT Expat License. A new “blade” window will pop-out, where you can read about the offering.

Create New VM
Click “Create” and you will be presented with the “Create virtual machine” blade.

Basics

The first thing we need to configure are the basic settings of the underlying Ubuntu 14.04.4 VM. On the screenshot below, I set the hostname to “GitLab-CE” and I chose Password authentication to keep things simple. This is the password that we will use later to SSH into the VM, so make sure it’s a strong password/passphrase. Alternatively you can choose to paste your SSH public key so that you don’t type your password every time. A “Resource group” is a way to group related resources together for easier administration. I named mine “GitLab-CE-Azure”, but your resource group can have the same name as your VM. Click OK when ready.

Basics

Size

The next screen reviews the Pricing Tiers, which are the VM sizes. I chose a “D1 Standard” VM, which meets the minimum system requirements to run a small GitLab environment. When ready click ‘Select’.

By default, only the recommended tiers are shown. To choose a larger one click on ‘View all’.

Size

Settings

On the next blade, you are called to configure the Storage, Network and Availability settings. Just review them and take the defaults which are sufficient for test-driving GitLab. Hit OK when done.

Settings

Summary

On the summary page you will have the chance to review your choices so far. If you change your mind about something, you can go back to the previous steps and amend your choice. Hit OK when ready.

Summary

Buy

This is the last step and you are presented with the price/hour your new VM will cost. You can see that we are billed only for the VM at this page, GitLab CE is a separate tile which is free to use. Go on and click Purchase for the deployment to begin.

Buy

Deployment page

At this point, Azure takes over and begins deploying your GitLab Ubuntu VM. You can scroll down to see the deployment process which takes a few minutes.

Deployment Page
When GitLab environment is ready, you will see the management blade for your new VM. This is basically your VM dashboard where you can configure many things like the DNS name of your instance.

VM Dashboard

Set up a domain name

The public IP address that the VM uses is shown in the ‘Essentials’ blade. Click on it and select Configuration under the ‘General’ tab. Enter a friendly DNS name for your instance in the DNS name label field.

Set Up a Domain Name
In the screenshot above I have set my DNS name to gitlab-ce-test.xxx.cloudapp.azure.com. Hit Save for the changes to take effect.

If you want to use your own domain name, add a DNS A record into your domain registrar pointing to the IP address displayed given by Azure.

Connecting to GitLab

Use the IP address or the domain name you set up from the previous step to visit GitLab on your browser.
The first time you hit the URL, you will be asked to set up a new password for the administrator user that GitLab has created for you.

Connecting To Gitlab
Once you change the password you will be redirected to login. Use root as the username and the password you configured just before.Connecting To Gitlab
At this point you have a working GitLab VM running on Azure. Congratulations!

Creating your first GitLab project

You can skip this section if you are familiar with Git and GitLab. Otherwise, let’s create our first project. From the Welcome page click New Project.

Creating your First Gitlab Project
I’m going to make this a private project called “demo”:

Gitlab Project Demo
It only takes a few moments to create the project and the next screen will show you the commands to begin working with your new repository locally.

Gitlab Project Demo
Following these instructions you should be able to push and pull from your new GitLab repository.

That’s it! You have a working GitLab environment!

Maintaining your GitLab instance

It’s important to keep your GitLab environment up-to-date and since the GitLab team is constantly making enhancements to the product, occasionally you may need to upgrade for security reasons.

Let’s review how to upgrade GitLab. When you click on the “Admin Area” wrench, GitLab will tell you whether there are updates available. In the following screenshot we are told to update ASAP, and this is because there is a security fix.

Maintaining your Gitlab Instance
On the screenshot we can see the current Azure Marketplace offered GitLab CE version 8.6.5, and there is an update available. To update you need to connect to your Ubuntu server using PuTTY or an equivalent SSH tool. Remember to log in with the username and password you specified when you created your Azure VM.

In your terminal type in the following to connect to your VM:

ssh user@gitlab-ce-test.westeurope.cloudapp.azure.com

Provide your password at the prompt to authenticate.

Your domain name will differ and is the one we set up previously. You can also use the public IP instead of the domain name.

Once you login, use the following command to upgrade GitLab to the latest version.

sudo apt-get update && sudo apt-get install gitlab-ce

Once it completes you should have an up-to-date GitLab instance!GitLab Admin

Conclusion

GitLab is a great Git repo tool, plus a whole lot more. In this post we looked at how to run GitLab using the Azure Marketplace offering. Azure is a great way to experiment with GitLab. If you decide, like me, that GitLab is the best solution for source code management you can continue to use Azure as your secure, scalable cloud provider.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>