Skip to content

Upgrade GitLab in v14.0 and v14.1 appliances

Martin Palastanga edited this page Mar 21, 2017 · 3 revisions

To upgrade your TurnKey v14.0 or v14.1 GitLab appliance, follow the steps below. This only relates to v14.x appliance. Some or part of it may apply to v13.x or earlier but it is not guaranteed. At the time of writing GitLab still supports the following GitLab versions:

  • 8.2.x; 8.3.x; 8.4.x; 8.5.x; 8.6.x; 8.7.x; 8.8.x

However this is subject to change so make sure that you upgrade to a version that is supported by GitLab.

Note that this is quite an extensive process. It is recommended that you do this when you have time and concentration so you don't need to rush.

Preparations and collecting info

  • Get started by creating a backup of your GitLab deployment (e.g., with TKLBAM).

  • Check the version of TurnKey you are running:

    turnkey-version
    

    It should return something like turnkey-gitlab-14.0-jessie-amd64 or turnkey-gitlab-14.1-jessie-amd64, which means version 14.0 or 14.1, respectively. If you have an older version of TurnKey GNU/Linux, these instructions may still help, but success is not guaranteed.

  • Check the version of GitLab your server is using:

    cat /home/git/gitlab/VERSION
    

Getting started

  • Set some environment variables to reduce typing (this only needs to be done once):
HOME='/home/git'
SUDO='sudo -u git -H'
  • Prepare your install for upgrade by stopping GitLab, stashing any local changes and creating a local backup (so it's easy to roll back if something goes wrong). This step needs to be done for each version upgrade:
service gitlab stop
cd $HOME/gitlab
$SUDO git stash
$SUDO bundle exec rake gitlab:backup:create RAILS_ENV=production

If you have TurnKey v14.0 and GitLab 8.1.x or lower, then follow the v14.0 steps below, starting at the relevant GitLab version (assuming that you have previously updated your GitLab, perhaps read through the previous instructions to make sure). If you have v14.1 or GitLab 8.2.x or higher you should be able to skip straight to the v14.1 section.

v14.0

Look down the GitLab versions until you find the version that you have. Then follow the instructions from that point until the end of the v14.0 section.

GitLab <7.14.x

Upgrade to v7.14.x

  • Follow the "Getting Started" directions above.

  • Get the latest GitLab code:

cd $HOME/gitlab
$SUDO git fetch --all
$SUDO git checkout -- db/schema.rb
$SUDO git checkout 7-14-stable
  • Install additional packages
apt-get update
apt-get install logrotate pkg-config cmake nodejs
  • Configure Redis to use sockets
cat > /etc/redis/unixsocket.conf <<EOF
port 0
bind 127.0.0.1
unixsocket /var/run/redis/redis.sock
unixsocketperm 770
EOF

echo 'include /etc/redis/unixsocket.conf' >> /etc/redis/redis.conf

usermod -aG redis git

service redis-server restart

for i in development test production; do
    echo "$i: unix:/var/run/redis/redis.sock" >> $HOME/gitlab/config/resque.yml
done

$SUDO sed -i 's|^  # socket.*|  socket: /var/run/redis/redis.sock|' $HOME/gitlab-shell/config.yml
  • Update gitlab-shell
cd $HOME/gitlab-shell
$SUDO git fetch
$SUDO git checkout v2.6.5
  • Install libs, migrations etc.
cd $HOME/gitlab
$SUDO bundle install --without development test postgres --deployment
$SUDO bundle exec rake db:migrate RAILS_ENV=production
$SUDO bundle exec rake migrate_iids RAILS_ENV=production
$SUDO bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production
chmod u+rwx,g+rx,o-rwx /home/git/gitlab-satellites
cp lib/support/init.d/gitlab /etc/init.d/gitlab
  • Update config files

    $SUDO cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
    cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab
    
  • Change Nginx settings

    • From v7.14.x onwards you need to decide whether you wish to use your site via HTTP or HTTPS.
    cd $HOME/gitlab
    service nginx stop
    rm /etc/nginx/sites-enabled/gitlab
    mv /etc/nginx/sites-available/gitlab /etc/nginx/sites-available/gitlab.old
    cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
    cp lib/support/nginx/gitlab-ssl /etc/nginx/sites-available/gitlab-ssl
    
    • HTTPS (recommended) ln -s /etc/nginx/sites-available/gitlab-ssl /etc/nginx/sites-enabled/gitlab

    • HTTP (NOT recommended) ln -s /etc/nginx/sites-available/gitlab /etc/nginx/sites-enabled/gitlab

    • restart Nginx and double check that it is running

      service nginx start
      service nginx status
      
  • Restart GitLab and test

    service gitlab start
    cd $HOME/gitlab
    $SUDO bundle exec rake gitlab:env:info RAILS_ENV=production
    $SUDO bundle exec rake gitlab:check RAILS_ENV=production
    
  • Update OmniAuth configuration (if relevant to you)

    When using Google omniauth login, changes of the Google account required. Ensure that Contacts API and the Google+ API are enabled in the Google Developers Console. More details can be found at the integration documentation.

Reference: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/6.x-or-7.x-to-7.14.md

GitLab >=7.14.x but <8.0.x

Upgrade to v8.0

  • Follow the "Getting Started" directions above (again).

  • Get the latest GitLab code

cd $HOME/gitlab
$SUDO git fetch --all
$SUDO git checkout -- db/schema.rb
$SUDO git checkout 8-0-stable
  • Update gitlab-shell
cd $HOME/gitlab-shell
$SUDO git fetch
$SUDO git checkout v2.6.5
  • Install gitlab-git-http-server

    • first download Go 1.5 and install it into /usr/local/go
    cd /root
    curl -O --progress https://storage.googleapis.com/golang/go1.5.linux-amd64.tar.gz
    echo '5817fa4b2252afdb02e11e8b9dc1d9173ef3bd5a  go1.5.linux-amd64.tar.gz' | shasum -c - && \
      tar -C /usr/local -xzf go1.5.linux-amd64.tar.gz
    ln -sf /usr/local/go/bin/{go,godoc,gofmt} /usr/local/bin/
    rm go1.5.linux-amd64.tar.gz
    
    • Install gitlab-git-http-server
    cd $HOME
    $SUDO git clone https://gitlab.com/gitlab-org/gitlab-git-http-server.git
    cd gitlab-git-http-server
    $SUDO git checkout 0.2.14
    $SUDO make
    
    • If your Git repositories are in a directory other than $HOME/repositories, you need to tell gitlab-git-http-server about it via /etc/default/gitlab. See $HOME/gitlab/lib/support/init.d/gitlab.default.example for the options.
  • Copy secrets

cd $HOME/gitlab
$SUDO cp config/secrets.yml.example config/secrets.yml
$SUDO chmod 0600 config/secrets.yml
  • Install libs, migrations, etc.
cd $HOME/gitlab
$SUDO bundle install --without postgres development test --deployment
$SUDO bundle exec rake db:migrate RAILS_ENV=production
$SUDO bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production
cp lib/support/init.d/gitlab /etc/init.d/gitlab
  • Update config files

    • There are new configuration options available for gitlab.yml. View them with the command below and apply them manually to your current gitlab.yml:

    git diff origin/7-14-stable:config/gitlab.yml.example origin/8-0-stable:config/gitlab.yml.example

    • Update nginx config:
    cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
    cp lib/support/nginx/gitlab-ssl /etc/nginx/sites-available/gitlab-ssl
    
  • Migrate GitLab CI to GitLab CE

    • As of GitLab 8.0.x, GitLab CE has CI integrated. However, migrations don't happen automatically and you need to do it manually. If you have installed GitLab CI previously (it's not installed by default in TurnKey GitLab), please follow the following guide to migrate your GitLab CI instance to GitLab CE.
    • If you have not installed GitLab CI you can safely skip this step.
  • Restart GitLab and test

    service nginx restart
    service gitlab start
    cd $HOME/gitlab
    $SUDO bundle exec rake gitlab:env:info RAILS_ENV=production
    $SUDO bundle exec rake gitlab:check RAILS_ENV=production
    

