Herramientas de usuario

Herramientas del sitio


gentoo:gitlab-ce

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anteriorRevisión previa
Próxima revisión
Revisión previa
gentoo:gitlab-ce [2019/10/05 09:17] – [Upgrade the container] barrachigentoo:gitlab-ce [2024/05/01 16:57] (actual) – [Upgrade the container] barrachi
Línea 1: Línea 1:
 ====== GitLab Community Edition installation (using docker) ====== ====== GitLab Community Edition installation (using docker) ======
  
-Although it is possible to [[https://wiki.gentoo.org/wiki/GitLab | install GitLab directly on Gentoo ]], this guide will cover the installation of the GitLab Community Edition using ''docker''.+Although it is possible to [[https://wiki.gentoo.org/wiki/GitLab | install GitLab directly on Gentoo ]], this guide covers the installation of the GitLab Community Edition using ''docker''.
  
 ===== Install and run docker on Gentoo ===== ===== Install and run docker on Gentoo =====
Línea 54: Línea 54:
 </code> </code>
  
-To see the logs of the gitlab docker:+To see the logs of a container while it is starting: 
 +<code bash> 
 +docker logs -f CONTAINER_ID 
 +</code> 
 + 
 +To see the logs of the gitlab container:
 <code bash> <code bash>
 docker exec gitlab gitlab-ctl tail docker exec gitlab gitlab-ctl tail
 </code> </code>
  
-To execute a bash inside the gitlab docker:+To execute a bash inside the gitlab container:
 <code bash> <code bash>
 docker exec -it gitlab /bin/bash docker exec -it gitlab /bin/bash
 </code> </code>
  
- +To enter the gitlab-rails console:
-===== NFS caveats ===== +
- +
-The NFS server and client can be fine tuned following the [[https://docs.gitlab.com/ee/administration/high_availability/nfs.html | GitLab NFS documentation]]. +
- +
-If '''/var/opt/gitlab' is not writable'' errors occur (which can be checked with ''docker exec gitlab gitlab-ctl tail''), these can be avoided after starting the gitlab docker by changing the owner of ''/var/opt/gitlab'' to ''git''. Also, the ''noac'' nfs4 mount option should be used on the NFS client to prevent attributes to be cached and, therefore, to allow the previous change to be accounted for as soon as possible. +
- +
-This change can be made permanent, patching ''/opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb'' as follows:: +
- +
-<code diff> +
---- /opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb.orig     2019-10-03 13:39:21.826524552 +0000 +
-+++ /opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb    2019-10-03 13:41:03.499281744 +0000 +
-@@ -45,6 +45,11 @@ +
-   action :create +
- end +
- +
-+directory "/var/opt/gitlab" do +
-+  owner "git" +
-+  action :create +
-+end +
-+
- directory "Create /var/log/gitlab" do +
-   path "/var/log/gitlab" +
-   owner "root" +
-</code> +
- +
-The '''/var/opt/gitlab' is not writable'' errors are caused when testing if the directory ''/var/opt/gitlab/.bundle'' is writable by the user ''git''. The ''stats()'' function says that is not writable unless its parent is also writable by that user. This can be tested with the following command:+
 <code bash> <code bash>
-docker exec gitlab su git -c "[ -w /var/opt/gitlab/.bundle ] || echo 'no writable'"+docker exec -it gitlab gitlab-rails console
 </code> </code>
  
  
 +More GitLab maintenance options in https://docs.gitlab.com/omnibus/maintenance/
 ===== Upgrade the container ===== ===== Upgrade the container =====
  
-1. Check the digest number of the current version with:+1. Check the current GitLab version x.y.z in the Administration dashboard.
  
-<code bash> 
-docker images --digests | grep gitlab-ce | grep latest | grep sha256: 
-</code> 
  
-2Compare the first digits of the digest number with those of the lastes version in: <https://hub.docker.com/r/gitlab/gitlab-ce/tags>.+2aIf it says that there is an update available, go to https://hub.docker.com/r/gitlab/gitlab-ce/tags and search the latest tag with the next subversion: x.y+1.
  
-3Stop and delete the current image, then pull the new version:+2bInstead of going by one, check the migration path in https://gitlab-com.gitlab.io/support/toolbox/upgrade-path/?current=14.6.6&distro=docker&edition=ce 
 + 
 + 
 +3. Copy the pull command an execute it:
  
 <code bash> <code bash>
-docker stop gitlab +docker pull gitlab/gitlab-ce:x.y+1.z-ce.0
-docker rm gitlab +
-docker pull gitlab/gitlab-ce+
 </code> </code>
  
-4. If an NFS mount point is used and the '''/var/opt/gitlab' is not writable'' error occurs, then apply the previously shown patch:+4. Optionally, tag the retrieved image as 'my-gitlab-cewith:
  
 <code bash> <code bash>
-# Run the image once using bash as entry point: +docker tag gitlab/gitlab-ce:x.y+1.z-ce.my-gitlab-ce
-docker run -it --entrypoint bash gitlab/gitlab-ce +
-# Apply the previous patch on default.rb: +
-nano /opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb +
-# Create new image from ID (it appears in the prompt, e.groot@9ffa2bafe2bb:/#), +
-docker commit 9ffa2bafe2bb my-gitlab-ce+
 </code> </code>
  
-5. Run the image+ 
 +5. Stop and delete the current gitlab container, then create and start a new gitlab container from the newer image:
  
 <code bash> <code bash>
 +docker stop gitlab
 +docker rm gitlab
 docker run --detach \ docker run --detach \
   [...]   [...]
Línea 135: Línea 111:
   --volume /srv/gitlab/logs:/var/log/gitlab \   --volume /srv/gitlab/logs:/var/log/gitlab \
   --volume /srv/gitlab/data:/var/opt/gitlab \   --volume /srv/gitlab/data:/var/opt/gitlab \
-  gitlab/gitlab-ce:latest # or my-gilab-ce+  my-gitlab-ce # or gitlab/gitlab-ce:x.y+1.z-ce.0
 </code> </code>
  
-5. Cleanup previous images:+6. Check that everything went Ok and monitor on the web interface the background migrations. **When all the background migrations have finished**, go to the Dashboard and check if there is a newer version available. If this is the caso, go again to the second step. 
 + 
 + 
 +7. Cleanup docker unused images, containers, networks and volumes:
  
 <code bash> <code bash>
-docker rmi $(docker images -f "dangling=true" -q)+docker system prune --volumes
 </code> </code>
  
-===== Backup and restore =====+7. Check that the backup procedure is working with the new version an delete the previous versions backups. 
 + 
 + 
 +===== PostgreSQL update ===== 
 + 
 +The PostgreSQL version is updated only on some versions of Gitlab. To check which version should be used to perform the PostgreSQL update, please check: https://docs.gitlab.com/omnibus/package-information/postgresql_versions.html 
 + 
 +The tagged docker Gitlab versions can be seen in: https://registry.hub.docker.com/r/gitlab/gitlab-ce/tags 
 + 
 + 
 +===== Backup =====
  
 The backup strategy described next generates a backup file with a fixed name that will be incrementally backed up using an external tool. The container name is assumed to be ''gitlab''. The backup strategy described next generates a backup file with a fixed name that will be incrementally backed up using an external tool. The container name is assumed to be ''gitlab''.
Línea 161: Línea 150:
 </code> </code>
  
-To restore a given backup, restore the previous dirs and follow the instructions in [[https://docs.gitlab.com/ee/raketasks/backup_restore.html | Backing up and restoring GitLab]].+===== Restore =====
  
-The next procedure assumes that: +To restore a given backup, restore the previously backed up dirs and follow the instructions in [[https://docs.gitlab.com/ee/raketasks/backup_restore.html | Backing up and restoring GitLab]]. The next procedure assumes that: 
- +  You have installed the exact same version and type (CE/EE) of GitLab Omnibus with which the backup was created.
-You have installed the exact same version and type (CE/EE) of GitLab Omnibus with which the backup was created.+
   * You have run ''gitlab-ctl reconfigure'' at least once.   * You have run ''gitlab-ctl reconfigure'' at least once.
   * GitLab is running. If not, start it using ''gitlab-ctl start''.   * GitLab is running. If not, start it using ''gitlab-ctl start''.
-  * First make sure your backup tar file is in the backup directory (''/var/opt/gitlab/backups''). **It needs to be owned by the git user**.+ 
 +First make sure your backup tar file is in the backup directory (''/var/opt/gitlab/backups''). **It needs to be owned by the git user**.
  
 <code bash> <code bash>
 cp gitlab-ce-12.3.4_gitlab_backup.tar /srv/gitlab/data/backups/ cp gitlab-ce-12.3.4_gitlab_backup.tar /srv/gitlab/data/backups/
 docker exec -it gitlab bash docker exec -it gitlab bash
-chown git.git /var/opt/gitlab/backups/* +chown git.git /var/opt/gitlab/backups/ 
-</code>+</code>
  
 Stop the processes that are connected to the database. Leave the rest of GitLab running: Stop the processes that are connected to the database. Leave the rest of GitLab running:
  
 <code bash> <code bash>
-sudo gitlab-ctl stop unicorn +gitlab-ctl stop unicorn 
-sudo gitlab-ctl stop sidekiq+gitlab-ctl stop sidekiq
 # Verify # Verify
-sudo gitlab-ctl status +gitlab-ctl status 
-</code>+</code>
  
 Next, restore the backup, specifying the **name part** of the backup you wish to restore: Next, restore the backup, specifying the **name part** of the backup you wish to restore:
Línea 191: Línea 180:
 gitlab-backup restore BACKUP=gitlab-ce-12.3.4 gitlab-backup restore BACKUP=gitlab-ce-12.3.4
 </code> </code>
-+
 Next, restore /etc/gitlab/gitlab-secrets.json if necessary as mentioned above. Next, restore /etc/gitlab/gitlab-secrets.json if necessary as mentioned above.
  
 Reconfigure, restart and check GitLab: Reconfigure, restart and check GitLab:
  
-<code bash>+<code>
 gitlab-ctl reconfigure gitlab-ctl reconfigure
 gitlab-ctl restart gitlab-ctl restart
 gitlab-rake gitlab:check SANITIZE=true gitlab-rake gitlab:check SANITIZE=true
 </code> </code>
 +
 +
 +
 +===== NFS caveats =====
 +
 +**DO NOT USE NFS WITH GITLAB-CE CONTAINER**
 +
 +If there are permission problems with your NFS configuration, it is better to no use it. What follows show how to avoid one of the problems, but another one raised when migrating from PostgreSQL 11 to 12.
 +
 +**DO NOT USE NFS WITH GITLAB-CE CONTAINER**
 +
 +The NFS server and client can be fine tuned following the [[https://docs.gitlab.com/ee/administration/high_availability/nfs.html | GitLab NFS documentation]].
 +
 +If '''/var/opt/gitlab' is not writable'' errors occur (which can be checked with ''docker exec gitlab gitlab-ctl tail''), these can be avoided after starting the gitlab docker by changing the owner of ''/var/opt/gitlab'' to ''git''. Also, the ''noac'' nfs4 mount option should be used on the NFS client to prevent attributes to be cached and, therefore, to allow the previous change to be accounted for as soon as possible.
 +
 +This change can be made permanent, patching ''/opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb'' as follows::
 +
 +<code diff>
 +--- /opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb.orig     2019-10-03 13:39:21.826524552 +0000
 ++++ /opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb    2019-10-03 13:41:03.499281744 +0000
 +@@ -45,6 +45,11 @@
 +   action :create
 + end
 +
 ++directory "/var/opt/gitlab" do
 ++  owner "git"
 ++  action :create
 ++end
 ++
 + directory "Create /var/log/gitlab" do
 +   path "/var/log/gitlab"
 +   owner "root"
 +</code>
 +
 +The '''/var/opt/gitlab' is not writable'' errors are caused when testing if the directory ''/var/opt/gitlab/.bundle'' is writable by the user ''git''. The ''stats()'' function says that is not writable unless its parent is also writable by that user. This can be tested with the following command:
 +<code bash>
 +docker exec gitlab su - git -c "[ -w /var/opt/gitlab/.bundle ] || echo 'no writable'"
 +</code>
 +
 +If an NFS mount point is used and the '''/var/opt/gitlab' is not writable'' error occurs, then apply the previously shown patch with:
 +
 +<code bash>
 +# Run the image once using bash as entry point:
 +docker run -it --entrypoint bash gitlab/gitlab-ce
 +# Apply the previous patch on default.rb:
 +nano /opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb
 +# Exit the image
 +exit
 +# Create new image from ID (it appears in the prompt, e.g. root@9ffa2bafe2bb:/#),
 +docker commit 9ffa2bafe2bb my-gitlab-ce
 +</code>
 +
 +
 ===== References ===== ===== References =====
  
 [1] https://hub.docker.com/r/gitlab/gitlab-ce/ [1] https://hub.docker.com/r/gitlab/gitlab-ce/
gentoo/gitlab-ce.1570267068.txt.gz · Última modificación: 2019/10/05 09:17 por barrachi