DevOps with Gitlab, Gitlab-CI, and Dokku

This is merely a collected records of my experience to setup DevOps infrastructure with Gitlab, Gitlab-CI, and Dokku.

Our setup uses virtual environment which is run on Proxmox VE with LXC as OS-level virtualization for Gitlab/Gitlab-CI server, and KVM as hypervisor for Dokku server (virtual machine). The first thing to do is to setup the virtual servers through web-based management of Proxmox VE. We allocate one CPU and 2048 MB of RAM for each virtual server.

There are steps for doing setup of virtual server and thankfully these are provided as a wizard in Proxmox VE. For LXC, our steps are described below.

  1. Login to the web-based management of Proxmox VE.
  2. Select Templates-“ubuntu-14.04_standard*”, and click Download.
  3. Create a container (CT).
  4. Set Hostname and Password.
  5. Use the template image: ubuntu 14.04 standard.
  6. Set disk size from local storage: 8 GB.
  7. Set network configuration, IPv4 Static with netmask /21, and set the gateway.
  8. Set servers for DNS domain.
  9. Finish the wizard.

Gitlab

  1. Use Console on web-based management of Proxmox VE, type these commands and follow the needed steps.
    # adduser stwn
    # visudo
  2. Close the Console and use terminal emulator in your computer.
  3. Remote login to the Gitlab server with SSH.
    $ ssh stwn@gitlab-server
  4. Update the packages index.
    $ sudo apt-get update
  5. Install curl and screen packages.
    $ sudo apt-get install curl screen
  6. Run this command. Adapt the version to the recent version of Gitlab.
    $ curl -LJO https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/trusty/gitlab-ce_8.6.6-ce.0_amd64.deb/download
  7. Install the downloaded Gitlab package.
    $ sudo dpkg -i gitlab-ce_8.6.6-ce.0_amd64.deb
  8. Reconfigure Gitlab for the first time.
    sudo gitlab-ctl reconfigure
  9. Configure nginx-related options.
    $ sudo nano /etc/gitlab/gitlab.rb

    Uncomment these lines.

    web_server['external_users'] = []
    web_server['username'] = 'gitlab-www'
    web_server['group'] = 'gitlab-www'
  10. Reconfigure and restart Gitlab.
    $ sudo gitlab-ctl reconfigure
    $ sudo gitlab-ctl restart

    Use this command to see the log of Gitlab.

    $ sudo gitlab-ctl tail

Gitlab-CI

Dokku

  1. Download ISO image of Ubuntu 14.04.4, and put it in a place which is accesible by Proxmox VE. Boot the virtual machine through the web-based management and follow the steps of the Ubuntu installer.
  2. Login to the Console of the web-based management or via SSH from your local computer/laptop. Configure the interface of the Dokku server.
    $ sudo nano /etc/network/interfaces

    Put these lines in that file.

    iface eth0 inet static
          address 10.16.7.128
          netmask 255.255.248.0
          gateway 10.16.7.1
          dns-nameservers 10.16.7.1
  3. Edit the sources.list file to configure the packages repository server.
    $ sudo nano /etc/apt/sources.list
  4. Update packages list and upgrade all packages.
    $ sudo apt-get update
    $ sudo apt-get upgrade
  5. After that, upgrade the distribution.
    $ sudo apt-get dist-upgrade
  6. Download bootstrap.sh script from Dokku repository.
    $ wget https://raw.githubusercontent.com/dokku/dokku/v0.5.5/bootstrap.sh
  7. Run the script.
    $ sudo DOKKU_TAG=v0.5.5 bash bootstrap.sh

    We need to relax waiting for this command to complete. It depends on the Internet connection. Please watch the network status of the server, if it has on going/active traffic then the script must be working and we should be sit back while it really accomplishes its mission :D

  8. Setup SSH key pairs. Get the public key from Gitlab server with our user in it, e.g. stwn. These commands should be run on the Gitlab server.
    $ ssh-keygen -t rsa
    $ cat .ssh/id_rsa.pub
  9. Visit the local web configuration of Dokku in http://dokku.server/ and copy the content of the output of the previous last command to the Public Key section.

Workflow

 
doc/devops.txt · Last modified: 2016/10/04 00:58 by stwn · [Old revisions]
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki