Notes Gitlab

Voir :

Notes Gitlab-CI

CIS GitLab Benchmark

Voir aussi :

Gogs

Gitea

GitPrep

gitweb

ArgoCD

Tekton

Install via Docker

Docker

Docker-compose avec Gitlab runner :

https://www.jamescoyle.net/how-to/docker-compose-files/3179-docker-compose-yml-for-gitlab-and-gitlab-runner

https://gitlab.com/gitlab-org/gitlab/-/issues/23911

https://github.com/jeshan/gitlab-on-compose/blob/master/docker-compose.yml

https://gist.github.com/barnybug/e988cfcd937e7414187c51f4d1e2cb82

https://medium.com/@rukeith/how-to-use-docker-to-build-a-self-host-gitlab-and-gitlab-runner-781981dc4d03

Configuration du runner

docker run --rm -ti --name gitlab-runner --add-host gitlab.local:172.17.0.1 \ -v /srv/gitlab-runner/config:/etc/gitlab-runner \ -v /var/run/docker.sock:/var/run/docker.sock \ gitlab/gitlab-runner:alpine register

/srv/gitlab-runner/config/config.toml

concurrent = 1 check_interval = 0 [session_server] session_timeout = 1800 [[runners]] name = "89fa5654f698" url = "http://gitlab.local:8081/" token = "FKXKQ5Zg1KmwB9ssNVU9" executor = "docker" [runners.custom_build_dir] [runners.cache] [runners.cache.s3] [runners.cache.gcs] [runners.cache.azure] [runners.docker] tls_verify = false image = "alpine" privileged = false disable_entrypoint_overwrite = false oom_kill_disable = false disable_cache = false volumes = ["/cache"] shm_size = 0

Gitlab créera de nouveau containers. Ils devrons etre capable de faire un git clone Pour configurer les flux réseaux, ajoutez clone_url = Dans notre exemple 172.18.0.1 est la passerelle par défaut des nouveaux containers crées.

/gitlab-runner/config/config.toml

[[runners]] #url = "http://gitlab.local:8081/" url = "http://gitlab.local/" clone_url = "http://172.18.0.1:8081"

docker-compose.yml

version: '3.7' services: gitlab: image: 'gitlab/gitlab-ce:latest' restart: unless-stopped hostname: 'gitlab.local' environment: GITLAB_OMNIBUS_CONFIG: | #external_url 'http://gitlab.local' # Add any other gitlab.rb configuration here, each on its own line ports: - '127.0.0.1:8081:80' - '127.0.0.1:4443:443' - '127.0.0.1:2222:22' volumes: - "/srv/gitlab/config:/etc/gitlab" - "/srv/gitlab/logs:/var/log/gitlab" - "/srv/gitlab/data:/var/opt/gitlab" networks: - gitlab-net gitlab-runner: image: gitlab/gitlab-runner:alpine restart: unless-stopped depends_on: - gitlab volumes: - /srv/gitlab-runner/config:/etc/gitlab-runner - /var/run/docker.sock:/var/run/docker.sock networks: - gitlab-net networks: gitlab-net: name: gitlab-net

srv/gitlab/config/gitlab.rb

gitlab_rails['env'] = { 'MALLOC_CONF' => 'dirty_decay_ms:1000,muzzy_decay_ms:1000' } gitaly['env'] = { 'LD_PRELOAD' => '/opt/gitlab/embedded/lib/libjemalloc.so', 'MALLOC_CONF' => 'dirty_decay_ms:1000,muzzy_decay_ms:1000', 'GITALY_COMMAND_SPAWN_MAX_PARALLEL' => '2' } gitlab_rails['gitlab_username_changing_enabled'] = true gitlab_rails['trusted_proxies'] = ["172.16.0.0/12"] gitlab_rails['omniauth_enabled'] = false puma['worker_processes'] = 0 puma['exporter_enabled'] = false sidekiq['max_concurrency'] = 10 sidekiq['metrics_enabled'] = false postgresql['shared_buffers'] = "1024MB" nginx['redirect_http_to_https'] = true nginx['listen_port'] = 80 nginx['listen_https'] = false prometheus['enable'] = false alertmanager['enable'] = false node_exporter['enable'] = false redis_exporter['enable'] = false postgres_exporter['enable'] = false pgbouncer_exporter['enable'] = false gitlab_exporter['enable'] = false grafana['enable'] = false grafana['metrics_enabled'] = false #gitaly['enable'] = false gitaly['ruby_max_rss'] = 200_000_000 # RSS threshold in bytes for triggering a gitaly-ruby restart gitaly['concurrency'] = [ { 'rpc' => "/gitaly.SmartHTTPService/PostReceivePack", 'max_per_repo' => 3 }, { 'rpc' => "/gitaly.SSHService/SSHUploadPack", 'max_per_repo' => 3 } ] gitaly['cgroups_count'] = 2 gitaly['cgroups_hierarchy_root'] = 'gitaly' gitaly['cgroups_memory_enabled'] = true gitaly['cgroups_memory_limit'] = 500000 gitaly['cgroups_cpu_enabled'] = true gitaly['cgroups_cpu_shares'] = 512

Lancement de Gitlab et de Gitlab-Runner

docker-compose -d up
docker exec -ti gitlab gitlab-ctl reconfigure docker restart gitlab

Config WebUI

User : root

Password

docker exec -it gitlab grep 'Password:' /etc/gitlab/initial_root_password

Open registration is enabled on your instance.

Admin Area - Settings - General - Sign-up restrictions

Sign-up enabled Require admin approval for new sign-ups

URL d'admin : https://gitlab.acme.local/admin

Le compte admin par defaut est “root”

Edit Profile - Account

Change username

admin/application_settings/general Account and limit Gravatar enabled Disable

admin/application_settings/general User OAuth applications Allow users to register any application to use GitLab as an OAuth provider Disable

admin/application_settings/general Third-party offers Do not display offers from third parties Checked

admin/application_settings/metrics_and_profiling Metrics - Prometheus Enable health and performance metrics endpoint Disable

profile Private profile Don't display activity-related personal information on your profile

Admin Area - Overview - Users

Config Runners avec Docker

Admin Area - Overview - Runners

docker-compose exec gitlab-runner gitlab-runner register

Enter the GitLab instance URL (for example, https://gitlab.com/): http://gitlab/

Enter the registration token: 2_xtsj1yw4sacbWwG46y

Enter an executor: docker, docker-ssh, ssh, docker+machine, kubernetes, custom, parallels, shell, virtualbox, docker-ssh+machine:
docker Enter the default Docker image (for example, ruby:2.6): alpine

Reconfig

docker-compose exec gitlab gitlab-ctl reconfigure docker-compose exec gitlab gitlab-ctl restart

Pb

Erreur dans Gitlab Settings CI/DI - There was an error fetching the environments information.

Solution :

Settings, General, Visibility, project features, permissions in Pipelines (Build, test, and deploy your changes) select Only Project Members

Autres

Installation sur Ubuntu 16.04

https://packages.gitlab.com/gitlab/gitlab-ce/install

curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash apt-get install gitlab-ce

--------------
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
---------------

sudo gitlab-ctl reconfigure

Optimisation

/etc/gitlab/gitlab.rb

##! **recommend value is 1/4 of total RAM, up to 14GB.** # postgresql['shared_buffers'] = "256MB" postgresql['shared_buffers'] = "4096MB"
gitlab-ctl restart postgresql

Les composants suivants seront automatiquement installés :

nginx

postgres

redis

A présent connectez vous sur le port 80 et définissez un mot de passe