Reference: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/7.14-to-8.0.md

GitLab = 8.0

Upgrade to v8.1.x

  • Follow the "Getting Started" directions above (again).

  • Get the latest GitLab code:

cd $HOME/gitlab
$SUDO git fetch --all
$SUDO git checkout -- db/schema.rb
$SUDO git checkout 8-1-stable
  • Update gitlab-shell:
cd $HOME/gitlab-shell
$SUDO git fetch
$SUDO git checkout v2.6.5
  • Update gitlab-git-http-server
cd $HOME/gitlab-git-http-server
$SUDO git fetch origin
$SUDO git checkout 0.3.0
$SUDO make
  • Install libs, migrations, etc.
cd $HOME/gitlab
$SUDO bundle install --without postgres development test --deployment
$SUDO bundle exec rake db:migrate RAILS_ENV=production
$SUDO bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production
cp lib/support/init.d/gitlab /etc/init.d/gitlab
  • Update config files

    • There are new configuration options available for gitlab.yml. View them with the command below and apply them manually to your current gitlab.yml:

    git diff origin/8-0-stable:config/gitlab.yml.example origin/8-1-stable:config/gitlab.yml.example

    • Update nginx config:
    cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
    cp lib/support/nginx/gitlab-ssl /etc/nginx/sites-available/gitlab-ssl
    
  • Restart GitLab and test

    service nginx restart
    service gitlab start
    cd $HOME/gitlab
    $SUDO bundle exec rake gitlab:env:info RAILS_ENV=production
    $SUDO bundle exec rake gitlab:check RAILS_ENV=production
    

Reference: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/8.0-to-8.1.md

GitLab = 8.1.x

Upgrade to v8.2.x

8.2.x is the oldest version of GitLab still supported. 8.2.5 has the required security fixes included.

  • Follow the "Getting Started" directions above (again).

  • Get the latest GitLab code:

