Private GitLab Server Automatic Installation with Jelastic PaaS

38

Git repositories became an integral part of the development process, and usually they are administered with GitHub or BitBucket. But while having a private project you may not want to trust the code to the tool hosted by a third party. So in order to get the required control, flexibility and simplicity within an own dedicated server, developers turn to GitLab installation.

3250-1-gitlab-community-edition

Professing an open source business model, a dedicated GitLab server can be easily deployed to a cloud environment. And the deployment with the help of Docker containers allows to immensely increase elasticity and scaling for extra efficiency. In this article, we will demonstrate how to combine cutting-edge technologies such as GitLab and Docker using Jelastic PaaS automation functionality.

GitLab Package Overview

We found a popular repository sameersbn/docker-gitlab with a detailed multipage manual how to get a running private GitLab Server in containers. This project is licensed under MIT and distinguished by a high rate and numerous forks that proves its sustainability.

3250-1-gitlab-docker

To make it even better, Jelastic PaaS added value to the mentioned repository by including:

  • Elastic resource provisioning with automatic vertical scaling;
  • Built-in SSL and Let’s Encrypt SSL for custom domains;
  • Auto discovery of Runners while scaling them horizontally;
  • Injection of required dynamic environment variables:
    • Environment and Domain Name;
    • Security Tokens;
    • Required Passwords;
    • Volume Configs.
  • Cost efficient cloud hosting with Pay As You Use pricing model based on the real usage only.

The listed options are packaged with a GitLab server as a DevOps Lab manifest for automatic installation on top of Jelastic PaaS. By default, the whole topology consists of two Docker Engine nodes:

3250-1-gitlab-topology

The automation package performs the following actions:

  • Creates 2 system containers with pre-installed Docker Engine CE and docker-compose utility;
  • Generates and installs self-signed or Let’s Encrypt SSL certificates, as well as shares them with Runners via NFS volume;
  • Injects dynamic environment variables such as tokens, passwords and environment domain;
  • Deploys GitLab Server and Container Registry via docker-compose.yml in one Docker Engine node;
  • Creates one Runner in a separate Docker Engine and registers it automatically in GitLab Server;
  • Automates discovery of newly added Runners upon horizontal scaling.

GitLab Server Installation

Let’s walk through the installation process. Enter Jelastic PaaS dashboard, find GitLab in the Marketplace and press Install.

3250-1-gitlab-server-marketplace-installation

Alternatively, you can import the DevOps Lab manifest by pressing the Import button.

3250-1-devops-lab-gitlab-server

In the opened popup dialog, specify the Name of the Environment and choose the preferred Region. Click on the Install button.

Wait a few minutes till the installation is completed. Using credentials from the successful installation message or received email notification, log in to the admin panel by pressing Open in Browser.

3250-1-gitlab-open-in-browser

Scaling Runners Horizontally

When a team is growing and a private GitLab Server becomes busy with builds of many different projects, it’s time to consider to increase the number of Runners to build and to deploy. The package automation helps to get benefits of horizontal scaling without the need to perform any extra manual configuration. Each Runner is going to be placed in a separate container and automatically registered to the GitLab server.

First of all, let’s make sure that the initial GitLab Runner instance is properly registered at the GitLab server. Open Admin Area > Runners.

3250-1-gitlab-server-admin-area

And to get more Runners, go to the Jelastic PaaS dashboard and press the Change Environment Topology button.

3250-1-change-environment-topology

Then click on the Docker-ce icon and press the + button in Horizontal Scaling section to add more Runner nodes. Finally, Apply changes.

3250-1-docker-horizontal-scaling

Now, we have 4 Runner instances.

3250-1-scaled-runners

Using the GitLab Admin Area, make sure the new Runner instances are registered at the GitLab server.

3250-1-runners-added

Import Projects from GitHub

Let’s briefly review how to import projects from GitHub to your private GitLab Server hosted in Jelastic PaaS.

Once you logged in to the GitLab Server admin panel with the account which was automatically created for you, сlick on Create a project.

3250-1-import-github-project

Then press Import project and after that click on GitHub.

To import repositories, you have to get a Personal Access Token.

3250-1-github-personal-access-token

Choose the required scopes (at least, the repo section to be able to manage repositories). Finally, press Generate token.

3250-1-github-generate-token

3250-1-github-access-token

Copy the token, get back to Import Repositories from GitHub at the GitLab Server admin panel, and paste it in a proper field and submit by clicking the List your GitHub repositories button.

3250-1-import-github-repositories

Now you have access to your repositories at GitHub. To begin importing, you should click on the corresponding Import button next to the required repository.

3250-1-import-required-repository

When importing is finished, the project is delivered to the private GitLab platform.

3250-1-github-project-imported

Docker Registry Access

As mentioned, the automation package provides a Private Docker Registry. To connect to it, use the details that can be found at Create a project > Registry. So, click on Create a project.

3250-1-docker-registry-create-project

Fill out the project name (e.g., myproject) and create it. Then click on the Registry icon in the left pane.

3250-1-docker-registry

After that, you will be redirected to your private Docker Container Registry page. Copy the connection string to ensure the Registry is accessible.

3250-1-docker-registry-connection-string

Issue a command to login into the Registry from the command line interface as follows:

sudo docker login my-gitlab.jelastic.cloud:8443

Tip: To avoid to use sudo with the docker command, add the user (in our case, the user is jel as on the picture below) to the unix docker group with the following command:
 
sudo usermod -aG docker jel
 
More information at https://docs.docker.com/install/linux/linux-postinstall/.

3250-1-docker-registry-command-line-access

Custom Domain and Let’s Encrypt SSL

The installation window has an option to install the Let’s Encrypt add-on that will provide an ability to generate an SSL certificate for a custom domain which is bound to your environment.

3250-1-lets-encrypt-add-on

In this case, the environment will be created with a public IP and a Let’s Encrypt staging certificate by default. To install a fully trusted production certificate, you have to bind a custom domain to the GitLab Server via A or CNAME records beforehand. To bind this custom domain, click on the Add-ons icon.

3250-1-gitlab-server-add-ons

Find Let’s Encrypt Free SSL add-on and click on Configure.

3250-1-configure-lets-encrypt-add-on

After that, specify the custom domain name (e.g., gitlab.extdomain.com) in the External Domain(s) field and press Apply.

3250-1-configure-external-custom-domain

GitLab Server Update

The automation package has a built-in GitLab Server software update procedure that can be initiated via Update GitLab Server add-on, which is installed by default. The software update procedure checks whether a new version of GitLab server is available at the Jelastic PaaS repository and updates it if any.

To use the software update procedure, go to the Add-ons as described in the previous step, find the Update GitLab Server add-on and just click on the Update button.

3250-1-update-gitlab-server

That’s it! Gain the required level of control, flexibility and simplicity while managing your code in a private dedicated GitLab Server. Try it yourself with a free trial at our Jelastic PaaS platform.

SOURCEJelastic, Inc.