gitlab-ce/qa/gems/gitlab-cng/README.md

3.1 KiB

cng

cng is a CLI tool that supports setting up and deploying Cloud Native GitLab builds using the official GitLab Chart.

Usage

cng is internal gem so it is not published to rubygems. Run cng by prefixing commands with bundle exec within its directory.

$ bundle exec cng
Commands:
  cng create [SUBCOMMAND]   # Manage deployment related object creation
  cng destroy [SUBCOMMAND]  # Manage deployment related object cleanup
  cng doctor                # Validate presence of all required system dependencies
  cng help [COMMAND]        # Describe available commands or one specific command
  cng log [SUBCOMMAND]      # Manage deployment related logs
  cng version               # Print cng orchestrator version

Add new deployments

The main feature cng is to programmatically manage different deployment type configurations and setup. To implement new deployment configuration:

  1. Add a new subcommand method to the Deployment class. This allows you to to define your own input arguments and documentation.
  2. Define a configuration class based on the Base configuration class. You can implement:
    • pre-deployment setup: optional setup steps that are executed before installing the GitLab instance.
    • post-deployment setup: optional setup steps that are executed after instance of GitLab has been installed.
    • helm values: set of values to apply during installation.
  3. Define a cleanup class based on the Base cleanup class. Implement a single method that deletes all objects created by pre-deployment and post-deployment setup.

All different options for GitLab deployment on Kubernetes cluster are described in GitLab Helm chart documentation page.

Tips

kubectl context

cng CLI uses kubectl and Helm to perform all kubernetes-related operations. When running a deployment, current context is always used. If non-default arguments are used when running the deployment, make sure current context points to the cluster where the deployment should be executed.

Shell integration

To make cng globally available in your shell without the need to run the commands from a specific folder and prefixed with bundle exec, add the following function to your shell's configuration file (for example,.zshrc or .bash_profile):

function cng() {
  (cd $PATH_TO_GITLAB_REPO/gems/gitlab-cng && BUNDLE_AUTO_INSTALL=true bundle exec cng "$@")
}

Troubleshooting

Because cng tool essentially wraps helm upgrade --install command, official Troubleshooting the GitLab chart guide can be used for troubleshooting deployment failures.