Skip to content

Expose setting to specify config_command in GitLab KAS config file

Balasankar 'Balu' C requested to merge 8355-gitlab-kas-external-config into master

What does this MR do?

Expose setting to specify config.command in GitLab KAS config file

Testing

  1. Deploy GitLab using the following docker-compose file

    docker-compose.yml
    version: '3.8'
    name: 'gitlab-test'
    
    x-default_settings: &default_settings
      image: "${GITLAB_IMAGE:-registry.gitlab.com/gitlab-org/omnibus-gitlab/gitlab-ee:8355-gitlab-kas-external-config}"
      pull_policy: always
      privileged: true
      shm_size: '256m'
      restart: always
    
    services:
      redis-for-rails:
        <<: *default_settings
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            roles ['redis_master_role']
    
            # Redis configuration
            redis['bind'] = '10.0.0.2'
            redis['port'] = 6379
            redis['password'] = 'rails-redis-password'
    
            # This is a pure Redis node. We don't need Rails stuff.
            gitlab_rails['enable'] = false
        networks:
          default:
            ipv4_address: 10.0.0.2
        healthcheck:
          test: ["CMD", "gitlab-redis-cli", "ping"]
          start_period: 60s
    
      redis-for-kas:
        <<: *default_settings
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            roles ['redis_master_role']
    
            # Redis configuration
            redis['bind'] = '10.0.0.3'
            redis['port'] = 6379
            redis['password'] = 'kas-redis-password'
    
            # This is a pure Redis node. We don't need Rails stuff.
            gitlab_rails['enable'] = false
        networks:
          default:
            ipv4_address: 10.0.0.3
        healthcheck:
          test: ["CMD", "gitlab-redis-cli", "ping"]
          start_period: 60s
    
      gitlab:
        <<: *default_settings
        environment:
          GITLAB_OMNIBUS_CONFIG: |
            external_url "http://127.0.0.1"
    
            redis['enable'] = false
    
            # Redis related information for Rails
            gitlab_rails['redis_host'] = '10.0.0.2'
            gitlab_rails['redis_port'] = '6379'
            gitlab_rails['redis_password'] = 'rails-redis-password'
    
            # Redis related information for KAS
            gitlab_kas['redis_host'] = '10.0.0.3'
            gitlab_kas['redis_port'] = '6379'
            gitlab_kas['redis_password'] = ''
        ports:
          - "80:80"
          - "443:443"
          - "22:22"
        networks:
          default:
            ipv4_address: 10.0.0.4
        healthcheck:
          disable: true
        depends_on:
          redis-for-rails:
            condition: service_healthy
          redis-for-kas:
            condition: service_healthy
    
    networks:
      default:
        ipam:
          config:
            - subnet: 10.0.0.0/24
  2. See that KAS is spitting out errors due to missing password

    $ docker compose exec -it gitlab gitlab-ctl tail gitlab-kas
    2023-12-22_06:03:06.92614 Program aborted: NOAUTH HELLO must be called with the client already authenticated, otherwise the HELLO AUTH <user> <pass> option can be used to authenticate the client and select the RESP protocol version at the same time      
    2023-12-22_06:03:07.95149 Program aborted: NOAUTH HELLO must be called with the client already authenticated, otherwise the HELLO AUTH <user> <pass> option can be used to authenticate the client and select the RESP protocol version at the same time      
    2023-12-22_06:03:08.97308 Program aborted: NOAUTH HELLO must be called with the client already authenticated, otherwise the HELLO AUTH <user> <pass> option can be used to authenticate the client and select the RESP protocol version at the same time      
    2023-12-22_06:03:10.00152 Program aborted: NOAUTH HELLO must be called with the client already authenticated, otherwise the HELLO AUTH <user> <pass> option can be used to authenticate the client and select the RESP protocol version at the same time      
  3. Drop into the GitLab container

    $ docker compose exec -it gitlab bash
  4. Create a script at /opt/kas-redis.sh with the following content

    #!/usr/bin/env bash
    cat << EOF
    redis:
      password: 'kas-redis-password'
    EOF
  5. Make the script executable

    $ chmod +x /opt/kas-redis.sh
  6. Add the following to /etc/gitlab/gitlab.rb

    gitlab_kas['extra_config_command'] = '/opt/kas-redis.sh'
  7. Run gitlab-ctl reconfigure and confirm that the KAS errors has gone away.

Related issues

Closes #8355 (closed)

Checklist

See Definition of done.

For anything in this list which will not be completed, please provide a reason in the MR discussion.

Required

  • MR title and description are up to date, accurate, and descriptive.
  • MR targeting the appropriate branch.
  • Latest Merge Result pipeline is green.
  • When ready for review, MR is labeled "~workflow::ready for review" per the Distribution MR workflow.

For GitLab team members

If you don't have access to this, the reviewer should trigger these jobs for you during the review process.

  • The manual Trigger:ee-package jobs have a green pipeline running against latest commit.
  • If config/software or config/patches directories are changed, make sure the build-package-on-all-os job within the Trigger:ee-package downstream pipeline succeeded.
  • If you are changing anything SSL related, then the Trigger:package:fips manual job within the Trigger:ee-package downstream pipeline must succeed.
  • If CI configuration is changed, the branch must be pushed to dev.gitlab.org to confirm regular branch builds aren't broken.

Expected (please provide an explanation if not completing)

  • Test plan indicating conditions for success has been posted and passes.
  • Documentation created/updated.
  • Tests added.
  • Integration tests added to GitLab QA.
  • Equivalent MR/issue for the GitLab Chart opened.
  • Validate potential values for new configuration settings. Formats such as integer 10, duration 10s, URI scheme://user:passwd@host:port may require quotation or other special handling when rendered in a template and written to a configuration file.
Edited by Balasankar 'Balu' C

Merge request reports