cd $HOME/gitlab
$SUDO git fetch --all
$SUDO git checkout -- db/schema.rb
$SUDO git checkout 8-2-stable
  • Update gitlab-shell:
cd $HOME/gitlab-shell
$SUDO git fetch
$SUDO git checkout v2.6.8
  • Replace gitlab-git-http-server with gitlab-workhorse

    • Install and compile gitlab-workhorse. This requires Go 1.5 which should already be on your system from GitLab 8.1.
cd $HOME
$SUDO git clone https://gitlab.com/gitlab-org/gitlab-workhorse.git
cd gitlab-workhorse
$SUDO git checkout 0.4.2
$SUDO make
  • Update the GitLab 'default' file
cd $HOME/gitlab
test -e /etc/default/gitlab && \
  sed -i.pre-8.2 's/^\([^=]*\)gitlab_git_http_server/\1gitlab_workhorse/' /etc/default/gitlab
  • Install libs, migrations, etc.
cd $HOME/gitlab
$SUDO bundle install --without postgres development test --deployment
$SUDO bundle exec rake db:migrate RAILS_ENV=production
$SUDO bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production
cp lib/support/init.d/gitlab /etc/init.d/gitlab
  • Update config files

    • There are new configuration options available for gitlab.yml. View them with the command below and apply them manually to your current gitlab.yml:

    git diff origin/8-1-stable:config/gitlab.yml.example origin/8-2-stable:config/gitlab.yml.example

    • Update nginx config:
    cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
    cp lib/support/nginx/gitlab-ssl /etc/nginx/sites-available/gitlab-ssl
    
  • Restart GitLab and test

    service nginx restart
    service gitlab start
    cd $HOME/gitlab
    $SUDO bundle exec rake gitlab:env:info RAILS_ENV=production
    $SUDO bundle exec rake gitlab:check RAILS_ENV=production
    
  • (Optional) remove gitlab-git-http-server

    • Temporarily rename gitlab-git-http-server directory

      mv $HOME/gitlab-git-http-server $HOME/gitlab-git-http-server.old
      
    • Test that everything is still working as it should

    • Remove gitlab-git-http-server. Note: Only complete this step once you have confirmed that GitLab is working properly.

      rm -r $HOME/gitlab-git-http-server.old
      

Reference: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/8.1-to-8.2.md

Your GitLab install should now be secure. Double check to make sure that the version is >=8.2.5

cat /home/git/gitlab/VERSION

If you wish to upgrade to GitLab to 8.3.x (8.3.9 currently) then follow the steps below.

v14.1

The v14.1 GitLab appliance came with GitLab 8.3.x installed. To update v14.1 (or v14.0 already updated to GitLab 8.2.x) to the latest secure 8.3.x (8.3.9 currently) follow these instructions:

  • Follow the "Getting Started" directions above (again).

  • Get the latest GitLab code:

cd $HOME/gitlab
$SUDO git fetch --all
$SUDO git checkout -- db/schema.rb
$SUDO git checkout 8-3-stable
  • Update gitlab-shell:
cd $HOME/gitlab-shell
$SUDO git fetch
$SUDO git checkout v2.6.9
  • Update gitlab-workhorse
cd $HOME/gitlab-workhorse
$SUDO git fetch -all
$SUDO git checkout 0.5.4
$SUDO make
  • Install libs, migrations, etc.
cd $HOME/gitlab
$SUDO bundle install --without postgres development test --deployment
$SUDO bundle exec rake db:migrate RAILS_ENV=production
$SUDO bundle exec rake assets:clean assets:precompile cache:clear RAILS_ENV=production
cp lib/support/init.d/gitlab /etc/init.d/gitlab
  • Update config files

    • Note: only required if upgrading from 8.2.x. There are new configuration options available for gitlab.yml. View them with the command below and apply them to your current gitlab.yml manually:

    git diff origin/8-2-stable:config/gitlab.yml.example origin/8-3-stable:config/gitlab.yml.example

    • Update nginx config:
    cd $HOME/gitlab
    cp lib/support/nginx/gitlab /etc/nginx/sites-available/gitlab
    cp lib/support/nginx/gitlab-ssl /etc/nginx/sites-available/gitlab-ssl
    
    • Update init script
    cd $HOME/gitlab
    cp lib/support/init.d/gitlab /etc/init.d/gitlab
    
  • Restart GitLab and test

    service nginx restart
    service gitlab start
    cd $HOME/gitlab
    $SUDO bundle exec rake gitlab:env:info RAILS_ENV=production
    $SUDO bundle exec rake gitlab:check RAILS_ENV=production
    

Further updates

You can check for available updates from the Admin page within your GitLab appliance.

  • If you wish, you can continue updating to newer versions. E.g. to upgrade to v8.3.x:

https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/8.2-to-8.3.md

All of the possible update instructions can be found in the GitLab docs:

https://gitlab.com/gitlab-org/gitlab-ce/tree/master/doc/update

You can’t perform that action at this time.